Skip to content

Commit 83690b8

Browse files
q2venPaolo Abeni
authored andcommitted
af_unix: Use skb_queue_empty_lockless() in unix_release_sock().
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 <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 45d872f commit 83690b8

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
@@ -631,7 +631,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
631631
unix_state_lock(skpair);
632632
/* No more writes */
633633
WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
634-
if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
634+
if (!skb_queue_empty_lockless(&sk->sk_receive_queue) || embrion)
635635
WRITE_ONCE(skpair->sk_err, ECONNRESET);
636636
unix_state_unlock(skpair);
637637
skpair->sk_state_change(skpair);

0 commit comments

Comments
 (0)