af_unix: Fix data race around sk->sk_err.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Sat, 2 Sep 2023 00:27:08 +0000 (17:27 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:28:02 +0000 (12:28 +0200)
commit2100bbf55e565c9005e4d5d2f7c333d35741073f
treeeb8919ad1b86f350bc72423293a7d355d7852506
parentce3aa88ceccdafd4286aef2cc9834b1e342218ab
af_unix: Fix data race around sk->sk_err.

[ Upstream commit b192812905e4b134f7b7994b079eb647e9d2d37e ]

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 cc04410af7de ("af_unix:
annotate lockless accesses to sk->sk_err").

Fixes: 1da177e4c3f4 ("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>
net/core/sock.c