af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
Subsystems (3)
PATCH RESEND 1/1 af_unix: dont send SCM_CREDENTIAL when dest socket is NULL
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).
--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/unix/af_unix.c +2 -2
@@ -1413,8 +1413,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 (); }
-- 1.8.0
Quoted 15 lines · dingtianhong
SCM_SCREDENTIALSshould apply towrite()syscalls only either source or destination socket assertedSOCK_PASSCRED. The original implememtation inmaybe_add_credsis wrong, and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).Origionally-authored-by Karel Srot <[email protected]>Signed-off-by Ding Tianhong <[email protected]>--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/unix/af_unix.c +0
-0
net/unix/af_unix.c static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock, · line 1420
Quoted 10 lines
net/unix/af_unix.c +2
-2@@ -1413,8 +1413,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 (); }
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Mon, 25 Mar 2013 21:38:07 -0700
Quoted 20 lines · dingtianhong
Quoted 19 lines
SCM_SCREDENTIALSshould apply towrite()syscalls only either source or destination socket assertedSOCK_PASSCRED. The original implememtation inmaybe_add_credsis wrong, and breaks several LSB testcases ( i.e. /tset/LSB.os/netowkr/recvfrom/T.recvfrom).Origionally-authored-by Karel Srot <[email protected]>Signed-off-by Ding Tianhong <[email protected]>--- net/unix/af_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/unix/af_unix.c +0
-1@@ -1413,8 +1413,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 ||
Quoted 8 lines
net/unix/af_unix.c static void maybe_add_creds(struct sk_buff *skb, const struct socket *sock, · line 1420
Quoted 6 lines
net/unix/af_unix.c +2
-1- 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 (); }Acked-by Eric Dumazet <[email protected]>
Applied and queued up for -stable.