Re: [PATCH 24/43] userns: Convert ptrace, kill, set_priority permission checks to work with kuids and kgids

Eric W. Biederman
2012-04-20T23:47:03Z

"Serge E. Hallyn" <serge@hallyn.com> writes:

> Quoting Eric W. Beiderman (ebiederm@xmission.com):
>> From: Eric W. Biederman <ebiederm@xmission.com>
>>
>> Update the permission checks to use the new uid_eq and gid_eq helpers
>> and remove the now unnecessary user_ns equality comparison.
>>
>> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
>> ---

>> @@ -1389,10 +1388,8 @@ static int kill_as_cred_perm(const struct cred *cred,
>> struct task_struct *target)
>> {
>> const struct cred *pcred = __task_cred(target);
>> - if (cred->user_ns != pcred->user_ns)
>> - return 0;
>> - if (cred->euid != pcred->suid && cred->euid != pcred->uid &&
>> - cred->uid != pcred->suid && cred->uid != pcred->uid)
>> + if (uid_eq(cred->euid, pcred->suid) && uid_eq(cred->euid, pcred->uid) &&
>
> These should be !uid_eq() right?
>> + uid_eq(cred->uid, pcred->suid) && uid_eq(cred->uid,
>pcred->uid))

Yes.

Thank you for catching this. This kind of mistake is unfortunately much
to easy to make.

Eric