sysctl: Fix data-races around ipv4_net_table (Round 4).
Subsystems (7)
cover sysctl: Fix data-races around ipv4_net_table (Round 4).
This series fixes data-races around 17 knobs after fib_multipath_use_neigh in ipv4_net_table.
tcp_fack was skipped because it's obsolete and there's no readers.
So, round 5 will start with tcp_dsack, 2 rounds left for 27 knobs.
Kuniyuki Iwashima (15):
ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh.
ipv4: Fix data-races around sysctl_fib_multipath_hash_policy.
ipv4: Fix data-races around sysctl_fib_multipath_hash_fields.
ip: Fix data-races around sysctl_ip_prot_sock.
udp: Fix a data-race around sysctl_udp_l3mdev_accept.
tcp: Fix data-races around sysctl knobs related to SYN option.
tcp: Fix a data-race around sysctl_tcp_early_retrans.
tcp: Fix data-races around sysctl_tcp_recovery.
tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts.
tcp: Fix data-races around sysctl_tcp_slow_start_after_idle.
tcp: Fix a data-race around sysctl_tcp_retrans_collapse.
tcp: Fix a data-race around sysctl_tcp_stdurg.
tcp: Fix a data-race around sysctl_tcp_rfc1337.
tcp: Fix a data-race around sysctl_tcp_abort_on_overflow.
tcp: Fix data-races around sysctl_tcp_max_reordering.
.../chelsio/inline_crypto/chtls/chtls_cm.c | 6 +++--- .../ethernet/mellanox/mlxsw/spectrum_router.c | 4 ++-- include/net/ip.h | 2 +- include/net/tcp.h | 4 ++-- include/net/udp.h | 2 +- net/core/secure_seq.c | 4 ++-- net/ipv4/fib_semantics.c | 2 +- net/ipv4/route.c | 8 ++++---- net/ipv4/syncookies.c | 6 +++--- net/ipv4/sysctl_net_ipv4.c | 6 +++--- net/ipv4/tcp_input.c | 15 ++++++++------- net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv4/tcp_output.c | 16 ++++++++-------- net/ipv4/tcp_recovery.c | 6 ++++-- net/ipv4/tcp_timer.c | 2 +- 15 files changed, 45 insertions(+), 42 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/15 ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh.
While reading sysctl_fib_multipath_use_neigh, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/fib_semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fib_semantics.c +1 -1
@@ -2216,7 +2216,7 @@ void fib_select_multipath(struct fib_result *res, int hash) }change_nexthops (fi) { -if (net->ipv4.sysctl_fib_multipath_use_neigh) { +if (READ_ONCE (net->ipv4.sysctl_fib_multipath_use_neigh)) {if (!fib_good_nh (nexthop_nh))continue ;if (!first) {
Signature · 1 line
2.30.2
PATCH 2/15 ipv4: Fix data-races around sysctl_fib_multipath_hash_policy.
In reply to Kuniyuki IwashimaWhile reading sysctl_fib_multipath_hash_policy, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
---
CC: Nikolay Aleksandrov <[email protected]>
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- net/ipv4/route.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -1
@@ -10324,7 +10324,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp,unsigned long *fields = config->fields;u32 hash_fields; -switch (net->ipv4.sysctl_fib_multipath_hash_policy) { +switch (READ_ONCE (net->ipv4.sysctl_fib_multipath_hash_policy)) {case 0 :mlxsw_sp_mp4_hash_outer_addr (config);break ;
net/ipv4/route.c +1 -1
@@ -2048,7 +2048,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,struct flow_keys hash_keys;u32 mhash =0 ; -switch (net->ipv4.sysctl_fib_multipath_hash_policy) { +switch (READ_ONCE (net->ipv4.sysctl_fib_multipath_hash_policy)) {case 0 :memset (&hash_keys,0 ,sizeof (hash_keys)); hash_keys.control.addr_type =FLOW_DISSECTOR_KEY_IPV4_ADDRS ;
Signature · 1 line
2.30.2
PATCH 3/15 ipv4: Fix data-races around sysctl_fib_multipath_hash_fields.
In reply to Kuniyuki IwashimaWhile reading sysctl_fib_multipath_hash_fields, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
---
CC: Ido Schimmel <[email protected]>
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- net/ipv4/route.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -1
@@ -10342,7 +10342,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_mp_hash_inner_l3 (config);break ;case 3 : - hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; + hash_fields =READ_ONCE (net->ipv4.sysctl_fib_multipath_hash_fields);/* Outer */ MLXSW_SP_MP_HASH_HEADER_SET (headers,IPV4_EN_NOT_TCP_NOT_UDP );MLXSW_SP_MP_HASH_HEADER_SET (headers,IPV4_EN_TCP_UDP );
net/ipv4/route.c +3 -3
@@ -1929,7 +1929,7 @@ static u32 fib_multipath_custom_hash_outer(const struct net *net,const struct sk_buff *skb, bool *p_has_inner) { - u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; + u32 hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields);struct flow_keys keys, hash_keys;if (!(hash_fields &FIB_MULTIPATH_HASH_FIELD_OUTER_MASK ))
@@ -1958,7 +1958,7 @@ static u32 fib_multipath_custom_hash_inner(const struct net *net,const struct sk_buff *skb, bool has_inner) { - u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; + u32 hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields);struct flow_keys keys, hash_keys;/* We assume the packet carries an encapsulation, but if none was
@@ -2018,7 +2018,7 @@ static u32 fib_multipath_custom_hash_skb(const struct net *net,static u32 fib_multipath_custom_hash_fl4 (const struct net *net,const struct flowi4 *fl4) { -u32 hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; +u32 hash_fields =READ_ONCE (net->ipv4.sysctl_fib_multipath_hash_fields);struct flow_keys hash_keys;if (!(hash_fields &FIB_MULTIPATH_HASH_FIELD_OUTER_MASK ))
Signature · 1 line
2.30.2
Re: [PATCH v1 net 03/15] ipv4: Fix data-races around sysctl_fib_multipath_hash_fields.
Quoted 7 lines · Kuniyuki Iwashima
While reading
sysctl_fib_multipath_hash_fields, it can be changed concurrently. Thus, we need to addREAD_ONCE()to its readers.Fixes ce5c9c20d364 ("ipv4: Add a sysctl to control multipath hash fields")Signed-off-by Kuniyuki Iwashima <[email protected]>---
CC: Ido Schimmel <[email protected]>
PATCH 4/15 ip: Fix data-races around sysctl_ip_prot_sock.
In reply to Kuniyuki Iwashimasysctl_ip_prot_sock is accessed concurrently, and there is always a chance of data-race. So, all readers and writers need some basic protection to avoid load/store-tearing.
---
CC: Krister Johansen <[email protected]>
--- include/net/ip.h | 2 +- net/ipv4/sysctl_net_ipv4.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
include/net/ip.h +1 -1
@@ -357,7 +357,7 @@ static inline bool sysctl_dev_name_is_allowed(const char *name)static inline bool inet_port_requires_bind_service (struct net *net,unsigned short port) { -return port < net->ipv4.sysctl_ip_prot_sock; +return port <READ_ONCE (net->ipv4.sysctl_ip_prot_sock); }#else
net/ipv4/sysctl_net_ipv4.c +3 -3
@@ -84,7 +84,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,* port limit. */ if ((range[1 ] < range[0 ]) || - (range[0 ] < net->ipv4.sysctl_ip_prot_sock)) + (range[0 ] <READ_ONCE (net->ipv4.sysctl_ip_prot_sock))) ret = -EINVAL ;else set_local_port_range (net, range);
@@ -110,7 +110,7 @@ static int ipv4_privileged_ports(struct ctl_table *table, int write, .extra2 = &ip_privileged_port_max, }; - pports = net->ipv4.sysctl_ip_prot_sock; + pports =READ_ONCE (net->ipv4.sysctl_ip_prot_sock); ret =proc_dointvec_minmax (&tmp, write, buffer, lenp, ppos);
@@ -122,7 +122,7 @@ static int ipv4_privileged_ports(struct ctl_table *table, int write,if (range[0 ] < pports) ret = -EINVAL ;else - net->ipv4.sysctl_ip_prot_sock = pports; +WRITE_ONCE (net->ipv4.sysctl_ip_prot_sock, pports); }return ret;
Signature · 1 line
2.30.2
PATCH 5/15 udp: Fix a data-race around sysctl_udp_l3mdev_accept.
In reply to Kuniyuki IwashimaWhile reading sysctl_udp_l3mdev_accept, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
---
CC: Robert Shearman <[email protected]>
--- include/net/udp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/udp.h +1 -1
@@ -238,7 +238,7 @@ static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if, int dif, int sdif) {#if IS_ENABLED (CONFIG_NET_L3_MASTER_DEV ) -return inet_bound_dev_eq (!!net->ipv4.sysctl_udp_l3mdev_accept, +return inet_bound_dev_eq (!!READ_ONCE (net->ipv4.sysctl_udp_l3mdev_accept), bound_dev_if, dif, sdif);#else return inet_bound_dev_eq (true, bound_dev_if, dif, sdif);
Signature · 1 line
2.30.2
PATCH 6/15 tcp: Fix data-races around sysctl knobs related to SYN option.
In reply to Kuniyuki IwashimaWhile reading these knobs, they can be changed concurrently. Thus, we need to add READ_ONCE() to their readers.
- tcp_sack
- tcp_window_scaling
- tcp_timestamps
--- .../ethernet/chelsio/inline_crypto/chtls/chtls_cm.c | 6 +++--- net/core/secure_seq.c | 4 ++-- net/ipv4/syncookies.c | 6 +++--- net/ipv4/tcp_input.c | 6 +++--- net/ipv4/tcp_output.c | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c +3 -3
@@ -1236,8 +1236,8 @@ static struct sock *chtls_recv_sock(struct sock *lsk, csk->sndbuf = newsk->sk_sndbuf; csk->smac_idx = ((struct port_info *)netdev_priv (ndev))->smt_idx;RCV_WSCALE (tp) =select_rcv_wscale (tcp_full_space (newsk), -sock_net (newsk)-> - ipv4.sysctl_tcp_window_scaling, +READ_ONCE (sock_net (newsk)-> + ipv4.sysctl_tcp_window_scaling), tp->window_clamp);neigh_release (n);inet_inherit_port (&tcp_hashinfo, lsk, newsk);
@@ -1384,7 +1384,7 @@ static void chtls_pass_accept_request(struct sock *sk,#endif }if (req->tcpopt.wsf <=14 && -sock_net (sk)->ipv4.sysctl_tcp_window_scaling) { +READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_window_scaling)) {inet_rsk (oreq)->wscale_ok =1 ;inet_rsk (oreq)->snd_wscale = req->tcpopt.wsf; }
net/core/secure_seq.c +2 -2
@@ -64,7 +64,7 @@ u32 secure_tcpv6_ts_off(const struct net *net, .daddr = *(struct in6_addr *)daddr, }; -if (net->ipv4.sysctl_tcp_timestamps !=1 ) +if (READ_ONCE (net->ipv4.sysctl_tcp_timestamps) !=1 )return 0 ;ts_secret_init ();
@@ -120,7 +120,7 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral);#ifdef CONFIG_INET u32 secure_tcp_ts_off (const struct net *net,__be32 saddr,__be32 daddr) { -if (net->ipv4.sysctl_tcp_timestamps !=1 ) +if (READ_ONCE (net->ipv4.sysctl_tcp_timestamps) !=1 )return 0 ;ts_secret_init ();
net/ipv4/syncookies.c +3 -3
@@ -247,12 +247,12 @@ bool cookie_timestamp_decode(const struct net *net,return true; } -if (!net->ipv4.sysctl_tcp_timestamps) +if (!READ_ONCE (net->ipv4.sysctl_tcp_timestamps))return false; tcp_opt->sack_ok = (options &TS_OPT_SACK ) ?TCP_SACK_SEEN :0 ; -if (tcp_opt->sack_ok && !net->ipv4.sysctl_tcp_sack) +if (tcp_opt->sack_ok && !READ_ONCE (net->ipv4.sysctl_tcp_sack))return false;if ((options &TS_OPT_WSCALE_MASK ) ==TS_OPT_WSCALE_MASK )
@@ -261,7 +261,7 @@ bool cookie_timestamp_decode(const struct net *net, tcp_opt->wscale_ok =1 ; tcp_opt->snd_wscale = options &TS_OPT_WSCALE_MASK ; -return net->ipv4.sysctl_tcp_window_scaling !=0 ; +return READ_ONCE (net->ipv4.sysctl_tcp_window_scaling) !=0 ; }EXPORT_SYMBOL (cookie_timestamp_decode);
net/ipv4/tcp_input.c +3 -3
@@ -4060,7 +4060,7 @@ void tcp_parse_options(const struct net *net,break ;case TCPOPT_WINDOW :if (opsize ==TCPOLEN_WINDOW && th->syn && - !estab && net->ipv4.sysctl_tcp_window_scaling) { + !estab &&READ_ONCE (net->ipv4.sysctl_tcp_window_scaling)) {__u8 snd_wscale = *(__u8 *)ptr; opt_rx->wscale_ok =1 ;if (snd_wscale >TCP_MAX_WSCALE ) {
@@ -4076,7 +4076,7 @@ void tcp_parse_options(const struct net *net,case TCPOPT_TIMESTAMP :if ((opsize ==TCPOLEN_TIMESTAMP ) && ((estab && opt_rx->tstamp_ok) || - (!estab && net->ipv4.sysctl_tcp_timestamps))) { + (!estab &&READ_ONCE (net->ipv4.sysctl_tcp_timestamps)))) { opt_rx->saw_tstamp =1 ; opt_rx->rcv_tsval =get_unaligned_be32 (ptr); opt_rx->rcv_tsecr =get_unaligned_be32 (ptr +4 );
@@ -4084,7 +4084,7 @@ void tcp_parse_options(const struct net *net,break ;case TCPOPT_SACK_PERM :if (opsize ==TCPOLEN_SACK_PERM && th->syn && - !estab && net->ipv4.sysctl_tcp_sack) { + !estab &&READ_ONCE (net->ipv4.sysctl_tcp_sack)) { opt_rx->sack_ok =TCP_SACK_SEEN ;tcp_sack_reset (opt_rx); }
net/ipv4/tcp_output.c +5 -5
@@ -791,18 +791,18 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb, opts->mss =tcp_advertise_mss (sk); remaining -=TCPOLEN_MSS_ALIGNED ; -if (likely (sock_net (sk)->ipv4.sysctl_tcp_timestamps && !*md5)) { +if (likely (READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_timestamps) && !*md5)) { opts->options |=OPTION_TS ; opts->tsval =tcp_skb_timestamp (skb) + tp->tsoffset; opts->tsecr = tp->rx_opt.ts_recent; remaining -=TCPOLEN_TSTAMP_ALIGNED ; } -if (likely (sock_net (sk)->ipv4.sysctl_tcp_window_scaling)) { +if (likely (READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_window_scaling))) { opts->ws = tp->rx_opt.rcv_wscale; opts->options |=OPTION_WSCALE ; remaining -=TCPOLEN_WSCALE_ALIGNED ; } -if (likely (sock_net (sk)->ipv4.sysctl_tcp_sack)) { +if (likely (READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_sack))) { opts->options |=OPTION_SACK_ADVERTISE ;if (unlikely (!(OPTION_TS & opts->options))) remaining -=TCPOLEN_SACKPERM_ALIGNED ;
@@ -3647,7 +3647,7 @@ static void tcp_connect_init(struct sock *sk)* See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. */ tp->tcp_header_len =sizeof (struct tcphdr ); -if (sock_net (sk)->ipv4.sysctl_tcp_timestamps) +if (READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_timestamps)) tp->tcp_header_len +=TCPOLEN_TSTAMP_ALIGNED ;#ifdef CONFIG_TCP_MD5SIG
@@ -3683,7 +3683,7 @@ static void tcp_connect_init(struct sock *sk) tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len -sizeof (struct tcphdr ) :0 ), &tp->rcv_wnd, &tp->window_clamp, -sock_net (sk)->ipv4.sysctl_tcp_window_scaling, +READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_window_scaling), &rcv_wscale, rcv_wnd);
Signature · 1 line
2.30.2
PATCH 7/15 tcp: Fix a data-race around sysctl_tcp_early_retrans.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_early_retrans, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
---
CC: Yuchung Cheng <[email protected]>
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -2741,7 +2741,7 @@ bool tcp_schedule_loss_probe(struct sock *sk, bool advancing_rto)if (rcu_access_pointer (tp->fastopen_rsk))return false; - early_retrans =sock_net (sk)->ipv4.sysctl_tcp_early_retrans; + early_retrans =READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_early_retrans);/* Schedule a loss probe in 2*RTT for SACK capable connections * not in loss recovery, that are either limited by cwnd or application. */
Signature · 1 line
2.30.2
PATCH 8/15 tcp: Fix data-races around sysctl_tcp_recovery.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_recovery, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
---
CC: Yuchung Cheng <[email protected]>
--- net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_recovery.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +2 -1
@@ -2095,7 +2095,8 @@ static inline void tcp_init_undo(struct tcp_sock *tp)static bool tcp_is_rack (const struct sock *sk) { -return sock_net (sk)->ipv4.sysctl_tcp_recovery &TCP_RACK_LOSS_DETECTION ; +return READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_recovery) & +TCP_RACK_LOSS_DETECTION ; }/* If we detect SACK reneging, forget all SACK information
net/ipv4/tcp_recovery.c +4 -2
@@ -14,7 +14,8 @@ static u32 tcp_rack_reo_wnd(const struct sock *sk)return 0 ;if (tp->sacked_out >= tp->reordering && - !(sock_net (sk)->ipv4.sysctl_tcp_recovery &TCP_RACK_NO_DUPTHRESH )) + !(READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_recovery) & +TCP_RACK_NO_DUPTHRESH ))return 0 ; }
@@ -187,7 +188,8 @@ void tcp_rack_update_reo_wnd(struct sock *sk, struct rate_sample *rs) {struct tcp_sock *tp =tcp_sk (sk); -if (sock_net (sk)->ipv4.sysctl_tcp_recovery &TCP_RACK_STATIC_REO_WND || +if ((READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_recovery) & +TCP_RACK_STATIC_REO_WND ) || !rs->prior_delivered)return ;
Signature · 1 line
2.30.2
PATCH 9/15 tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_thin_linear_timeouts, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
---
CC: Andreas Petlund <[email protected]>
--- net/ipv4/tcp_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_timer.c +1 -1
@@ -578,7 +578,7 @@ void tcp_retransmit_timer(struct sock *sk)* linear-timeout retransmissions into a black hole */ if (sk->sk_state ==TCP_ESTABLISHED && - (tp->thin_lto || net->ipv4.sysctl_tcp_thin_linear_timeouts) && + (tp->thin_lto ||READ_ONCE (net->ipv4.sysctl_tcp_thin_linear_timeouts)) &&tcp_stream_is_thin (tp) && icsk->icsk_retransmits <=TCP_THIN_LINEAR_RETRIES ) { icsk->icsk_backoff =0 ;
Signature · 1 line
2.30.2
PATCH 10/15 tcp: Fix data-races around sysctl_tcp_slow_start_after_idle.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_slow_start_after_idle, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
--- include/net/tcp.h | 4 ++-- net/ipv4/tcp_output.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/tcp.h +2 -2
@@ -1403,8 +1403,8 @@ static inline void tcp_slow_start_after_idle_check(struct sock *sk)struct tcp_sock *tp =tcp_sk (sk);s32 delta; -if (!sock_net (sk)->ipv4.sysctl_tcp_slow_start_after_idle || tp->packets_out || - ca_ops->cong_control) +if (!READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_slow_start_after_idle) || + tp->packets_out || ca_ops->cong_control)return ; delta = tcp_jiffies32 - tp->lsndtime;if (delta >inet_csk (sk)->icsk_rto)
net/ipv4/tcp_output.c +1 -1
@@ -1898,7 +1898,7 @@ static void tcp_cwnd_validate(struct sock *sk, bool is_cwnd_limited)if (tp->packets_out > tp->snd_cwnd_used) tp->snd_cwnd_used = tp->packets_out; -if (sock_net (sk)->ipv4.sysctl_tcp_slow_start_after_idle && +if (READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_slow_start_after_idle) && (s32)(tcp_jiffies32 - tp->snd_cwnd_stamp) >=inet_csk (sk)->icsk_rto && !ca_ops->cong_control)tcp_cwnd_application_limited (sk);
Signature · 1 line
2.30.2
PATCH 11/15 tcp: Fix a data-race around sysctl_tcp_retrans_collapse.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_retrans_collapse, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/tcp_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
@@ -3105,7 +3105,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to,struct sk_buff *skb = to, *tmp;bool first = true; -if (!sock_net (sk)->ipv4.sysctl_tcp_retrans_collapse) +if (!READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_retrans_collapse))return ;if (TCP_SKB_CB (skb)->tcp_flags &TCPHDR_SYN )return ;
Signature · 1 line
2.30.2
PATCH 12/15 tcp: Fix a data-race around sysctl_tcp_stdurg.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_stdurg, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/tcp_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_input.c +1 -1
@@ -5572,7 +5572,7 @@ static void tcp_check_urg(struct sock *sk, const struct tcphdr *th)struct tcp_sock *tp =tcp_sk (sk);u32 ptr =ntohs (th->urg_ptr); -if (ptr && !sock_net (sk)->ipv4.sysctl_tcp_stdurg) +if (ptr && !READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_stdurg)) ptr--; ptr +=ntohl (th->seq);
Signature · 1 line
2.30.2
PATCH 13/15 tcp: Fix a data-race around sysctl_tcp_rfc1337.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_rfc1337, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/tcp_minisocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_minisocks.c +1 -1
@@ -173,7 +173,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,* Oh well... nobody has a sufficient solution to this * protocol bug yet. */ -if (twsk_net (tw)->ipv4.sysctl_tcp_rfc1337 ==0 ) { +if (!READ_ONCE (twsk_net (tw)->ipv4.sysctl_tcp_rfc1337)) { kill:inet_twsk_deschedule_put (tw);return TCP_TW_SUCCESS ;
Signature · 1 line
2.30.2
PATCH 14/15 tcp: Fix a data-race around sysctl_tcp_abort_on_overflow.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_abort_on_overflow, it can be changed concurrently. Thus, we need to add READ_ONCE() to its reader.
--- net/ipv4/tcp_minisocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_minisocks.c +1 -1
@@ -781,7 +781,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,if (sk != req->rsk_listener)__NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPMIGRATEREQFAILURE ); -if (!sock_net (sk)->ipv4.sysctl_tcp_abort_on_overflow) { +if (!READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_abort_on_overflow)) {inet_rsk (req)->acked =1 ;return NULL ; }
Signature · 1 line
2.30.2
PATCH 15/15 tcp: Fix data-races around sysctl_tcp_max_reordering.
In reply to Kuniyuki IwashimaWhile reading sysctl_tcp_max_reordering, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
--- net/ipv4/tcp_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_input.c +2 -2
@@ -1051,7 +1051,7 @@ static void tcp_check_sack_reordering(struct sock *sk, const u32 low_seq, tp->undo_marker ? tp->undo_retrans : 0);#endif tp->reordering =min_t (u32, (metric + mss -1 ) / mss, -sock_net (sk)->ipv4.sysctl_tcp_max_reordering); +READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_max_reordering)); }/* This exciting event is worth to be remembered. 8) */
@@ -2030,7 +2030,7 @@ static void tcp_check_reno_reordering(struct sock *sk, const int addend)return ; tp->reordering =min_t (u32, tp->packets_out + addend, -sock_net (sk)->ipv4.sysctl_tcp_max_reordering); +READ_ONCE (sock_net (sk)->ipv4.sysctl_tcp_max_reordering)); tp->reord_seen++;NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPRENOREORDER ); }
Signature · 1 line
2.30.2
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Mon, 18 Jul 2022 10:26:38 -0700 you wrote:
This series fixes data-races around 17 knobs after
fib_multipath_use_neighinipv4_net_table.
tcp_fackwas skipped because it's obsolete and there's no readers.So, round 5 will start with
tcp_dsack, 2 rounds left for 27 knobs.[...]
Here is the summary with links:
- [v1,net,01/15] ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh.
https://git.kernel.org/netdev/net/c/87507bcb4f5d - [v1,net,02/15] ipv4: Fix data-races around sysctl_fib_multipath_hash_policy. https://git.kernel.org/netdev/net/c/7998c12a08c9 - [v1,net,03/15] ipv4: Fix data-races around sysctl_fib_multipath_hash_fields. https://git.kernel.org/netdev/net/c/8895a9c2ac76 - [v1,net,04/15] ip: Fix data-races around sysctl_ip_prot_sock. https://git.kernel.org/netdev/net/c/9b55c20f8336 - [v1,net,05/15] udp: Fix a data-race around sysctl_udp_l3mdev_accept. https://git.kernel.org/netdev/net/c/3d72bb4188c7 - [v1,net,06/15] tcp: Fix data-races around sysctl knobs related to SYN option. https://git.kernel.org/netdev/net/c/3666f666e996 - [v1,net,07/15] tcp: Fix a data-race around sysctl_tcp_early_retrans. https://git.kernel.org/netdev/net/c/52e65865deb6 - [v1,net,08/15] tcp: Fix data-races around sysctl_tcp_recovery. https://git.kernel.org/netdev/net/c/e7d2ef837e14 - [v1,net,09/15] tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts. https://git.kernel.org/netdev/net/c/7c6f2a86ca59 - [v1,net,10/15] tcp: Fix data-races around sysctl_tcp_slow_start_after_idle. https://git.kernel.org/netdev/net/c/4845b5713ab1 - [v1,net,11/15] tcp: Fix a data-race around sysctl_tcp_retrans_collapse. https://git.kernel.org/netdev/net/c/1a63cb91f0c2 - [v1,net,12/15] tcp: Fix a data-race around sysctl_tcp_stdurg. https://git.kernel.org/netdev/net/c/4e08ed41cb11 - [v1,net,13/15] tcp: Fix a data-race around sysctl_tcp_rfc1337. https://git.kernel.org/netdev/net/c/0b484c91911e - [v1,net,14/15] tcp: Fix a data-race around sysctl_tcp_abort_on_overflow. https://git.kernel.org/netdev/net/c/2d17d9c73823 - [v1,net,15/15] tcp: Fix data-races around sysctl_tcp_max_reordering. https://git.kernel.org/netdev/net/c/a11e5b3e7a59
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html