Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fa7cb71 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

fib: use atomic_inc_not_zero() in fib_rules_lookup



It seems we dont use appropriate refcount increment in an
rcu_read_lock() protected section.

fib_rule_get() might increment a null refcount and bad things could
happen.

While fib_nl_delrule() respects an rcu grace period before calling
fib_rule_put(), fib_rules_cleanup_ops() calls fib_rule_put() without a
grace period.

Note : after this patch, we might avoid the synchronize_rcu() call done
in fib_nl_delrule()

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15fc1f70
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -225,10 +225,12 @@ jumped:
			err = ops->action(rule, fl, flags, arg);
			err = ops->action(rule, fl, flags, arg);


		if (err != -EAGAIN) {
		if (err != -EAGAIN) {
			fib_rule_get(rule);
			if (likely(atomic_inc_not_zero(&rule->refcnt))) {
				arg->rule = rule;
				arg->rule = rule;
				goto out;
				goto out;
			}
			}
			break;
		}
	}
	}


	err = -ESRCH;
	err = -ESRCH;