From: Kuniyuki Iwashima Date: Sun, 5 Jun 2022 23:23:25 +0000 (-0700) Subject: af_unix: Fix a data-race in unix_dgram_peer_wake_me(). X-Git-Tag: baikal/aarch64/sdk6.1~3763^2~20 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=bd7c10adab6d800da3ed4262f453fdefaef32d6f;p=kernel.git af_unix: Fix a data-race in unix_dgram_peer_wake_me(). unix_dgram_poll() calls unix_dgram_peer_wake_me() without `other`'s lock held and check if its receive queue is full. Here we need to use unix_recvq_full_lockless() instead of unix_recvq_full(), otherwise KCSAN will report a data-race. Fixes: ebc9ffbf8a17 ("unix: avoid use-after-free in ep_remove_wait_queue") Signed-off-by: Kuniyuki Iwashima Link: https://lore.kernel.org/r/20220605232325.11804-1-kuniyu@amazon.com Signed-off-by: Paolo Abeni --- diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 654dcef7cfb38..2206e6f8902d7 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -490,7 +490,7 @@ static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) * -ECONNREFUSED. Otherwise, if we haven't queued any skbs * to other and its full, we will hang waiting for POLLOUT. */ - if (unix_recvq_full(other) && !sock_flag(other, SOCK_DEAD)) + if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) return 1; if (connected)