diff options
author | Eric Dumazet <edumazet@google.com> | 2023-07-20 00:28:51 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-27 09:50:48 +0300 |
commit | d27a1aa37e327e34fa7b13dacb314699df1fa890 (patch) | |
tree | 91bdb5b51970876f31fde76383897e10c2df65be /net | |
parent | 161b069389dddc2433d6e591d4877cca60d8bdcf (diff) | |
download | linux-d27a1aa37e327e34fa7b13dacb314699df1fa890.tar.xz |
tcp: annotate data-races around tp->keepalive_probes
[ Upstream commit 6e5e1de616bf5f3df1769abc9292191dfad9110a ]
do_tcp_getsockopt() reads tp->keepalive_probes 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-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index d19cfeb78392..7d75928ea0f9 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3463,7 +3463,8 @@ int tcp_sock_set_keepcnt(struct sock *sk, int val) return -EINVAL; lock_sock(sk); - tcp_sk(sk)->keepalive_probes = val; + /* Paired with READ_ONCE() in keepalive_probes() */ + WRITE_ONCE(tcp_sk(sk)->keepalive_probes, val); release_sock(sk); return 0; } @@ -3671,7 +3672,7 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname, if (val < 1 || val > MAX_TCP_KEEPCNT) err = -EINVAL; else - tp->keepalive_probes = val; + WRITE_ONCE(tp->keepalive_probes, val); break; case TCP_SYNCNT: if (val < 1 || val > MAX_TCP_SYNCNT) |