net: fib_rules: Don't dump dying fib_rule in fib_rules_dump().
rocker_router_fib_event() calls fib_rule_get() during RCU dump.
If the fib_rule is dying, refcount_inc() will complain about it.
Let's call refcount_inc_not_zero() in fib_rules_dump().
Fixes: 5d7bfd1419 ("ipv4: fib_rules: Dump FIB rules when registering FIB notifier")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20260610061744.2030996-3-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
1 parent
06b693d2eb
commit
2821e85c05
2 files changed
+10
-1
No files matched your search
@@ -111,6 +111,11 @@ static inline void fib_rule_get(struct fib_rule *rule)
|
||||
refcount_inc(&rule->refcnt);
|
||||
}
|
||||
|
||||
static inline bool fib_rule_get_safe(struct fib_rule *rule)
|
||||
{
|
||||
return refcount_inc_not_zero(&rule->refcnt);
|
||||
}
|
||||
|
||||
static inline void fib_rule_put(struct fib_rule *rule)
|
||||
{
|
||||
if (refcount_dec_and_test(&rule->refcnt))
|
||||
|
||||
@@ -349,7 +349,7 @@ jumped:
|
||||
|
||||
if (err != -EAGAIN) {
|
||||
if ((arg->flags & FIB_LOOKUP_NOREF) ||
|
||||
likely(refcount_inc_not_zero(&rule->refcnt))) {
|
||||
likely(fib_rule_get_safe(rule))) {
|
||||
arg->rule = rule;
|
||||
goto out;
|
||||
}
|
||||
@@ -410,8 +410,12 @@ int fib_rules_dump(struct net *net, struct notifier_block *nb, int family,
|
||||
if (!ops)
|
||||
return -EAFNOSUPPORT;
|
||||
list_for_each_entry_rcu(rule, &ops->rules_list, list) {
|
||||
if (!fib_rule_get_safe(rule))
|
||||
continue;
|
||||
|
||||
err = call_fib_rule_notifier(nb, FIB_EVENT_RULE_ADD,
|
||||
rule, family, extack);
|
||||
fib_rule_put(rule);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user