Commit 0968d2a4 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by David S. Miller

ip: Fix data-races around sysctl_ip_no_pmtu_disc.

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

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8281b7ec
...@@ -335,7 +335,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, ...@@ -335,7 +335,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
inet->hdrincl = 1; 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; inet->pmtudisc = IP_PMTUDISC_DONT;
else else
inet->pmtudisc = IP_PMTUDISC_WANT; inet->pmtudisc = IP_PMTUDISC_WANT;
......
...@@ -881,7 +881,7 @@ static enum skb_drop_reason icmp_unreach(struct sk_buff *skb) ...@@ -881,7 +881,7 @@ static enum skb_drop_reason icmp_unreach(struct sk_buff *skb)
* values please see * values please see
* Documentation/networking/ip-sysctl.rst * Documentation/networking/ip-sysctl.rst
*/ */
switch (net->ipv4.sysctl_ip_no_pmtu_disc) { switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) {
default: default:
net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n", net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n",
&iph->daddr); &iph->daddr);
......
...@@ -226,7 +226,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol, ...@@ -226,7 +226,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
RCU_INIT_POINTER(inet->mc_list, NULL); RCU_INIT_POINTER(inet->mc_list, NULL);
inet->rcv_tos = 0; 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; inet->pmtudisc = IP_PMTUDISC_DONT;
else else
inet->pmtudisc = IP_PMTUDISC_WANT; inet->pmtudisc = IP_PMTUDISC_WANT;
......
...@@ -2620,7 +2620,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload) ...@@ -2620,7 +2620,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
int err; int err;
if (family == AF_INET && 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; x->props.flags |= XFRM_STATE_NOPMTUDISC;
err = -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment