Skip to content

Commit 01a1563

Browse files
edumazetgregkh
authored andcommitted
tcp: annotate data-races around icsk->icsk_user_timeout
[ Upstream commit 26023e9 ] This field can be read locklessly from do_tcp_getsockopt() Fixes: dca43c7 ("tcp: Add TCP_USER_TIMEOUT socket option.") Signed-off-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 918a1be commit 01a1563

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/ipv4/tcp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(tcp_sock_set_syncnt);
34063406
void tcp_sock_set_user_timeout(struct sock *sk, u32 val)
34073407
{
34083408
lock_sock(sk);
3409-
inet_csk(sk)->icsk_user_timeout = val;
3409+
WRITE_ONCE(inet_csk(sk)->icsk_user_timeout, val);
34103410
release_sock(sk);
34113411
}
34123412
EXPORT_SYMBOL(tcp_sock_set_user_timeout);
@@ -3726,7 +3726,7 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
37263726
if (val < 0)
37273727
err = -EINVAL;
37283728
else
3729-
icsk->icsk_user_timeout = val;
3729+
WRITE_ONCE(icsk->icsk_user_timeout, val);
37303730
break;
37313731

37323732
case TCP_FASTOPEN:
@@ -4243,7 +4243,7 @@ int do_tcp_getsockopt(struct sock *sk, int level,
42434243
break;
42444244

42454245
case TCP_USER_TIMEOUT:
4246-
val = icsk->icsk_user_timeout;
4246+
val = READ_ONCE(icsk->icsk_user_timeout);
42474247
break;
42484248

42494249
case TCP_FASTOPEN:

0 commit comments

Comments
 (0)