Serge E. Hallyn wrote:
> Quoting Oren Laadan (or...@cs.columbia.edu):
>> -int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
>> +int
>> +ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size, int 
>> req_id)
>>  {
>>      uid_t euid;
>>      gid_t egid;
>> +    int lid = 0;
>>      int id, err;
>>
>>      if (size > IPCMNI)
>> @@ -268,28 +270,41 @@ int ipc_addid(struct ipc_ids* ids, struct 
>> kern_ipc_perm* new, int size)
>>      if (ids->in_use >= size)
>>              return -ENOSPC;
>>
>> +    if (req_id >= 0)
>> +            lid = ipcid_to_idx(req_id);
>> +
>>      spin_lock_init(&new->lock);
>>      new->deleted = 0;
>>      rcu_read_lock();
>>      spin_lock(&new->lock);
>>
>> -    err = idr_get_new(&ids->ipcs_idr, new, &id);
>> +    err = idr_get_new_above(&ids->ipcs_idr, new, lid, &id);
>>      if (err) {
>>              spin_unlock(&new->lock);
>>              rcu_read_unlock();
>>              return err;
>>      }
>>
>> +    if (req_id >= 0) {
>> +            if (id != lid) {
>> +                    idr_remove(&ids->ipcs_idr, id);
>> +                    spin_unlock(&new->lock);
>> +                    rcu_read_unlock();
>> +                    return -EBUSY;
>> +            }
>> +            new->seq = req_id / SEQ_MULTIPLIER;
> 
> Should this be
>       
>       new->seq = req_id % ids->seq_max;
> 
> ?

This is how the user-visible IPC id is constructed:

        static inline int ipc_buildid(int id, int seq)
        {
                return SEQ_MULTIPLIER * seq + id;
        }

and I want to get the original 'seq' ....  (the 'id' in this function is
an in-kernel identifier)

> 
>> +    } else {
>> +            new->seq = ids->seq++;
>> +            if (ids->seq > ids->seq_max)
>> +                    ids->seq = 0;
>> +    }
>> +
>>      ids->in_use++;
>>
>>      current_euid_egid(&euid, &egid);
>>      new->cuid = new->uid = euid;
>>      new->gid = new->cgid = egid;
>>
>> -    new->seq = ids->seq++;
>> -    if(ids->seq > ids->seq_max)
>> -            ids->seq = 0;
>> -
> 
_______________________________________________
Containers mailing list
contain...@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Devel mailing list
Devel@openvz.org
https://openvz.org/mailman/listinfo/devel

Reply via email to