From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>,
Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Subject: [PATCH v1 net 02/15] ipv4: Fix data-races around sysctl_fib_multipath_hash_policy.
Date: Mon, 18 Jul 2022 10:26:40 -0700 [thread overview]
Message-ID: <20220718172653.22111-3-kuniyu@amazon.com> (raw)
In-Reply-To: <20220718172653.22111-1-kuniyu@amazon.com>
While reading sysctl_fib_multipath_hash_policy, it can be changed
concurrently. Thus, we need to add READ_ONCE() to its readers.
Fixes: bf4e0a3db97e ("net: ipv4: add support for ECMP hash policy choice")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
CC: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
net/ipv4/route.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 868d28f3b4e1..de63a5f3b767 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -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;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 91c4f60de75a..521194dd1c99 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -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;
--
2.30.2
next prev parent reply other threads:[~2022-07-18 17:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 17:26 [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 4) Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 01/15] ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh Kuniyuki Iwashima
2022-07-18 17:26 ` Kuniyuki Iwashima [this message]
2022-07-18 17:26 ` [PATCH v1 net 03/15] ipv4: Fix data-races around sysctl_fib_multipath_hash_fields Kuniyuki Iwashima
2022-07-19 9:38 ` Ido Schimmel
2022-07-18 17:26 ` [PATCH v1 net 04/15] ip: Fix data-races around sysctl_ip_prot_sock Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 05/15] udp: Fix a data-race around sysctl_udp_l3mdev_accept Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 06/15] tcp: Fix data-races around sysctl knobs related to SYN option Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 07/15] tcp: Fix a data-race around sysctl_tcp_early_retrans Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 08/15] tcp: Fix data-races around sysctl_tcp_recovery Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 09/15] tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 10/15] tcp: Fix data-races around sysctl_tcp_slow_start_after_idle Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 11/15] tcp: Fix a data-race around sysctl_tcp_retrans_collapse Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 12/15] tcp: Fix a data-race around sysctl_tcp_stdurg Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 13/15] tcp: Fix a data-race around sysctl_tcp_rfc1337 Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 14/15] tcp: Fix a data-race around sysctl_tcp_abort_on_overflow Kuniyuki Iwashima
2022-07-18 17:26 ` [PATCH v1 net 15/15] tcp: Fix data-races around sysctl_tcp_max_reordering Kuniyuki Iwashima
2022-07-20 9:30 ` [PATCH v1 net 00/15] sysctl: Fix data-races around ipv4_net_table (Round 4) patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220718172653.22111-3-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).