Skip to content

Commit f8d8ce1

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: fix possible infinite loop in fib6_info_uses_dev()
fib6_info_uses_dev() seems to rely on RCU without an explicit protection. Like the prior fix in rt6_nlmsg_size(), we need to make sure fib6_del_route() or fib6_add_rt2node() have not removed the anchor from the list, or we risk an infinite loop. Fixes: d9ccb18 ("ipv6: Fix soft lockups in fib6_select_path under high next hop churn") Signed-off-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 54e6fe9 commit f8d8ce1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

net/ipv6/route.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5958,16 +5958,21 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i,
59585958
if (f6i->fib6_nh->fib_nh_dev == dev)
59595959
return true;
59605960

5961-
if (f6i->fib6_nsiblings) {
5962-
struct fib6_info *sibling, *next_sibling;
5961+
if (READ_ONCE(f6i->fib6_nsiblings)) {
5962+
const struct fib6_info *sibling;
59635963

5964-
list_for_each_entry_safe(sibling, next_sibling,
5965-
&f6i->fib6_siblings, fib6_siblings) {
5966-
if (sibling->fib6_nh->fib_nh_dev == dev)
5964+
rcu_read_lock();
5965+
list_for_each_entry_rcu(sibling, &f6i->fib6_siblings,
5966+
fib6_siblings) {
5967+
if (sibling->fib6_nh->fib_nh_dev == dev) {
5968+
rcu_read_unlock();
59675969
return true;
5970+
}
5971+
if (!READ_ONCE(f6i->fib6_nsiblings))
5972+
break;
59685973
}
5974+
rcu_read_unlock();
59695975
}
5970-
59715976
return false;
59725977
}
59735978

0 commit comments

Comments
 (0)