Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

af_unix: Don't check SOCK_DEAD in unix_stream_read_skb().

unix_stream_read_skb() checks SOCK_DEAD only when the dequeued skb is
OOB skb.

unix_stream_read_skb() is called for a SOCK_STREAM socket in SOCKMAP
when data is sent to it.

The function is invoked via sk_psock_verdict_data_ready(), which is
set to sk->sk_data_ready().

During sendmsg(), we check if the receiver has SOCK_DEAD, so there
is no point in checking it again later in ->read_skb().

Also, unix_read_skb() for SOCK_DGRAM does not have the test either.

Let's remove the SOCK_DEAD test in unix_stream_read_skb().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250702223606.1054680-3-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
772f0104 b429a5ad

-10
-10
net/unix/af_unix.c
··· 2803 2803 if (unlikely(skb == READ_ONCE(u->oob_skb))) { 2804 2804 bool drop = false; 2805 2805 2806 - unix_state_lock(sk); 2807 - 2808 - if (sock_flag(sk, SOCK_DEAD)) { 2809 - unix_state_unlock(sk); 2810 - kfree_skb_reason(skb, SKB_DROP_REASON_SOCKET_CLOSE); 2811 - return -ECONNRESET; 2812 - } 2813 - 2814 2806 spin_lock(&sk->sk_receive_queue.lock); 2815 2807 if (likely(skb == u->oob_skb)) { 2816 2808 WRITE_ONCE(u->oob_skb, NULL); 2817 2809 drop = true; 2818 2810 } 2819 2811 spin_unlock(&sk->sk_receive_queue.lock); 2820 - 2821 - unix_state_unlock(sk); 2822 2812 2823 2813 if (drop) { 2824 2814 kfree_skb_reason(skb, SKB_DROP_REASON_UNIX_SKIP_OOB);