]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ip: Fix data-races around sysctl_ip_no_pmtu_disc.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 13 Jul 2022 20:51:52 +0000 (13:51 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:19:12 +0000 (17:19 +0200)
[ Upstream commit 0968d2a441bf6afb551fd99e60fa65ed67068963 ]

While reading sysctl_ip_no_pmtu_disc, 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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/af_inet.c
net/ipv4/icmp.c
net/ipv6/af_inet6.c
net/xfrm/xfrm_state.c

index e77283069c7b7e62ee0517b8d6db24719ea7c694..9d1ff3baa21352acb78112eb88baa9c4889356fa 100644 (file)
@@ -338,7 +338,7 @@ lookup_protocol:
                        inet->hdrincl = 1;
        }
 
-       if (net->ipv4.sysctl_ip_no_pmtu_disc)
+       if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
                inet->pmtudisc = IP_PMTUDISC_DONT;
        else
                inet->pmtudisc = IP_PMTUDISC_WANT;
index 0fa0da1d71f57fe3cf1626d954453d5759cbb4c2..a1aacf5e75a6ab6ddc90efee8b11a3f5d38e0f9b 100644 (file)
@@ -887,7 +887,7 @@ static bool icmp_unreach(struct sk_buff *skb)
                         * values please see
                         * Documentation/networking/ip-sysctl.rst
                         */
-                       switch (net->ipv4.sysctl_ip_no_pmtu_disc) {
+                       switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) {
                        default:
                                net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n",
                                                    &iph->daddr);
index 890a9cfc6ce2709fa667b08334d59dbd6b48fdee..d30c9d949c1b513ca0d80aaa6e3f2e461dddc104 100644 (file)
@@ -225,7 +225,7 @@ lookup_protocol:
        inet->mc_list   = NULL;
        inet->rcv_tos   = 0;
 
-       if (net->ipv4.sysctl_ip_no_pmtu_disc)
+       if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
                inet->pmtudisc = IP_PMTUDISC_DONT;
        else
                inet->pmtudisc = IP_PMTUDISC_WANT;
index 717db5ecd0bd4df5c47fab6e66e39eba305805bf..bc0bbb1571cefe61af92f1d124c9dd385648c981 100644 (file)
@@ -2587,7 +2587,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
        int err;
 
        if (family == AF_INET &&
-           xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)
+           READ_ONCE(xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc))
                x->props.flags |= XFRM_STATE_NOPMTUDISC;
 
        err = -EPROTONOSUPPORT;