Patch "af_unix: Use skb_queue_empty_lockless() in unix_release_sock()." has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    af_unix: Use skb_queue_empty_lockless() in unix_release_sock().

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     af_unix-use-skb_queue_empty_lockless-in-unix_release.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0d596d22aae72b7ca666d21a079b8f63449f0407
Author: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
Date:   Tue Jun 4 09:52:39 2024 -0700

    af_unix: Use skb_queue_empty_lockless() in unix_release_sock().
    
    [ Upstream commit 83690b82d228b3570565ebd0b41873933238b97f ]
    
    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: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 85b1c0d7c287a..12099b06d7e88 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -570,7 +570,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
 			unix_state_lock(skpair);
 			/* No more writes */
 			WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
-			if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
+			if (!skb_queue_empty_lockless(&sk->sk_receive_queue) || embrion)
 				WRITE_ONCE(skpair->sk_err, ECONNRESET);
 			unix_state_unlock(skpair);
 			skpair->sk_state_change(skpair);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux