]> git.baikalelectronics.ru Git - kernel.git/commitdiff
icmp: Fix data-races around sysctl_icmp_echo_enable_probe.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 12 Jul 2022 00:15:23 +0000 (17:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Jul 2022 11:56:49 +0000 (12:56 +0100)
While reading sysctl_icmp_echo_enable_probe, it can be changed
concurrently.  Thus, we need to add READ_ONCE() to its readers.

Fixes: 72aea1cc9c46 ("icmp: add response to RFC 8335 PROBE messages")
Fixes: 2f400e428b52 ("ipv6: ICMPV6: add response to ICMPV6 RFC 8335 PROBE messages")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/icmp.c
net/ipv6/icmp.c

index 1df4aae310e02306200a0f09e413c19eaef6a90e..c406e324c594e13ecaad8e35f53b14671abf70d8 100644 (file)
@@ -1028,7 +1028,7 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
        u16 ident_len;
        u8 status;
 
-       if (!net->ipv4.sysctl_icmp_echo_enable_probe)
+       if (!READ_ONCE(net->ipv4.sysctl_icmp_echo_enable_probe))
                return false;
 
        /* We currently only support probing interfaces on the proxy node
index 61770220774ee09b8f780290776ec45353c75c9a..9d92d51c475779f7af72b1c4ea35d4d482874db0 100644 (file)
@@ -925,7 +925,7 @@ static int icmpv6_rcv(struct sk_buff *skb)
                break;
        case ICMPV6_EXT_ECHO_REQUEST:
                if (!net->ipv6.sysctl.icmpv6_echo_ignore_all &&
-                   net->ipv4.sysctl_icmp_echo_enable_probe)
+                   READ_ONCE(net->ipv4.sysctl_icmp_echo_enable_probe))
                        icmpv6_echo_reply(skb);
                break;