aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2010-06-12 23:32:34 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-16 17:55:56 -0400
commit257b5358b32f17e0603b6ff57b13610b0e02348f (patch)
tree15c4887d45eb6ccfe32f5e67b5c0009e1e8dae6c /net/core
parentb47030c71dfd6c8cd5cb6e551b6f7f7cfc96f6a6 (diff)
scm: Capture the full credentials of the scm sender.
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/scm.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/net/core/scm.c b/net/core/scm.c
index b88f6f9d0b97..681c976307b5 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)
170 err = scm_check_creds(&p->creds); 170 err = scm_check_creds(&p->creds);
171 if (err) 171 if (err)
172 goto error; 172 goto error;
173
174 if (pid_vnr(p->pid) != p->creds.pid) {
175 struct pid *pid;
176 err = -ESRCH;
177 pid = find_get_pid(p->creds.pid);
178 if (!pid)
179 goto error;
180 put_pid(p->pid);
181 p->pid = pid;
182 }
183
184 if ((p->cred->euid != p->creds.uid) ||
185 (p->cred->egid != p->creds.gid)) {
186 struct cred *cred;
187 err = -ENOMEM;
188 cred = prepare_creds();
189 if (!cred)
190 goto error;
191
192 cred->uid = cred->euid = p->creds.uid;
193 cred->gid = cred->egid = p->creds.uid;
194 put_cred(p->cred);
195 p->cred = cred;
196 }
173 break; 197 break;
174 default: 198 default:
175 goto error; 199 goto error;