diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2010-06-13 03:32:34 +0000 |
---|---|---|
committer | AK <andi@firstfloor.org> | 2011-02-06 11:03:35 -0800 |
commit | cab9e9848b9a8283b0504a2d7c435a9f5ba026de (patch) | |
tree | 1c53e6bc3fa59adbbd6e7011d8c6a6accb3b45df /net | |
parent | 4d6d4fae2b988f48b94d93bc398fdf353463ec40 (diff) |
scm: Capture the full credentials of the scm sender.
Upstream commit 257b5358b32f17e0603b6ff57b13610b0e02348f
Start capturing not only the userspace pid, uid and gid values of the
sending process but also the struct pid and struct cred of the sending
process as well.
This is in preparation for properly supporting SCM_CREDENTIALS for
sockets that have different uid and/or pid namespaces at the different
ends.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Serge E. Hallyn <serge@hallyn.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/scm.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/core/scm.c b/net/core/scm.c index b88f6f9d0b9..681c976307b 100644 --- a/net/core/scm.c +++ b/net/core/scm.c @@ -170,6 +170,30 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) err = scm_check_creds(&p->creds); if (err) goto error; + + if (pid_vnr(p->pid) != p->creds.pid) { + struct pid *pid; + err = -ESRCH; + pid = find_get_pid(p->creds.pid); + if (!pid) + goto error; + put_pid(p->pid); + p->pid = pid; + } + + if ((p->cred->euid != p->creds.uid) || + (p->cred->egid != p->creds.gid)) { + struct cred *cred; + err = -ENOMEM; + cred = prepare_creds(); + if (!cred) + goto error; + + cred->uid = cred->euid = p->creds.uid; + cred->gid = cred->egid = p->creds.uid; + put_cred(p->cred); + p->cred = cred; + } break; default: goto error; |