aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2025-06-20 13:30:00 +0000
committerJakub Kicinski <kuba@kernel.org>2025-06-23 17:04:03 -0700
commite84a4927a404f369c842c19de93b216627fcc690 (patch)
tree901784e2f1bbcbcfbc36eff81b0d685abd7140e6 /include/net/route.h
parentcaif: reduce stack size, again (diff)
downloadlinux-e84a4927a404f369c842c19de93b216627fcc690.tar.gz
linux-e84a4927a404f369c842c19de93b216627fcc690.zip
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>
Diffstat (limited to 'include/net/route.h')
-rw-r--r--include/net/route.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/net/route.h b/include/net/route.h
index 8e39aa822cf9..3d3d6048ffca 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -153,7 +153,7 @@ static inline void inet_sk_init_flowi4(const struct inet_sock *inet,
ip_sock_rt_tos(sk), ip_sock_rt_scope(sk),
sk->sk_protocol, inet_sk_flowi_flags(sk), daddr,
inet->inet_saddr, inet->inet_dport,
- inet->inet_sport, sk->sk_uid);
+ inet->inet_sport, sk_uid(sk));
security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4));
}
@@ -331,7 +331,7 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst,
flowi4_init_output(fl4, oif, READ_ONCE(sk->sk_mark), ip_sock_rt_tos(sk),
ip_sock_rt_scope(sk), protocol, flow_flags, dst,
- src, dport, sport, sk->sk_uid);
+ src, dport, sport, sk_uid(sk));
}
static inline struct rtable *ip_route_connect(struct flowi4 *fl4, __be32 dst,