mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
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: 86741ec254 ("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>
This commit is contained in:
committed by
Jakub Kicinski
parent
b630c781bc
commit
e84a4927a4
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user