net: Check the correct namespace when spoofing pid over SCM_RIGHTS
authorAndy Lutomirski <luto@amacapital.net>
Thu, 22 Aug 2013 18:39:15 +0000 (11:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Aug 2013 17:52:52 +0000 (13:52 -0400)
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>
net/core/scm.c

index 03795d0147f2995e09495c98dcf3c94cb3d5511f..b4da80b1cc07d28eafec50a6185d6d2a2ece61af 100644 (file)
@@ -54,7 +54,7 @@ static __inline__ int scm_check_creds(struct ucred *creds)
                return -EINVAL;
 
        if ((creds->pid == task_tgid_vnr(current) ||
-            ns_capable(current->nsproxy->pid_ns->user_ns, CAP_SYS_ADMIN)) &&
+            ns_capable(task_active_pid_ns(current)->user_ns, CAP_SYS_ADMIN)) &&
            ((uid_eq(uid, cred->uid)   || uid_eq(uid, cred->euid) ||
              uid_eq(uid, cred->suid)) || nsown_capable(CAP_SETUID)) &&
            ((gid_eq(gid, cred->gid)   || gid_eq(gid, cred->egid) ||