Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Check the correct namespace when spoofing pid over SCM_RIGHTS

This is a security bug.

The follow-up will fix nsproxy to discourage this type of issue from
happening again.

Cc: stable@vger.kernel.org
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andy Lutomirski and committed by
David S. Miller
d661684c dd5746bf

+1 -1
+1 -1
net/core/scm.c
··· 54 54 return -EINVAL; 55 55 56 56 if ((creds->pid == task_tgid_vnr(current) || 57 - ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) && 57 + ns_capable(task_active_pid_ns(current)->user_ns, CAP_SYS_ADMIN)) && 58 58 ((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) || 59 59 uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) && 60 60 ((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||