]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
authordingtianhong <dingtianhong@huawei.com>
Mon, 25 Mar 2013 17:02:04 +0000 (17:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 Mar 2013 16:33:55 +0000 (12:33 -0400)
SCM_SCREDENTIALS should apply to write() syscalls only either source or destination
socket asserted SOCK_PASSCRED. The original implememtation in maybe_add_creds is wrong,
and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).

Origionally-authored-by: Karel Srot <ksrot@redhat.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c

index f153a8d6e3398e46eaecc53eb16a97c258ef8062..971282b6f6a38fd056dd65d127b85f044b7c6041 100644 (file)
@@ -1412,8 +1412,8 @@ static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock,
        if (UNIXCB(skb).cred)
                return;
        if (test_bit(SOCK_PASSCRED, &sock->flags) ||
-           !other->sk_socket ||
-           test_bit(SOCK_PASSCRED, &other->sk_socket->flags)) {
+           (other->sk_socket &&
+           test_bit(SOCK_PASSCRED, &other->sk_socket->flags))) {
                UNIXCB(skb).pid  = get_pid(task_tgid(current));
                UNIXCB(skb).cred = get_current_cred();
        }