Skip to content

Commit

Permalink
af_unix: Fix data race around sk->sk_err.
Browse files Browse the repository at this point in the history
[ Upstream commit b192812 ]

As with sk->sk_shutdown shown in the previous patch, sk->sk_err can be
read locklessly by unix_dgram_sendmsg().

Let's use READ_ONCE() for sk_err as well.

Note that the writer side is marked by commit cc04410 ("af_unix:
annotate lockless accesses to sk->sk_err").

Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
q2ven authored and gregkh committed Sep 19, 2023
1 parent d883243 commit a226df7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/core/sock.c
Expand Up @@ -2748,7 +2748,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
break;
if (READ_ONCE(sk->sk_shutdown) & SEND_SHUTDOWN)
break;
if (sk->sk_err)
if (READ_ONCE(sk->sk_err))
break;
timeo = schedule_timeout(timeo);
}
Expand Down

0 comments on commit a226df7

Please sign in to comment.