net: annotate races around sk->sk_uid
authorEric Dumazet <edumazet@google.com>
Fri, 20 Jun 2025 13:30:00 +0000 (13:30 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 24 Jun 2025 00:04:03 +0000 (17:04 -0700)
commite84a4927a404f369c842c19de93b216627fcc690
tree901784e2f1bbcbcfbc36eff81b0d685abd7140e6
parentb630c781bcf6ff87657146661816d0d30a902139
net: annotate races around sk->sk_uid

sk->sk_uid can be read while another thread changes its
value in sockfs_setattr().

Add sk_uid(const struct sock *sk) helper to factorize the needed
READ_ONCE() annotations, and add corresponding WRITE_ONCE()
where needed.

Fixes: 86741ec25462 ("net: core: Add a UID field to struct sock.")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Reviewed-by: Maciej Żenczykowski <maze@google.com>
Link: https://patch.msgid.link/20250620133001.4090592-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
20 files changed:
include/net/route.h
include/net/sock.h
net/ipv4/inet_connection_sock.c
net/ipv4/ping.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/udp.c
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ping.c
net/ipv6/raw.c
net/ipv6/route.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/l2tp/l2tp_ip6.c
net/mptcp/protocol.c
net/socket.c