Skip to content

Commit

Permalink
af_unix: Fix a data-race in unix_dgram_peer_wake_me().
Browse files Browse the repository at this point in the history
[ Upstream commit 662a809 ]

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: 7d26727 ("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>
  • Loading branch information
q2ven authored and gregkh committed Jun 14, 2022
1 parent be9581f commit c618485
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,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)
Expand Down

0 comments on commit c618485

Please sign in to comment.