diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
commit | da733563be5a9da26fe81d9f007262d00b846e22 (patch) | |
tree | db28291df94a2043af2123911984c5c173da4e6f /net/unix/af_unix.c | |
parent | 6ccbcf2cb41131f8d56ef0723bf3f7c1f8486076 (diff) | |
parent | dab78d7924598ea4031663dd10db814e2e324928 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ec68e1c05b85..466fbcc5cf77 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -1381,8 +1381,10 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) | |||
1381 | static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds) | 1381 | static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool send_fds) |
1382 | { | 1382 | { |
1383 | int err = 0; | 1383 | int err = 0; |
1384 | |||
1384 | UNIXCB(skb).pid = get_pid(scm->pid); | 1385 | UNIXCB(skb).pid = get_pid(scm->pid); |
1385 | UNIXCB(skb).cred = get_cred(scm->cred); | 1386 | if (scm->cred) |
1387 | UNIXCB(skb).cred = get_cred(scm->cred); | ||
1386 | UNIXCB(skb).fp = NULL; | 1388 | UNIXCB(skb).fp = NULL; |
1387 | if (scm->fp && send_fds) | 1389 | if (scm->fp && send_fds) |
1388 | err = unix_attach_fds(scm, skb); | 1390 | err = unix_attach_fds(scm, skb); |
@@ -1392,6 +1394,24 @@ static int unix_scm_to_skb(struct scm_cookie *scm, struct sk_buff *skb, bool sen | |||
1392 | } | 1394 | } |
1393 | 1395 | ||
1394 | /* | 1396 | /* |
1397 | * Some apps rely on write() giving SCM_CREDENTIALS | ||
1398 | * We include credentials if source or destination socket | ||
1399 | * asserted SOCK_PASSCRED. | ||
1400 | */ | ||
1401 | static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock, | ||
1402 | const struct sock *other) | ||
1403 | { | ||
1404 | if (UNIXCB(skb).cred) | ||
1405 | return; | ||
1406 | if (test_bit(SOCK_PASSCRED, &sock->flags) || | ||
1407 | !other->sk_socket || | ||
1408 | test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) { | ||
1409 | UNIXCB(skb).pid = get_pid(task_tgid(current)); | ||
1410 | UNIXCB(skb).cred = get_current_cred(); | ||
1411 | } | ||
1412 | } | ||
1413 | |||
1414 | /* | ||
1395 | * Send AF_UNIX data. | 1415 | * Send AF_UNIX data. |
1396 | */ | 1416 | */ |
1397 | 1417 | ||
@@ -1538,6 +1558,7 @@ restart: | |||
1538 | 1558 | ||
1539 | if (sock_flag(other, SOCK_RCVTSTAMP)) | 1559 | if (sock_flag(other, SOCK_RCVTSTAMP)) |
1540 | __net_timestamp(skb); | 1560 | __net_timestamp(skb); |
1561 | maybe_add_creds(skb, sock, other); | ||
1541 | skb_queue_tail(&other->sk_receive_queue, skb); | 1562 | skb_queue_tail(&other->sk_receive_queue, skb); |
1542 | if (max_level > unix_sk(other)->recursion_level) | 1563 | if (max_level > unix_sk(other)->recursion_level) |
1543 | unix_sk(other)->recursion_level = max_level; | 1564 | unix_sk(other)->recursion_level = max_level; |
@@ -1652,6 +1673,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
1652 | (other->sk_shutdown & RCV_SHUTDOWN)) | 1673 | (other->sk_shutdown & RCV_SHUTDOWN)) |
1653 | goto pipe_err_free; | 1674 | goto pipe_err_free; |
1654 | 1675 | ||
1676 | maybe_add_creds(skb, sock, other); | ||
1655 | skb_queue_tail(&other->sk_receive_queue, skb); | 1677 | skb_queue_tail(&other->sk_receive_queue, skb); |
1656 | if (max_level > unix_sk(other)->recursion_level) | 1678 | if (max_level > unix_sk(other)->recursion_level) |
1657 | unix_sk(other)->recursion_level = max_level; | 1679 | unix_sk(other)->recursion_level = max_level; |