* [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2).
@ 2022-07-13 20:51 Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl Kuniyuki Iwashima
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
This series fixes data-races around 15 knobs after ip_default_ttl in
ipv4_net_table.
These two knobs are skipped.
- ip_local_port_range is safe with its own lock.
- ip_local_reserved_ports uses proc_do_large_bitmap(), which will need
an additional lock and can be fixed later.
So, the next round will start with igmp_link_local_mcast_reports.
Kuniyuki Iwashima (15):
ip: Fix data-races around sysctl_ip_default_ttl.
ip: Fix data-races around sysctl_ip_no_pmtu_disc.
ip: Fix data-races around sysctl_ip_fwd_use_pmtu.
ip: Fix data-races around sysctl_ip_fwd_update_priority.
ip: Fix data-races around sysctl_ip_nonlocal_bind.
ip: Fix a data-race around sysctl_ip_autobind_reuse.
ip: Fix a data-race around sysctl_fwmark_reflect.
tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
tcp: Fix data-races around sysctl_tcp_l3mdev_accept.
tcp: Fix data-races around sysctl_tcp_mtu_probing.
tcp: Fix data-races around sysctl_tcp_base_mss.
tcp: Fix data-races around sysctl_tcp_min_snd_mss.
tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor.
tcp: Fix a data-race around sysctl_tcp_probe_threshold.
tcp: Fix a data-race around sysctl_tcp_probe_interval.
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++-
drivers/net/ethernet/netronome/nfp/flower/action.c | 2 +-
include/net/inet_hashtables.h | 2 +-
include/net/inet_sock.h | 9 +++++----
include/net/ip.h | 4 ++--
include/net/route.h | 2 +-
net/ipv4/af_inet.c | 2 +-
net/ipv4/icmp.c | 2 +-
net/ipv4/inet_connection_sock.c | 2 +-
net/ipv4/ip_forward.c | 2 +-
net/ipv4/ip_sockglue.c | 2 +-
net/ipv4/netfilter/nf_reject_ipv4.c | 4 ++--
net/ipv4/proc.c | 2 +-
net/ipv4/route.c | 2 +-
net/ipv4/tcp_output.c | 11 ++++++-----
net/ipv4/tcp_timer.c | 8 ++++----
net/ipv6/af_inet6.c | 2 +-
net/netfilter/nf_synproxy_core.c | 2 +-
net/sctp/protocol.c | 2 +-
net/xfrm/xfrm_state.c | 2 +-
20 files changed, 35 insertions(+), 32 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc Kuniyuki Iwashima
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_ip_default_ttl, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
drivers/net/ethernet/netronome/nfp/flower/action.c | 2 +-
include/net/route.h | 2 +-
net/ipv4/ip_sockglue.c | 2 +-
net/ipv4/netfilter/nf_reject_ipv4.c | 4 ++--
net/ipv4/proc.c | 2 +-
net/netfilter/nf_synproxy_core.c | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 0147de405365..ffb6f6d05a07 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -474,7 +474,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,
set_tun->ttl = ip4_dst_hoplimit(&rt->dst);
ip_rt_put(rt);
} else {
- set_tun->ttl = net->ipv4.sysctl_ip_default_ttl;
+ set_tun->ttl = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
}
}
diff --git a/include/net/route.h b/include/net/route.h
index 991a3985712d..bbcf2aba149f 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -373,7 +373,7 @@ static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
struct net *net = dev_net(dst->dev);
if (hoplimit == 0)
- hoplimit = net->ipv4.sysctl_ip_default_ttl;
+ hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
return hoplimit;
}
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 445a9ecaefa1..d497d525dea3 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1606,7 +1606,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
{
struct net *net = sock_net(sk);
val = (inet->uc_ttl == -1 ?
- net->ipv4.sysctl_ip_default_ttl :
+ READ_ONCE(net->ipv4.sysctl_ip_default_ttl) :
inet->uc_ttl);
break;
}
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index 918c61fda0f3..d640adcaf1b1 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -62,7 +62,7 @@ struct sk_buff *nf_reject_skb_v4_tcp_reset(struct net *net,
skb_reserve(nskb, LL_MAX_HEADER);
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
- net->ipv4.sysctl_ip_default_ttl);
+ READ_ONCE(net->ipv4.sysctl_ip_default_ttl));
nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
niph->tot_len = htons(nskb->len);
ip_send_check(niph);
@@ -117,7 +117,7 @@ struct sk_buff *nf_reject_skb_v4_unreach(struct net *net,
skb_reserve(nskb, LL_MAX_HEADER);
niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP,
- net->ipv4.sysctl_ip_default_ttl);
+ READ_ONCE(net->ipv4.sysctl_ip_default_ttl));
skb_reset_transport_header(nskb);
icmph = skb_put_zero(nskb, sizeof(struct icmphdr));
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 28836071f0a6..0088a4c64d77 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -387,7 +387,7 @@ static int snmp_seq_show_ipstats(struct seq_file *seq, void *v)
seq_printf(seq, "\nIp: %d %d",
IPV4_DEVCONF_ALL(net, FORWARDING) ? 1 : 2,
- net->ipv4.sysctl_ip_default_ttl);
+ READ_ONCE(net->ipv4.sysctl_ip_default_ttl));
BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0);
snmp_get_cpu_field64_batch(buff64, snmp4_ipstats_list,
diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c
index e479dd0561c5..16915f8eef2b 100644
--- a/net/netfilter/nf_synproxy_core.c
+++ b/net/netfilter/nf_synproxy_core.c
@@ -405,7 +405,7 @@ synproxy_build_ip(struct net *net, struct sk_buff *skb, __be32 saddr,
iph->tos = 0;
iph->id = 0;
iph->frag_off = htons(IP_DF);
- iph->ttl = net->ipv4.sysctl_ip_default_ttl;
+ iph->ttl = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
iph->protocol = IPPROTO_TCP;
iph->check = 0;
iph->saddr = saddr;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu Kuniyuki Iwashima
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_ip_no_pmtu_disc, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/ipv4/af_inet.c | 2 +-
net/ipv4/icmp.c | 2 +-
net/ipv6/af_inet6.c | 2 +-
net/xfrm/xfrm_state.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ac67f6b4ec70..4bc24f9e38b3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -335,7 +335,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
inet->hdrincl = 1;
}
- if (net->ipv4.sysctl_ip_no_pmtu_disc)
+ if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
inet->pmtudisc = IP_PMTUDISC_DONT;
else
inet->pmtudisc = IP_PMTUDISC_WANT;
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 57c4f0d87a7a..d5d745c3e345 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -881,7 +881,7 @@ static enum skb_drop_reason icmp_unreach(struct sk_buff *skb)
* values please see
* Documentation/networking/ip-sysctl.rst
*/
- switch (net->ipv4.sysctl_ip_no_pmtu_disc) {
+ switch (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) {
default:
net_dbg_ratelimited("%pI4: fragmentation needed and DF set\n",
&iph->daddr);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 70564ddccc46..6f354f8be2c5 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -226,7 +226,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
RCU_INIT_POINTER(inet->mc_list, NULL);
inet->rcv_tos = 0;
- if (net->ipv4.sysctl_ip_no_pmtu_disc)
+ if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc))
inet->pmtudisc = IP_PMTUDISC_DONT;
else
inet->pmtudisc = IP_PMTUDISC_WANT;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 08564e0eef20..ccfb172eb5b8 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2620,7 +2620,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
int err;
if (family == AF_INET &&
- xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)
+ READ_ONCE(xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc))
x->props.flags |= XFRM_STATE_NOPMTUDISC;
err = -EPROTONOSUPPORT;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority Kuniyuki Iwashima
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Hannes Frederic Sowa
While reading sysctl_ip_fwd_use_pmtu, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: f87c10a8aa1e ("ipv4: introduce ip_dst_mtu_maybe_forward and protect forwarding path against pmtu spoofing")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
include/net/ip.h | 2 +-
net/ipv4/route.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/ip.h b/include/net/ip.h
index 26fffda78cca..05fe313f72fa 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -446,7 +446,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst,
struct net *net = dev_net(dst->dev);
unsigned int mtu;
- if (net->ipv4.sysctl_ip_fwd_use_pmtu ||
+ if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) ||
ip_mtu_locked(dst) ||
!forwarding) {
mtu = rt->rt_pmtu;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 356f535f3443..91c4f60de75a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1398,7 +1398,7 @@ u32 ip_mtu_from_fib_result(struct fib_result *res, __be32 daddr)
struct fib_info *fi = res->fi;
u32 mtu = 0;
- if (dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu ||
+ if (READ_ONCE(dev_net(dev)->ipv4.sysctl_ip_fwd_use_pmtu) ||
fi->fib_metrics->metrics[RTAX_LOCK - 1] & (1 << RTAX_MTU))
mtu = fi->fib_mtu;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (2 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind Kuniyuki Iwashima
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Petr Machata
While reading sysctl_ip_fwd_update_priority, it can be changed
concurrently. Thus, we need to add READ_ONCE() to its readers.
Fixes: 432e05d32892 ("net: ipv4: Control SKB reprioritization after forwarding")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Petr Machata <petrm@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++-
net/ipv4/ip_forward.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 0d8a0068e4ca..868d28f3b4e1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -10523,13 +10523,14 @@ static int mlxsw_sp_dscp_init(struct mlxsw_sp *mlxsw_sp)
static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
{
struct net *net = mlxsw_sp_net(mlxsw_sp);
- bool usp = net->ipv4.sysctl_ip_fwd_update_priority;
char rgcr_pl[MLXSW_REG_RGCR_LEN];
u64 max_rifs;
+ bool usp;
if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS))
return -EIO;
max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
+ usp = READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority);
mlxsw_reg_rgcr_pack(rgcr_pl, true, true);
mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs);
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index e3aa436a1bdf..e18931a6d153 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -157,7 +157,7 @@ int ip_forward(struct sk_buff *skb)
!skb_sec_path(skb))
ip_rt_send_redirect(skb);
- if (net->ipv4.sysctl_ip_fwd_update_priority)
+ if (READ_ONCE(net->ipv4.sysctl_ip_fwd_update_priority))
skb->priority = rt_tos2priority(iph->tos);
return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD,
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (3 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse Kuniyuki Iwashima
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_ip_nonlocal_bind, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
include/net/inet_sock.h | 2 +-
net/sctp/protocol.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index daead5fb389a..68d337775564 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -374,7 +374,7 @@ static inline bool inet_get_convert_csum(struct sock *sk)
static inline bool inet_can_nonlocal_bind(struct net *net,
struct inet_sock *inet)
{
- return net->ipv4.sysctl_ip_nonlocal_bind ||
+ return READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind) ||
inet->freebind || inet->transparent;
}
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 35928fefae33..1a094b087d88 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -358,7 +358,7 @@ static int sctp_v4_available(union sctp_addr *addr, struct sctp_sock *sp)
if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) &&
ret != RTN_LOCAL &&
!sp->inet.freebind &&
- !net->ipv4.sysctl_ip_nonlocal_bind)
+ !READ_ONCE(net->ipv4.sysctl_ip_nonlocal_bind))
return 0;
if (ipv6_only_sock(sctp_opt2sk(sp)))
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (4 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 07/15] ip: Fix a data-race around sysctl_fwmark_reflect Kuniyuki Iwashima
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_ip_autobind_reuse, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: 4b01a9674231 ("tcp: bind(0) remove the SO_REUSEADDR restriction when ephemeral ports are exhausted.")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/ipv4/inet_connection_sock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 53f5f956d948..2c44556af452 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -263,7 +263,7 @@ inet_csk_find_open_port(struct sock *sk, struct inet_bind_bucket **tb_ret, int *
goto other_half_scan;
}
- if (net->ipv4.sysctl_ip_autobind_reuse && !relax) {
+ if (READ_ONCE(net->ipv4.sysctl_ip_autobind_reuse) && !relax) {
/* We still have a chance to connect to different destinations */
relax = true;
goto ports_exhausted;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 07/15] ip: Fix a data-race around sysctl_fwmark_reflect.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (5 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept Kuniyuki Iwashima
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Lorenzo Colitti
While reading sysctl_fwmark_reflect, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: e110861f8609 ("net: add a sysctl to reflect the fwmark on replies")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Lorenzo Colitti <lorenzo@google.com>
---
include/net/ip.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/ip.h b/include/net/ip.h
index 05fe313f72fa..4a15b6bcb4b8 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -384,7 +384,7 @@ void ipfrag_init(void);
void ip_static_sysctl_init(void);
#define IP4_REPLY_MARK(net, mark) \
- ((net)->ipv4.sysctl_fwmark_reflect ? (mark) : 0)
+ (READ_ONCE((net)->ipv4.sysctl_fwmark_reflect) ? (mark) : 0)
static inline bool ip_is_fragment(const struct iphdr *iph)
{
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (6 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 07/15] ip: Fix a data-race around sysctl_fwmark_reflect Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept Kuniyuki Iwashima
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Lorenzo Colitti
While reading sysctl_tcp_fwmark_accept, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: 84f39b08d786 ("net: support marking accepting TCP sockets")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Lorenzo Colitti <lorenzo@google.com>
---
include/net/inet_sock.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 68d337775564..b29108f0973a 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -107,7 +107,8 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
{
- if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)
+ if (!sk->sk_mark &&
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept))
return skb->mark;
return sk->sk_mark;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (7 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept Kuniyuki Iwashima
@ 2022-07-13 20:51 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing Kuniyuki Iwashima
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:51 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_tcp_l3mdev_accept, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 6dd9a14e92e5 ("net: Allow accepted sockets to be bound to l3mdev domain")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
include/net/inet_hashtables.h | 2 +-
include/net/inet_sock.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index ebfa3df6f8dc..fd6b510d114b 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -179,7 +179,7 @@ static inline bool inet_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_tcp_l3mdev_accept,
+ return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept),
bound_dev_if, dif, sdif);
#else
return inet_bound_dev_eq(true, bound_dev_if, dif, sdif);
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index b29108f0973a..6395f6b9a5d2 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -121,7 +121,7 @@ static inline int inet_request_bound_dev_if(const struct sock *sk,
#ifdef CONFIG_NET_L3_MASTER_DEV
struct net *net = sock_net(sk);
- if (!bound_dev_if && net->ipv4.sysctl_tcp_l3mdev_accept)
+ if (!bound_dev_if && READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))
return l3mdev_master_ifindex_by_index(net, skb->skb_iif);
#endif
@@ -133,7 +133,7 @@ static inline int inet_sk_bound_l3mdev(const struct sock *sk)
#ifdef CONFIG_NET_L3_MASTER_DEV
struct net *net = sock_net(sk);
- if (!net->ipv4.sysctl_tcp_l3mdev_accept)
+ if (!READ_ONCE(net->ipv4.sysctl_tcp_l3mdev_accept))
return l3mdev_master_ifindex_by_index(net,
sk->sk_bound_dev_if);
#endif
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (8 preceding siblings ...)
2022-07-13 20:51 ` [PATCH v1 net 09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 11/15] tcp: Fix data-races around sysctl_tcp_base_mss Kuniyuki Iwashima
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, John Heffner
While reading sysctl_tcp_mtu_probing, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 5d424d5a674f ("[TCP]: MTU probing")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: John Heffner <jheffner@psc.edu>
---
net/ipv4/tcp_output.c | 2 +-
net/ipv4/tcp_timer.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 11aa0ab10bba..3fcfc0f1e9f9 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1762,7 +1762,7 @@ void tcp_mtup_init(struct sock *sk)
struct inet_connection_sock *icsk = inet_csk(sk);
struct net *net = sock_net(sk);
- icsk->icsk_mtup.enabled = net->ipv4.sysctl_tcp_mtu_probing > 1;
+ icsk->icsk_mtup.enabled = READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) > 1;
icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) +
icsk->icsk_af_ops->net_header_len;
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_base_mss);
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 20cf4a98c69d..98bb00e29e1e 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -163,7 +163,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
int mss;
/* Black hole detection */
- if (!net->ipv4.sysctl_tcp_mtu_probing)
+ if (!READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing))
return;
if (!icsk->icsk_mtup.enabled) {
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 11/15] tcp: Fix data-races around sysctl_tcp_base_mss.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (9 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss Kuniyuki Iwashima
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, John Heffner
While reading sysctl_tcp_base_mss, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 5d424d5a674f ("[TCP]: MTU probing")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: John Heffner <jheffner@psc.edu>
---
net/ipv4/tcp_output.c | 2 +-
net/ipv4/tcp_timer.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 3fcfc0f1e9f9..9450d8469871 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1765,7 +1765,7 @@ void tcp_mtup_init(struct sock *sk)
icsk->icsk_mtup.enabled = READ_ONCE(net->ipv4.sysctl_tcp_mtu_probing) > 1;
icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) +
icsk->icsk_af_ops->net_header_len;
- icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, net->ipv4.sysctl_tcp_base_mss);
+ icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, READ_ONCE(net->ipv4.sysctl_tcp_base_mss));
icsk->icsk_mtup.probe_size = 0;
if (icsk->icsk_mtup.enabled)
icsk->icsk_mtup.probe_timestamp = tcp_jiffies32;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 98bb00e29e1e..04063c7e33ba 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -171,7 +171,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
icsk->icsk_mtup.probe_timestamp = tcp_jiffies32;
} else {
mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1;
- mss = min(net->ipv4.sysctl_tcp_base_mss, mss);
+ mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss);
mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor);
mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss);
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (10 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 11/15] tcp: Fix data-races around sysctl_tcp_base_mss Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor Kuniyuki Iwashima
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
While reading sysctl_tcp_min_snd_mss, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its readers.
Fixes: 5f3e2bf008c2 ("tcp: add tcp_min_snd_mss sysctl")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/ipv4/tcp_output.c | 3 ++-
net/ipv4/tcp_timer.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 9450d8469871..7130b405da21 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1719,7 +1719,8 @@ static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu)
mss_now -= icsk->icsk_ext_hdr_len;
/* Then reserve room for full set of TCP options and 8 bytes of data */
- mss_now = max(mss_now, sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss);
+ mss_now = max(mss_now,
+ READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_snd_mss));
return mss_now;
}
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 04063c7e33ba..39107bb730b0 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -173,7 +173,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1;
mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss);
mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor);
- mss = max(mss, net->ipv4.sysctl_tcp_min_snd_mss);
+ mss = max(mss, READ_ONCE(net->ipv4.sysctl_tcp_min_snd_mss));
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
}
tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (11 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold Kuniyuki Iwashima
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Josh Hunt
While reading sysctl_tcp_mtu_probe_floor, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: c04b79b6cfd7 ("tcp: add new tcp_mtu_probe_floor sysctl")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Josh Hunt <johunt@akamai.com>
---
net/ipv4/tcp_timer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 39107bb730b0..4f3b9ab222b6 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -172,7 +172,7 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk)
} else {
mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1;
mss = min(READ_ONCE(net->ipv4.sysctl_tcp_base_mss), mss);
- mss = max(mss, net->ipv4.sysctl_tcp_mtu_probe_floor);
+ mss = max(mss, READ_ONCE(net->ipv4.sysctl_tcp_mtu_probe_floor));
mss = max(mss, READ_ONCE(net->ipv4.sysctl_tcp_min_snd_mss));
icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (12 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval Kuniyuki Iwashima
2022-07-15 11:00 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) patchwork-bot+netdevbpf
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Fan Du
While reading sysctl_tcp_probe_threshold, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: 6b58e0a5f32d ("ipv4: Use binary search to choose tcp PMTU probe_size")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Fan Du <fan.du@intel.com>
---
net/ipv4/tcp_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 7130b405da21..aa757c74dad4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2367,7 +2367,7 @@ static int tcp_mtu_probe(struct sock *sk)
* probing process by not resetting search range to its orignal.
*/
if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high) ||
- interval < net->ipv4.sysctl_tcp_probe_threshold) {
+ interval < READ_ONCE(net->ipv4.sysctl_tcp_probe_threshold)) {
/* Check whether enough time has elaplased for
* another round of probing.
*/
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval.
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (13 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold Kuniyuki Iwashima
@ 2022-07-13 20:52 ` Kuniyuki Iwashima
2022-07-15 11:00 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) patchwork-bot+netdevbpf
15 siblings, 0 replies; 17+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-13 20:52 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, Fan Du
While reading sysctl_tcp_probe_interval, it can be changed concurrently.
Thus, we need to add READ_ONCE() to its reader.
Fixes: 05cbc0db03e8 ("ipv4: Create probe timer for tcp PMTU as per RFC4821")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Fan Du <fan.du@intel.com>
---
net/ipv4/tcp_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index aa757c74dad4..02ab3a9c6657 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2283,7 +2283,7 @@ static inline void tcp_mtu_check_reprobe(struct sock *sk)
u32 interval;
s32 delta;
- interval = net->ipv4.sysctl_tcp_probe_interval;
+ interval = READ_ONCE(net->ipv4.sysctl_tcp_probe_interval);
delta = tcp_jiffies32 - icsk->icsk_mtup.probe_timestamp;
if (unlikely(delta >= interval * HZ)) {
int mss = tcp_current_mss(sk);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2).
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
` (14 preceding siblings ...)
2022-07-13 20:52 ` [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval Kuniyuki Iwashima
@ 2022-07-15 11:00 ` patchwork-bot+netdevbpf
15 siblings, 0 replies; 17+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-15 11:00 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: davem, edumazet, kuba, pabeni, dsahern, kuni1840, netdev
Hello:
This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Wed, 13 Jul 2022 13:51:50 -0700 you wrote:
> This series fixes data-races around 15 knobs after ip_default_ttl in
> ipv4_net_table.
>
> These two knobs are skipped.
> - ip_local_port_range is safe with its own lock.
> - ip_local_reserved_ports uses proc_do_large_bitmap(), which will need
> an additional lock and can be fixed later.
>
> [...]
Here is the summary with links:
- [v1,net,01/15] ip: Fix data-races around sysctl_ip_default_ttl.
https://git.kernel.org/netdev/net/c/8281b7ec5c56
- [v1,net,02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc.
https://git.kernel.org/netdev/net/c/0968d2a441bf
- [v1,net,03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu.
https://git.kernel.org/netdev/net/c/60c158dc7b1f
- [v1,net,04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority.
https://git.kernel.org/netdev/net/c/7bf9e18d9a5e
- [v1,net,05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind.
https://git.kernel.org/netdev/net/c/289d3b21fb0b
- [v1,net,06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse.
https://git.kernel.org/netdev/net/c/0db232765887
- [v1,net,07/15] ip: Fix a data-race around sysctl_fwmark_reflect.
https://git.kernel.org/netdev/net/c/85d0b4dbd74b
- [v1,net,08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept.
https://git.kernel.org/netdev/net/c/1a0008f9df59
- [v1,net,09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept.
https://git.kernel.org/netdev/net/c/08a75f106794
- [v1,net,10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing.
https://git.kernel.org/netdev/net/c/f47d00e077e7
- [v1,net,11/15] tcp: Fix data-races around sysctl_tcp_base_mss.
https://git.kernel.org/netdev/net/c/88d78bc097cd
- [v1,net,12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss.
https://git.kernel.org/netdev/net/c/78eb166cdefc
- [v1,net,13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor.
https://git.kernel.org/netdev/net/c/8e92d4423615
- [v1,net,14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold.
https://git.kernel.org/netdev/net/c/92c0aa417547
- [v1,net,15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval.
https://git.kernel.org/netdev/net/c/2a85388f1d94
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2022-07-15 11:00 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 20:51 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 01/15] ip: Fix data-races around sysctl_ip_default_ttl Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 02/15] ip: Fix data-races around sysctl_ip_no_pmtu_disc Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 03/15] ip: Fix data-races around sysctl_ip_fwd_use_pmtu Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_fwd_update_priority Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 05/15] ip: Fix data-races around sysctl_ip_nonlocal_bind Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 06/15] ip: Fix a data-race around sysctl_ip_autobind_reuse Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 07/15] ip: Fix a data-race around sysctl_fwmark_reflect Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 08/15] tcp/dccp: Fix a data-race around sysctl_tcp_fwmark_accept Kuniyuki Iwashima
2022-07-13 20:51 ` [PATCH v1 net 09/15] tcp: Fix data-races around sysctl_tcp_l3mdev_accept Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_mtu_probing Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 11/15] tcp: Fix data-races around sysctl_tcp_base_mss Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 12/15] tcp: Fix data-races around sysctl_tcp_min_snd_mss Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_mtu_probe_floor Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_probe_threshold Kuniyuki Iwashima
2022-07-13 20:52 ` [PATCH v1 net 15/15] tcp: Fix a data-race around sysctl_tcp_probe_interval Kuniyuki Iwashima
2022-07-15 11:00 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 2) patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.