Re: [PATCH V3 3/5 selinux-next] selinux: sidtab_clone switch to use rwlock.
From: peter enderborg
Date: Thu May 31 2018 - 01:35:54 EST
On 05/30/2018 11:22 PM, J Freyensee wrote:
>
>> Â +int sidtab_clone(struct sidtab *s, struct sidtab *d)
>> +{
>> +ÂÂÂ int i, rc = 0;
> If s or d are NULL (see if() below), why would we want rc, the return value, to be 0? How about defaulting rc to an error value (-EINVAL)?
Oops! Thanks, will fix in next set.
>> +ÂÂÂ struct sidtab_node *cur;
>> +
>> +ÂÂÂ if (!s || !d)
>> +ÂÂÂÂÂÂÂ goto errout;
>> +
>> +ÂÂÂ read_lock(&s->lock);
>> +ÂÂÂ for (i = 0; i < SIDTAB_SIZE; i++) {
>> +ÂÂÂÂÂÂÂ cur = s->htable[i];
>> +ÂÂÂÂÂÂÂ while (cur) {
>> +ÂÂÂÂÂÂÂÂÂÂÂ if (cur->sid > SECINITSID_NUM)
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ rc =Â sidtab_insert(d, cur->sid, &cur->context);
>> +ÂÂÂÂÂÂÂÂÂÂÂ if (rc)
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ goto out;
>> +ÂÂÂÂÂÂÂÂÂÂÂ cur = cur->next;
>> +ÂÂÂÂÂÂÂ }
>> +ÂÂÂ }
>> +out:
>> +ÂÂÂ read_unlock(&s->lock);
>> +errout:
>> +ÂÂÂ return rc;
>> +}
>>
> Thanks,
> Jay
>