Skip to content

Commit 92f28d9

Browse files
committed
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>
1 parent a937536 commit 92f28d9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/core/scm.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/interrupt.h>
2525
#include <linux/netdevice.h>
2626
#include <linux/security.h>
27+
#include <linux/pid_namespace.h>
2728
#include <linux/pid.h>
2829
#include <linux/nsproxy.h>
2930
#include <linux/slab.h>
@@ -52,7 +53,8 @@ static __inline__ int scm_check_creds(struct ucred *creds)
5253
if (!uid_valid(uid) || !gid_valid(gid))
5354
return -EINVAL;
5455

55-
if ((creds->pid == task_tgid_vnr(current) || nsown_capable(CAP_SYS_ADMIN)) &&
56+
if ((creds->pid == task_tgid_vnr(current) ||
57+
ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) &&
5658
((uid_eq(uid, cred->uid) || uid_eq(uid, cred->euid) ||
5759
uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) &&
5860
((gid_eq(gid, cred->gid) || gid_eq(gid, cred->egid) ||

0 commit comments

Comments
 (0)