Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14134f65 authored by dingtianhong's avatar dingtianhong Committed by David S. Miller
Browse files

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).

Origionally-authored-by: default avatarKarel Srot <ksrot@redhat.com>
Signed-off-by: default avatarDing Tianhong <dingtianhong@huawei.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 465c0a16
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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();
	}