Commit 8895a9c2 authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by David S. Miller

ipv4: Fix data-races around sysctl_fib_multipath_hash_fields.

While reading sysctl_fib_multipath_hash_fields, it can be changed
concurrently.  Thus, we need to add READ_ONCE() to its readers.

Fixes: ce5c9c20 ("ipv4: Add a sysctl to control multipath hash fields")
Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7998c12a
...@@ -10342,7 +10342,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp, ...@@ -10342,7 +10342,7 @@ static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_mp_hash_inner_l3(config); mlxsw_sp_mp_hash_inner_l3(config);
break; break;
case 3: case 3:
hash_fields = net->ipv4.sysctl_fib_multipath_hash_fields; hash_fields = READ_ONCE(net->ipv4.sysctl_fib_multipath_hash_fields);
/* Outer */ /* Outer */
MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP); MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_NOT_TCP_NOT_UDP);
MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP); MLXSW_SP_MP_HASH_HEADER_SET(headers, IPV4_EN_TCP_UDP);
......
...@@ -1929,7 +1929,7 @@ static u32 fib_multipath_custom_hash_outer(const struct net *net, ...@@ -1929,7 +1929,7 @@ static u32 fib_multipath_custom_hash_outer(const struct net *net,
const struct sk_buff *skb, const struct sk_buff *skb,
bool *p_has_inner) 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; struct flow_keys keys, hash_keys;
if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK))
...@@ -1958,7 +1958,7 @@ static u32 fib_multipath_custom_hash_inner(const struct net *net, ...@@ -1958,7 +1958,7 @@ static u32 fib_multipath_custom_hash_inner(const struct net *net,
const struct sk_buff *skb, const struct sk_buff *skb,
bool has_inner) 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; struct flow_keys keys, hash_keys;
/* We assume the packet carries an encapsulation, but if none was /* 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, ...@@ -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, static u32 fib_multipath_custom_hash_fl4(const struct net *net,
const struct flowi4 *fl4) 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; struct flow_keys hash_keys;
if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK)) if (!(hash_fields & FIB_MULTIPATH_HASH_FIELD_OUTER_MASK))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment