Re: [PATCH] kernel: user_namespace: always set the return parameter'new_cred' when call unshare_userns() successfully.

From: Chen Gang
Date: Wed Aug 21 2013 - 00:16:33 EST


On 08/20/2013 10:37 PM, Oleg Nesterov wrote:
> On 08/20, Serge Hallyn wrote:
>>
>> Quoting Chen Gang (gang.chen@xxxxxxxxxxx):
>>> When unshare_userns() succeed, recommend to always set the return
>>> parameter which may be used by caller.
>>>
>>> The caller has rights to call it with 'new_cred' uninitialized, if
>>> succeed, the caller can assume the 'new_cred' has been initialized.
>>
>> But the only existing caller (sys_unshare) does in fact initialize it to
>> NULL. So while this patch does no harm, is it necessary?
>
> Agreed.
>
> Plus, with this patch unshare_userns() becomes "inconsistent" compared
> to other unshare_ helpers.
>
> Oleg.
>
>
>

Hmm... for static functions, they don't need, but for extern functions,
recommend to do so.


For "unshare_ helpers", I find 3 extern functions:

unshare_files() which already set value.
unshare_userns() and unshare_nsproxy_namespaces() which not set.

In my opinion, recommend to always set the return parameter when
succeed, for the 2 left extern functions.


Thanks.
--
Chen Gang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/