Skip to content

Commit

Permalink
af_unix: Annotate data-race of sk->sk_shutdown in sk_diag_fill().
Browse files Browse the repository at this point in the history
[ Upstream commit efaf24e ]

While dumping sockets via UNIX_DIAG, we do not hold unix_state_lock().

Let's use READ_ONCE() to read sk->sk_shutdown.

Fixes: e4e541a ("sock-diag: Report shutdown for inet and unix sockets (v2)")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
q2ven authored and Sasha Levin committed Jun 16, 2024
1 parent 927e379 commit f84d645
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/unix/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
goto out_nlmsg_trim;

if (nla_put_u8(skb, UNIX_DIAG_SHUTDOWN, sk->sk_shutdown))
if (nla_put_u8(skb, UNIX_DIAG_SHUTDOWN, READ_ONCE(sk->sk_shutdown)))
goto out_nlmsg_trim;

if ((req->udiag_show & UDIAG_SHOW_UID) &&
Expand Down

0 comments on commit f84d645

Please sign in to comment.