]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
af_unix: Fix a data-race in unix_dgram_peer_wake_me().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Sun, 5 Jun 2022 23:23:25 +0000 (16:23 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:52:57 +0000 (10:52 +0200)
BugLink: https://bugs.launchpad.net/bugs/1982968
[ Upstream commit 662a80946ce13633ae90a55379f1346c10f0c432 ]

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: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20220605232325.11804-1-kuniyu@amazon.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/unix/af_unix.c

index 10ac93e054486d9c6fb15170e448962842848527..17ad0677dce371c2176c4f7e5569a7e0fdb08ae5 100644 (file)
@@ -446,7 +446,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)