Skip to content

Commit 1b53694

Browse files
q2venPaolo Abeni
authored andcommitted
af_unix: Annotate data-race of sk->sk_state in unix_accept().
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>
1 parent a9bf9c7 commit 1b53694

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/unix/af_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,7 +1710,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock,
17101710
goto out;
17111711

17121712
arg->err = -EINVAL;
1713-
if (sk->sk_state != TCP_LISTEN)
1713+
if (READ_ONCE(sk->sk_state) != TCP_LISTEN)
17141714
goto out;
17151715

17161716
/* If socket state is TCP_LISTEN it cannot change (for now...),

0 commit comments

Comments
 (0)