From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net 02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc.
Date: Wed, 13 Jul 2022 13:51:52 -0700 [thread overview]
Message-ID: <20220713205205.15735-3-kuniyu@amazon.com> (raw)
In-Reply-To: <20220713205205.15735-1-kuniyu@amazon.com>
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>
---
net/ipv4/af_inet.c | 2 +-
net/ipv4/icmp.c | 2 +-
net/ipv6/af_inet6.c | 2 +-
net/xfrm/xfrm_state.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ac67f6b4ec70..4bc24f9e38b3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -335,7 +335,7 @@ static int inet_create(struct net *net, struct socket *sock, int 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;
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 57c4f0d87a7a..d5d745c3e345 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -881,7 +881,7 @@ static enum skb_drop_reason 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);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 70564ddccc46..6f354f8be2c5 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -226,7 +226,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
RCU_INIT_POINTER(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;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 08564e0eef20..ccfb172eb5b8 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2620,7 +2620,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;
--
2.30.2
next prev parent reply other threads:[~2022-07-13 20:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl Kuniyuki Iwashima
2022-07-13 20:51 ` Kuniyuki Iwashima [this message]
2022-07-13 20:51 ` [PATCH v1 net 03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 07/15] ip: Fix a data-race around sysctl_fwmark_reflect Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 11/15] tcp: Fix data-races around sysctl_tcp_base_mss Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval Kuniyuki Iwashima
2022-07-15 11:00 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220713205205.15735-3-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).