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 03/12] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser
Date: Mon, 4 Mar 2024 16:20:37 +0800 [thread overview]
Message-ID: <20240304082046.64977-4-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/nr_dev.c | 2 +-
net/netrom/nr_out.c | 2 +-
net/netrom/nr_subr.c | 5 +++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
index 3aaac4a22b38..2c34389c3ce6 100644
--- a/net/netrom/nr_dev.c
+++ b/net/netrom/nr_dev.c
@@ -81,7 +81,7 @@ static int nr_header(struct sk_buff *skb, struct net_device *dev,
buff[6] |= AX25_SSSID_SPARE;
buff += AX25_ADDR_LEN;
- *buff++ = sysctl_netrom_network_ttl_initialiser;
+ *buff++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser);
*buff++ = NR_PROTO_IP;
*buff++ = NR_PROTO_IP;
diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index 44929657f5b7..5e531394a724 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -204,7 +204,7 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff *skb)
dptr[6] |= AX25_SSSID_SPARE;
dptr += AX25_ADDR_LEN;
- *dptr++ = sysctl_netrom_network_ttl_initialiser;
+ *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser);
if (!nr_route_frame(skb, NULL)) {
kfree_skb(skb);
diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c
index e2d2af924cff..c3bbd5880850 100644
--- a/net/netrom/nr_subr.c
+++ b/net/netrom/nr_subr.c
@@ -182,7 +182,8 @@ void nr_write_internal(struct sock *sk, int frametype)
*dptr++ = nr->my_id;
*dptr++ = frametype;
*dptr++ = nr->window;
- if (nr->bpqext) *dptr++ = sysctl_netrom_network_ttl_initialiser;
+ if (nr->bpqext)
+ *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser);
break;
case NR_DISCREQ:
@@ -236,7 +237,7 @@ void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags)
dptr[6] |= AX25_SSSID_SPARE;
dptr += AX25_ADDR_LEN;
- *dptr++ = sysctl_netrom_network_ttl_initialiser;
+ *dptr++ = READ_ONCE(sysctl_netrom_network_ttl_initialiser);
if (mine) {
*dptr++ = 0;
--
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 ` Jason Xing [this message]
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 ` [PATCH net 12/12] netrom: Fix data-races around sysctl_net_busy_read Jason Xing
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-4-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).