summaryrefslogtreecommitdiffstats
path: root/net/ipv4/syncookies.c
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2022-07-15 19:17:47 +0200
committerDavid S. Miller <davem@davemloft.net>2022-07-18 13:21:54 +0200
commitf2e383b5bb6bbc60a0b94b87b3e49a2b1aefd11e (patch)
treed086482c4486c23c9ea6ebeb523b1251872086d4 /net/ipv4/syncookies.c
parenttcp: Fix data-races around sysctl_tcp_syn(ack)?_retries. (diff)
downloadlinux-f2e383b5bb6bbc60a0b94b87b3e49a2b1aefd11e.tar.xz
linux-f2e383b5bb6bbc60a0b94b87b3e49a2b1aefd11e.zip
tcp: Fix data-races around sysctl_tcp_syncookies.
While reading sysctl_tcp_syncookies, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. 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/syncookies.c')
-rw-r--r--net/ipv4/syncookies.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index b387c4835155..9b234b42021e 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -340,7 +340,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
struct flowi4 fl4;
u32 tsoff = 0;
- if (!sock_net(sk)->ipv4.sysctl_tcp_syncookies || !th->ack || th->rst)
+ if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_syncookies) ||
+ !th->ack || th->rst)
goto out;
if (tcp_synq_no_recent_overflow(sk))