]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tcp: Fix a data-race around sysctl_tcp_challenge_ack_limit.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 20 Jul 2022 16:50:21 +0000 (09:50 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Aug 2022 09:59:38 +0000 (11:59 +0200)
commit a30eb41d36f05b4a53c9626157865b6f986fc89f upstream.

While reading sysctl_tcp_challenge_ack_limit, it can be changed
concurrently.  Thus, we need to add READ_ONCE() to its reader.

Fixes: dbe400804f0b ("tcp: implement RFC 5961 3.2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/tcp_input.c

index f5f50a30b30ca6365f84cd5b9a4361516d1f28e4..a8d8ff4882814d90b5402cf4ae2d2d16daf7ea21 100644 (file)
@@ -3484,7 +3484,7 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb)
        /* Then check host-wide RFC 5961 rate limit. */
        now = jiffies / HZ;
        if (now != challenge_timestamp) {
-               u32 ack_limit = net->ipv4.sysctl_tcp_challenge_ack_limit;
+               u32 ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit);
                u32 half = (ack_limit + 1) >> 1;
 
                challenge_timestamp = now;