Skip to content

Commit

Permalink
netrom: Fix data-races around sysctl_net_busy_read
Browse files Browse the repository at this point in the history
[ Upstream commit d380ce7 ]

We need to protect the reader reading the sysctl value because the
value can be changed concurrently.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JasonXing authored and Sasha Levin committed Mar 15, 2024
1 parent 0b8eb36 commit 16d7131
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/netrom/af_netrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions net/netrom/nr_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 16d7131

Please sign in to comment.