summaryrefslogtreecommitdiff
path: root/net/unix
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2024-06-04 19:52:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-06-21 15:38:31 +0300
commit6fdc1152afaef6845bd38ec50f512a02d187f5f0 (patch)
tree7c7555ecb067883848463e87709c957d90702c08 /net/unix
parentb82c97a79b8eadcaeab630a0206ea58654854232 (diff)
downloadlinux-6fdc1152afaef6845bd38ec50f512a02d187f5f0.tar.xz
af_unix: Annotate data-race of sk->sk_state in unix_accept().
[ Upstream commit 1b536948e805aab61a48c5aa5db10c9afee880bd ] Once sk->sk_state is changed to TCP_LISTEN, it never changes. unix_accept() takes the advantage and reads sk->sk_state without holding unix_state_lock(). Let's use READ_ONCE() there. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/unix')
-rw-r--r--net/unix/af_unix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e6395647558a..bfda07178837 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1710,7 +1710,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags,
goto out;
err = -EINVAL;
- if (sk->sk_state != TCP_LISTEN)
+ if (READ_ONCE(sk->sk_state) != TCP_LISTEN)
goto out;
/* If socket state is TCP_LISTEN it cannot change (for now...),