diff options
author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2022-07-12 02:15:21 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-07-13 13:56:49 +0200 |
commit | 6f605b57f3782114e330e108ce1903ede22ec675 (patch) | |
tree | 762f1a37b0bd207f332e9dd4ff310a8319da0702 /net/ipv4/inet_timewait_sock.c | |
parent | sysctl: Fix data-races in proc_dointvec_ms_jiffies(). (diff) | |
download | linux-6f605b57f3782114e330e108ce1903ede22ec675.tar.xz linux-6f605b57f3782114e330e108ce1903ede22ec675.zip |
tcp: Fix a data-race around sysctl_max_tw_buckets.
While reading sysctl_max_tw_buckets, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_timewait_sock.c')
-rw-r--r-- | net/ipv4/inet_timewait_sock.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 0ec501845cb3..47ccc343c9fb 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -156,7 +156,8 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, { struct inet_timewait_sock *tw; - if (refcount_read(&dr->tw_refcount) - 1 >= dr->sysctl_max_tw_buckets) + if (refcount_read(&dr->tw_refcount) - 1 >= + READ_ONCE(dr->sysctl_max_tw_buckets)) return NULL; tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, |