netrom: Fix all the data-races around sysctls
Subsystems (2)
cover netrom: Fix all the data-races around sysctls
From: Jason Xing <[email protected]>
As the title said, in this patchset I fix the data-race issues because the writer and the reader can manipulate the same value concurrently.
Jason Xing (12):
netrom: Fix a data-race around sysctl_netrom_default_path_quality
netrom: Fix a data-race around
sysctl_netrom_obsolescence_count_initialiser
netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser
netrom: Fix a data-race around sysctl_netrom_transport_timeout
netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries
netrom: Fix a data-race around
sysctl_netrom_transport_acknowledge_delay
netrom: Fix a data-race around sysctl_netrom_transport_busy_delay
netrom: Fix a data-race around
sysctl_netrom_transport_requested_window_size
netrom: Fix a data-race around
sysctl_netrom_transport_no_activity_timeout
netrom: Fix a data-race around sysctl_netrom_routing_control
netrom: Fix a data-race around sysctl_netrom_link_fails_count
netrom: Fix data-races around sysctl_net_busy_read
net/netrom/af_netrom.c | 14 +++++++------- net/netrom/nr_dev.c | 2 +- net/netrom/nr_in.c | 6 +++--- net/netrom/nr_out.c | 2 +- net/netrom/nr_route.c | 8 ++++---- net/netrom/nr_subr.c | 5 +++-- 6 files changed, 19 insertions(+), 18 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/12 netrom: Fix a data-race around sysctl_netrom_default_path_quality
From: Jason Xing <[email protected]>
We need to protect the reader reading sysctl_netrom_default_path_quality because the value can be changed concurrently.
--- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/nr_route.c +1 -1
@@ -153,7 +153,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic, nr_neigh->digipeat =NULL ; nr_neigh->ax25 =NULL ; nr_neigh->dev = dev; - nr_neigh->quality = sysctl_netrom_default_path_quality; + nr_neigh->quality =READ_ONCE (sysctl_netrom_default_path_quality); nr_neigh->locked =0 ; nr_neigh->count =0 ; nr_neigh->number = nr_neigh_no++;
Signature · 1 line
2.37.3
PATCH 2/12 netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/nr_route.c +1 -1
@@ -766,7 +766,7 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)if (ax25 !=NULL ) { ret =nr_add_node (nr_src,"" , &ax25->dest_addr, ax25->digipeat, ax25->ax25_dev->dev,0 , - sysctl_netrom_obsolescence_count_initialiser); +READ_ONCE (sysctl_netrom_obsolescence_count_initialiser));if (ret)return ret; }
Signature · 1 line
2.37.3
PATCH 3/12 netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- 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(-)
net/netrom/nr_dev.c +1 -1
@@ -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 ;
net/netrom/nr_out.c +1 -1
@@ -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);
net/netrom/nr_subr.c +3 -2
@@ -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 ;
Signature · 1 line
2.37.3
PATCH 4/12 netrom: Fix a data-race around sysctl_netrom_transport_timeout
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -453,7 +453,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol,nr_init_timers (sk); nr->t1 = -msecs_to_jiffies (sysctl_netrom_transport_timeout); +msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_timeout)); nr->t2 =msecs_to_jiffies (sysctl_netrom_transport_acknowledge_delay); nr->n2 =
Signature · 1 line
2.37.3
PATCH 5/12 netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -457,7 +457,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol, nr->t2 =msecs_to_jiffies (sysctl_netrom_transport_acknowledge_delay); nr->n2 = -msecs_to_jiffies (sysctl_netrom_transport_maximum_tries); +msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_maximum_tries)); nr->t4 =msecs_to_jiffies (sysctl_netrom_transport_busy_delay); nr->idle =
Signature · 1 line
2.37.3
PATCH 6/12 netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -455,7 +455,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol, nr->t1 =msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_timeout)); nr->t2 = -msecs_to_jiffies (sysctl_netrom_transport_acknowledge_delay); +msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_acknowledge_delay)); nr->n2 =msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_maximum_tries)); nr->t4 =
Signature · 1 line
2.37.3
PATCH 7/12 netrom: Fix a data-race around sysctl_netrom_transport_busy_delay
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -459,7 +459,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol, nr->n2 =msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_maximum_tries)); nr->t4 = -msecs_to_jiffies (sysctl_netrom_transport_busy_delay); +msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_busy_delay)); nr->idle =msecs_to_jiffies (sysctl_netrom_transport_no_activity_timeout); nr->window = sysctl_netrom_transport_requested_window_size;
Signature · 1 line
2.37.3
PATCH 8/12 netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -462,7 +462,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol,msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_busy_delay)); nr->idle =msecs_to_jiffies (sysctl_netrom_transport_no_activity_timeout); - nr->window = sysctl_netrom_transport_requested_window_size; + nr->window =READ_ONCE (sysctl_netrom_transport_requested_window_size); nr->bpqext =1 ; nr->state =NR_STATE_0 ;
Signature · 1 line
2.37.3
PATCH 9/12 netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/af_netrom.c +1 -1
@@ -461,7 +461,7 @@ static int nr_create(struct net *net, struct socket *sock, int protocol, nr->t4 =msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_busy_delay)); nr->idle = -msecs_to_jiffies (sysctl_netrom_transport_no_activity_timeout); +msecs_to_jiffies (READ_ONCE (sysctl_netrom_transport_no_activity_timeout)); nr->window =READ_ONCE (sysctl_netrom_transport_requested_window_size); nr->bpqext =1 ;
Signature · 1 line
2.37.3
PATCH 10/12 netrom: Fix a data-race around sysctl_netrom_routing_control
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/nr_route.c +1 -1
@@ -780,7 +780,7 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25)return ret; } -if (!sysctl_netrom_routing_control && ax25 !=NULL ) +if (!READ_ONCE (sysctl_netrom_routing_control) && ax25 !=NULL )return 0 ;/* Its Time-To-Live has expired */
Signature · 1 line
2.37.3
PATCH 11/12 netrom: Fix a data-race around sysctl_netrom_link_fails_count
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netrom/nr_route.c +1 -1
@@ -728,7 +728,7 @@ void nr_link_failed(ax25_cb *ax25, int reason) nr_neigh->ax25 =NULL ;ax25_cb_put (ax25); -if (++nr_neigh->failed < sysctl_netrom_link_fails_count) { +if (++nr_neigh->failed <READ_ONCE (sysctl_netrom_link_fails_count)) {nr_neigh_put (nr_neigh);return ; }
Signature · 1 line
2.37.3
PATCH 12/12 netrom: Fix data-races around sysctl_net_busy_read
In reply to Jason XingFrom: Jason Xing <[email protected]>
We need to protect the reader reading the sysctl value because the value can be changed concurrently.
--- net/netrom/af_netrom.c | 2 +- net/netrom/nr_in.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
net/netrom/af_netrom.c +1 -1
@@ -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 );
net/netrom/nr_in.c +3 -3
@@ -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 frametypebreak ;case NR_RESET : -if (sysctl_netrom_reset_circuit) +if (READ_ONCE (sysctl_netrom_reset_circuit))nr_disconnect (sk,ECONNRESET );break ;
Signature · 1 line
2.37.3
Paolo Abeni
maintainerHi,
Quoted 2 lines · Jason Xing
As the title said, in this patchset I fix the data-race issues because the writer and the reader can manipulate the same value concurrently.
I hope this is not a one-shot effort. I think there is quite a bit room for improvement in the x25/netrom land, e.g. starting from selftests, if you have time and will:)
The patches LGTM, I'm applying them.
Cheers,
Paolo
Quoted 10 lines · Paolo Abeni
Hi,
Quoted 2 lines · Jason Xing
As the title said, in this patchset I fix the data-race issues because the writer and the reader can manipulate the same value concurrently.
I hope this is not a one-shot effort. I think there is quite a bit room for improvement in the x25/netrom land, e.g. starting from selftests, if you have time and will:)
Yes, I'm trying to make time to learn it after work, like fixing issues that syzbot reports, since Ralf seems inactive in recent years. I hope I can take it...
Quoted 2 lines
The patches LGTM, I'm applying them.
Thanks!
Quoted 5 lines
Cheers,
Paolo
This series was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 23 lines · On Mon, 4 Mar 2024 16:20:34 +0800 you wrote:
From: Jason Xing <[email protected]>
As the title said, in this patchset I fix the data-race issues because the writer and the reader can manipulate the same value concurrently.
Jason Xing (12):
netrom: Fix a data-race aroundsysctl_netrom_default_path_quality
netrom: Fix a data-race around
sysctl_netrom_obsolescence_count_initialiser
netrom: Fix data-races aroundsysctl_netrom_network_ttl_initialiser
netrom: Fix a data-race aroundsysctl_netrom_transport_timeout
netrom: Fix a data-race aroundsysctl_netrom_transport_maximum_tries
netrom: Fix a data-race around
sysctl_netrom_transport_acknowledge_delay
netrom: Fix a data-race aroundsysctl_netrom_transport_busy_delay
netrom: Fix a data-race around
sysctl_netrom_transport_requested_window_size
netrom: Fix a data-race around
sysctl_netrom_transport_no_activity_timeout
netrom: Fix a data-race aroundsysctl_netrom_routing_control
netrom: Fix a data-race aroundsysctl_netrom_link_fails_count
netrom: Fix data-races aroundsysctl_net_busy_read
Quoted 1 line
[...]
Here is the summary with links:
- [net,01/12] netrom: Fix a data-race around sysctl_netrom_default_path_quality
https://git.kernel.org/netdev/net/c/958d6145a6d9 - [net,02/12] netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser https://git.kernel.org/netdev/net/c/cfd9f4a740f7 - [net,03/12] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser https://git.kernel.org/netdev/net/c/119cae5ea3f9 - [net,04/12] netrom: Fix a data-race around sysctl_netrom_transport_timeout https://git.kernel.org/netdev/net/c/60a7a152abd4 - [net,05/12] netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries https://git.kernel.org/netdev/net/c/e799299aafed - [net,06/12] netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay https://git.kernel.org/netdev/net/c/806f462ba902 - [net,07/12] netrom: Fix a data-race around sysctl_netrom_transport_busy_delay https://git.kernel.org/netdev/net/c/43547d869943 - [net,08/12] netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size https://git.kernel.org/netdev/net/c/a2e706841488 - [net,09/12] netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout https://git.kernel.org/netdev/net/c/f99b494b4043 - [net,10/12] netrom: Fix a data-race around sysctl_netrom_routing_control https://git.kernel.org/netdev/net/c/b5dffcb8f71b - [net,11/12] netrom: Fix a data-race around sysctl_netrom_link_fails_count https://git.kernel.org/netdev/net/c/bc76645ebdd0 - [net,12/12] netrom: Fix data-races around sysctl_net_busy_read https://git.kernel.org/netdev/net/c/d380ce70058a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html