Skip to content

Commit 96b9bd8

Browse files
q2vendavem330
authored andcommitted
ipv4: Fix data-races around sysctl_fib_notify_on_flag_change.
While reading sysctl_fib_notify_on_flag_change, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers. Fixes: 680aea0 ("net: ipv4: Emit notification when fib hardware flags are changed") Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 870e3a6 commit 96b9bd8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/ipv4/fib_trie.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ fib_find_matching_alias(struct net *net, const struct fib_rt_info *fri)
10421042

10431043
void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri)
10441044
{
1045+
u8 fib_notify_on_flag_change;
10451046
struct fib_alias *fa_match;
10461047
struct sk_buff *skb;
10471048
int err;
@@ -1063,14 +1064,16 @@ void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri)
10631064
WRITE_ONCE(fa_match->offload, fri->offload);
10641065
WRITE_ONCE(fa_match->trap, fri->trap);
10651066

1067+
fib_notify_on_flag_change = READ_ONCE(net->ipv4.sysctl_fib_notify_on_flag_change);
1068+
10661069
/* 2 means send notifications only if offload_failed was changed. */
1067-
if (net->ipv4.sysctl_fib_notify_on_flag_change == 2 &&
1070+
if (fib_notify_on_flag_change == 2 &&
10681071
READ_ONCE(fa_match->offload_failed) == fri->offload_failed)
10691072
goto out;
10701073

10711074
WRITE_ONCE(fa_match->offload_failed, fri->offload_failed);
10721075

1073-
if (!net->ipv4.sysctl_fib_notify_on_flag_change)
1076+
if (!fib_notify_on_flag_change)
10741077
goto out;
10751078

10761079
skb = nlmsg_new(fib_nlmsg_size(fa_match->fa_info), GFP_ATOMIC);

0 commit comments

Comments
 (0)