]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ipv4: Fix data-races around sysctl_fib_multipath_hash_policy.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 18 Jul 2022 17:26:40 +0000 (10:26 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 16 Sep 2022 08:53:24 +0000 (10:53 +0200)
BugLink: https://bugs.launchpad.net/bugs/1988479
[ Upstream commit 7998c12a08c97cc26660532c9f90a34bd7d8da5a ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
net/ipv4/route.c

index d17156c11ef8040afe0a5371e53ce8a9e1d35345..6cdf0e232b1cc61269f2bf54a6dbd156ddafc3d0 100644 (file)
@@ -9588,7 +9588,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;
index 7f08a30256c52ba58b328ece28fff2494f459d6d..ade6cb309c4060d55b329da352ba8426d3217ce2 100644 (file)
@@ -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;