]> Git Repo - linux.git/commitdiff
af_unix: Annotate data-race of sk->sk_state in unix_accept().
authorKuniyuki Iwashima <[email protected]>
Tue, 4 Jun 2024 16:52:32 +0000 (09:52 -0700)
committerPaolo Abeni <[email protected]>
Thu, 6 Jun 2024 10:57:14 +0000 (12:57 +0200)
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 <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
net/unix/af_unix.c

index 84552826530df0cd0c0fea6e74ab977fd057fc1d..4763c26ae480a1ca06b6aeb478c9713d6f2dd660 100644 (file)
@@ -1710,7 +1710,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock,
                goto out;
 
        arg->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...),
This page took 0.055366 seconds and 4 git commands to generate.