diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2022-07-15 10:17:50 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-07-29 17:10:33 +0200 |
commit | f197442a0ea7fc0fa3103379d0be710664c76ba4 (patch) | |
tree | 16c6967e8b4d7626ffb7641fdf1c609bb0bd7872 /include/net/tcp.h | |
parent | 59ce170d33dd8c3c95049765ffc311584585e366 (diff) | |
download | linux-stable-f197442a0ea7fc0fa3103379d0be710664c76ba4.tar.gz linux-stable-f197442a0ea7fc0fa3103379d0be710664c76ba4.tar.bz2 linux-stable-f197442a0ea7fc0fa3103379d0be710664c76ba4.zip |
tcp: Fix data-races around some timeout sysctl knobs.
[ Upstream commit 39e24435a776e9de5c6dd188836cf2523547804b ]
While reading these sysctl knobs, they can be changed concurrently.
Thus, we need to add READ_ONCE() to their readers.
- tcp_retries1
- tcp_retries2
- tcp_orphan_retries
- tcp_fin_timeout
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 5c5807ed66ee..f92b93cf074c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1430,7 +1430,8 @@ static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) static inline int tcp_fin_time(const struct sock *sk) { - int fin_timeout = tcp_sk(sk)->linger2 ? : sock_net(sk)->ipv4.sysctl_tcp_fin_timeout; + int fin_timeout = tcp_sk(sk)->linger2 ? : + READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fin_timeout); const int rto = inet_csk(sk)->icsk_rto; if (fin_timeout < (rto << 2) - (rto >> 1)) |