summaryrefslogtreecommitdiff
path: root/net/netrom/nr_subr.c
diff options
context:
space:
mode:
authorJason Xing <kernelxing@tencent.com>2024-03-04 16:20:37 +0800
committerPaolo Abeni <pabeni@redhat.com>2024-03-07 10:36:58 +0100
commit119cae5ea3f9e35cdada8e572cc067f072fa825a (patch)
treeb2a6d4479ab2bd99f36525ee7933a241880f8d1b /net/netrom/nr_subr.c
parentcfd9f4a740f772298308b2e6070d2c744fb5cf79 (diff)
netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser
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> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/netrom/nr_subr.c')
-rw-r--r--net/netrom/nr_subr.c5
1 files changed, 3 insertions, 2 deletions
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;