netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/ipv6: insert the fib6 gc_link of a fib6_info only if in fib6.
@ 2023-12-07 22:16 thinker.li
  2023-12-07 22:19 ` Kui-Feng Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: thinker.li @ 2023-12-07 22:16 UTC (permalink / raw)
  To: netdev, martin.lau, kernel-team, davem, kuba, pabeni, dsahern,
	edumazet
  Cc: sinquersw, kuifeng, Kui-Feng Lee, syzbot+c15aa445274af8674f41

From: Kui-Feng Lee <thinker.li@gmail.com>

Check f6i->fib6_node before inserting a f6i (fib6_info) to tb6_gc_hlist.

Previously, it checks only if f6i->fib6_table is not NULL, however it is
not enough. When a f6i is removed from a fib6_table, it's fib6_table is not
going to be reset. fib6_node is always reset when a f6i is removed from a
fib6_table and set when a f6i is added to a fib6_table. By checking
fib6_node, adding a f6i t0 tb6_gc_hlist only if f6i is in the table will be
enforced.

Fixes: 3dec89b14d37 ("net/ipv6: Remove expired routes with a separated list of routes.")
Reported-by: syzbot+c15aa445274af8674f41@syzkaller.appspotmail.com
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: dsahern@kernel.org
---
 include/net/ip6_fib.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 95ed495c3a40..8477c9ff67ac 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -512,7 +512,10 @@ static inline void fib6_set_expires_locked(struct fib6_info *f6i,
 
 	tb6 = f6i->fib6_table;
 	f6i->expires = expires;
-	if (tb6 && !fib6_has_expires(f6i))
+	if (tb6 &&
+	    rcu_dereference_protected(f6i->fib6_node,
+				      lockdep_is_held(&tb6->tb6_lock)) &&
+	    !fib6_has_expires(f6i))
 		hlist_add_head(&f6i->gc_link, &tb6->tb6_gc_hlist);
 	f6i->fib6_flags |= RTF_EXPIRES;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-08  2:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-07 22:16 [PATCH net-next] net/ipv6: insert the fib6 gc_link of a fib6_info only if in fib6 thinker.li
2023-12-07 22:19 ` Kui-Feng Lee
2023-12-07 23:17 ` David Ahern
2023-12-07 23:20   ` David Ahern
2023-12-07 23:33     ` Kui-Feng Lee
2023-12-08  1:02       ` David Ahern
2023-12-08  1:16         ` Kui-Feng Lee
2023-12-08  1:23           ` David Ahern
2023-12-08  2:30             ` Kui-Feng Lee
2023-12-08  1:03 ` Kui-Feng Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).