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

scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids.

Don't allow spoofing pids over unix domain sockets in the corner
cases where a user has created a user namespace but has not yet
created a pid namespace.

Cc: stable@vger.kernel.org
Reported-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+3 -1
+3 -1
net/core/scm.c
··· 24 24 #include <linux/interrupt.h> 25 25 #include <linux/netdevice.h> 26 26 #include <linux/security.h> 27 + #include <linux/pid_namespace.h> 27 28 #include <linux/pid.h> 28 29 #include <linux/nsproxy.h> 29 30 #include <linux/slab.h> ··· 53 52 if (!uid_valid(uid) || !gid_valid(gid)) 54 53 return -EINVAL; 55 54 56 - if ((creds->pid == task_tgid_vnr(current) || nsown_capable(CAP_SYS_ADMIN)) && 55 + if ((creds->pid == task_tgid_vnr(current) || 56 + ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) && 57 57 ((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) || 58 58 uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) && 59 59 ((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||