aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 824eaf2c3afa..5ca1631de7ef 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1340,7 +1340,6 @@ static void unix_destruct_scm(struct sk_buff *skb)
1340 struct scm_cookie scm; 1340 struct scm_cookie scm;
1341 memset(&scm, 0, sizeof(scm)); 1341 memset(&scm, 0, sizeof(scm));
1342 scm.pid = UNIXCB(skb).pid; 1342 scm.pid = UNIXCB(skb).pid;
1343 scm.cred = UNIXCB(skb).cred;
1344 if (UNIXCB(skb).fp) 1343 if (UNIXCB(skb).fp)
1345 unix_detach_fds(&scm, skb); 1344 unix_detach_fds(&scm, skb);
1346 1345
@@ -1391,8 +1390,8 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool sen
1391 int err = 0; 1390 int err = 0;
1392 1391
1393 UNIXCB(skb).pid = get_pid(scm->pid); 1392 UNIXCB(skb).pid = get_pid(scm->pid);
1394 if (scm->cred) 1393 UNIXCB(skb).uid = scm->creds.uid;
1395 UNIXCB(skb).cred = get_cred(scm->cred); 1394 UNIXCB(skb).gid = scm->creds.gid;
1396 UNIXCB(skb).fp = NULL; 1395 UNIXCB(skb).fp = NULL;
1397 if (scm->fp && send_fds) 1396 if (scm->fp && send_fds)
1398 err = unix_attach_fds(scm, skb); 1397 err = unix_attach_fds(scm, skb);
@@ -1409,13 +1408,13 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool sen
1409static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock, 1408static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
1410 const struct sock *other) 1409 const struct sock *other)
1411{ 1410{
1412 if (UNIXCB(skb).cred) 1411 if (UNIXCB(skb).pid)
1413 return; 1412 return;
1414 if (test_bit(SOCK_PASSCRED, &sock->flags) || 1413 if (test_bit(SOCK_PASSCRED, &sock->flags) ||
1415 !other->sk_socket || 1414 !other->sk_socket ||
1416 test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) { 1415 test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
1417 UNIXCB(skb).pid = get_pid(task_tgid(current)); 1416 UNIXCB(skb).pid = get_pid(task_tgid(current));
1418 UNIXCB(skb).cred = get_current_cred(); 1417 current_euid_egid(&UNIXCB(skb).uid, &UNIXCB(skb).gid);
1419 } 1418 }
1420} 1419}
1421 1420
@@ -1819,7 +1818,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1819 siocb->scm = &tmp_scm; 1818 siocb->scm = &tmp_scm;
1820 memset(&tmp_scm, 0, sizeof(tmp_scm)); 1819 memset(&tmp_scm, 0, sizeof(tmp_scm));
1821 } 1820 }
1822 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); 1821 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).uid, UNIXCB(skb).gid);
1823 unix_set_secdata(siocb->scm, skb); 1822 unix_set_secdata(siocb->scm, skb);
1824 1823
1825 if (!(flags & MSG_PEEK)) { 1824 if (!(flags & MSG_PEEK)) {
@@ -1991,11 +1990,12 @@ again:
1991 if (check_creds) { 1990 if (check_creds) {
1992 /* Never glue messages from different writers */ 1991 /* Never glue messages from different writers */
1993 if ((UNIXCB(skb).pid != siocb->scm->pid) || 1992 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
1994 (UNIXCB(skb).cred != siocb->scm->cred)) 1993 !uid_eq(UNIXCB(skb).uid, siocb->scm->creds.uid) ||
1994 !gid_eq(UNIXCB(skb).gid, siocb->scm->creds.gid))
1995 break; 1995 break;
1996 } else if (test_bit(SOCK_PASSCRED, &sock->flags)) { 1996 } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
1997 /* Copy credentials */ 1997 /* Copy credentials */
1998 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); 1998 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).uid, UNIXCB(skb).gid);
1999 check_creds = 1; 1999 check_creds = 1;
2000 } 2000 }
2001 2001