Skip to content

Commit d380ce7

Browse files
JasonXingPaolo Abeni
authored andcommitted
netrom: Fix data-races around sysctl_net_busy_read
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>
1 parent bc76645 commit d380ce7

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

net/netrom/af_netrom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
954954
* G8PZT's Xrouter which is sending packets with command type 7
955955
* as an extension of the protocol.
956956
*/
957-
if (sysctl_netrom_reset_circuit &&
957+
if (READ_ONCE(sysctl_netrom_reset_circuit) &&
958958
(frametype != NR_RESET || flags != 0))
959959
nr_transmit_reset(skb, 1);
960960

net/netrom/nr_in.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int nr_state1_machine(struct sock *sk, struct sk_buff *skb,
9797
break;
9898

9999
case NR_RESET:
100-
if (sysctl_netrom_reset_circuit)
100+
if (READ_ONCE(sysctl_netrom_reset_circuit))
101101
nr_disconnect(sk, ECONNRESET);
102102
break;
103103

@@ -128,7 +128,7 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb,
128128
break;
129129

130130
case NR_RESET:
131-
if (sysctl_netrom_reset_circuit)
131+
if (READ_ONCE(sysctl_netrom_reset_circuit))
132132
nr_disconnect(sk, ECONNRESET);
133133
break;
134134

@@ -262,7 +262,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
262262
break;
263263

264264
case NR_RESET:
265-
if (sysctl_netrom_reset_circuit)
265+
if (READ_ONCE(sysctl_netrom_reset_circuit))
266266
nr_disconnect(sk, ECONNRESET);
267267
break;
268268

0 commit comments

Comments
 (0)