From: Jason Xing <kerneljasonxing@gmail.com>
To: ralf@linux-mips.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com
Cc: linux-hams@vger.kernel.org, netdev@vger.kernel.org,
kerneljasonxing@gmail.com, Jason Xing <kernelxing@tencent.com>
Subject: [PATCH net 12/12] netrom: Fix data-races around sysctl_net_busy_read
Date: Mon, 4 Mar 2024 16:20:46 +0800 [thread overview]
Message-ID: <20240304082046.64977-13-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20240304082046.64977-1-kerneljasonxing@gmail.com>
From: Jason Xing <kernelxing@tencent.com>
We need to protect the reader reading the sysctl value because the
value can be changed concurrently.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
net/netrom/af_netrom.c | 2 +-
net/netrom/nr_in.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 1671be042ffe..104a80b75477 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -954,7 +954,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
* G8PZT's Xrouter which is sending packets with command type 7
* as an extension of the protocol.
*/
- if (sysctl_netrom_reset_circuit &&
+ if (READ_ONCE(sysctl_netrom_reset_circuit) &&
(frametype != NR_RESET || flags != 0))
nr_transmit_reset(skb, 1);
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 2f084b6f69d7..97944db6b5ac 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -97,7 +97,7 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb,
break;
case NR_RESET:
- if (sysctl_netrom_reset_circuit)
+ if (READ_ONCE(sysctl_netrom_reset_circuit))
nr_disconnect(sk, ECONNRESET);
break;
@@ -128,7 +128,7 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb,
break;
case NR_RESET:
- if (sysctl_netrom_reset_circuit)
+ if (READ_ONCE(sysctl_netrom_reset_circuit))
nr_disconnect(sk, ECONNRESET);
break;
@@ -262,7 +262,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
break;
case NR_RESET:
- if (sysctl_netrom_reset_circuit)
+ if (READ_ONCE(sysctl_netrom_reset_circuit))
nr_disconnect(sk, ECONNRESET);
break;
--
2.37.3
next prev parent reply other threads:[~2024-03-04 8:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 8:20 [PATCH net 00/12] netrom: Fix all the data-races around sysctls Jason Xing
2024-03-04 8:20 ` [PATCH net 01/12] netrom: Fix a data-race around sysctl_netrom_default_path_quality Jason Xing
2024-03-04 8:20 ` [PATCH net 02/12] netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser Jason Xing
2024-03-04 8:20 ` [PATCH net 03/12] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser Jason Xing
2024-03-04 8:20 ` [PATCH net 04/12] netrom: Fix a data-race around sysctl_netrom_transport_timeout Jason Xing
2024-03-04 8:20 ` [PATCH net 05/12] netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries Jason Xing
2024-03-04 8:20 ` [PATCH net 06/12] netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay Jason Xing
2024-03-04 8:20 ` [PATCH net 07/12] netrom: Fix a data-race around sysctl_netrom_transport_busy_delay Jason Xing
2024-03-04 8:20 ` [PATCH net 08/12] netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size Jason Xing
2024-03-04 8:20 ` [PATCH net 09/12] netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout Jason Xing
2024-03-04 8:20 ` [PATCH net 10/12] netrom: Fix a data-race around sysctl_netrom_routing_control Jason Xing
2024-03-04 8:20 ` [PATCH net 11/12] netrom: Fix a data-race around sysctl_netrom_link_fails_count Jason Xing
2024-03-04 8:20 ` Jason Xing [this message]
2024-03-07 9:36 ` [PATCH net 00/12] netrom: Fix all the data-races around sysctls Paolo Abeni
2024-03-07 9:43 ` Jason Xing
2024-03-07 10:00 ` 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=20240304082046.64977-13-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-hams@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ralf@linux-mips.org \
/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).