summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-07-19 21:28:49 +0000
committerJakub Kicinski <kuba@kernel.org>2023-07-20 12:34:18 -0700
commit4164245c76ff906c9086758e1c3f87082a7f5ef5 (patch)
treee04906fc69cbbe4246b71ab495927a7d770b66c8 /net
parentdd23c9f1e8d5c1d2e3d29393412385ccb9c7a948 (diff)
downloadlinux-4164245c76ff906c9086758e1c3f87082a7f5ef5.tar.gz
linux-4164245c76ff906c9086758e1c3f87082a7f5ef5.tar.bz2
linux-4164245c76ff906c9086758e1c3f87082a7f5ef5.zip
tcp: annotate data-races around tp->keepalive_time
do_tcp_getsockopt() reads tp->keepalive_time while another cpu might change its value. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20230719212857.3943972-4-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 03ae6554c78d..b4f7856dfb16 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3312,7 +3312,8 @@ int tcp_sock_set_keepidle_locked(struct sock *sk, int val)
if (val < 1 || val > MAX_TCP_KEEPIDLE)
return -EINVAL;
- tp->keepalive_time = val * HZ;
+ /* Paired with WRITE_ONCE() in keepalive_time_when() */
+ WRITE_ONCE(tp->keepalive_time, val * HZ);
if (sock_flag(sk, SOCK_KEEPOPEN) &&
!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) {
u32 elapsed = keepalive_time_elapsed(tp);