Skip to content

Commit 9caf13f

Browse files
q2venSasha Levin
authored andcommitted
af_unix: Use skb_queue_empty_lockless() in unix_release_sock().
[ Upstream commit 83690b8 ] If the socket type is SOCK_STREAM or SOCK_SEQPACKET, unix_release_sock() checks the length of the peer socket's recvq under unix_state_lock(). However, unix_stream_read_generic() calls skb_unlink() after releasing the lock. Also, for SOCK_SEQPACKET, __skb_try_recv_datagram() unlinks skb without unix_state_lock(). Thues, unix_state_lock() does not protect qlen. Let's use skb_queue_empty_lockless() in unix_release_sock(). Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 32accd7 commit 9caf13f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/unix/af_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
619619
unix_state_lock(skpair);
620620
/* No more writes */
621621
WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
622-
if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
622+
if (!skb_queue_empty_lockless(&sk->sk_receive_queue) || embrion)
623623
WRITE_ONCE(skpair->sk_err, ECONNRESET);
624624
unix_state_unlock(skpair);
625625
skpair->sk_state_change(skpair);

0 commit comments

Comments
 (0)