Skip to content

Commit ef1148d

Browse files
Eric Dumazetkuba-moo
Eric Dumazet
authored andcommitted
ipv6: remove nexthop_fib6_nh_bh()
After blamed commit, nexthop_fib6_nh_bh() and nexthop_fib6_nh() are the same. Delete nexthop_fib6_nh_bh(), and convert /proc/net/ipv6_route to standard rcu to avoid this splat: [ 5723.180080] WARNING: suspicious RCU usage [ 5723.180083] ----------------------------- [ 5723.180084] include/net/nexthop.h:516 suspicious rcu_dereference_check() usage! [ 5723.180086] other info that might help us debug this: [ 5723.180087] rcu_scheduler_active = 2, debug_locks = 1 [ 5723.180089] 2 locks held by cat/55856: [ 5723.180091] #0: ffff9440a582afa8 (&p->lock){+.+.}-{3:3}, at: seq_read_iter (fs/seq_file.c:188) [ 5723.180100] #1: ffffffffaac07040 (rcu_read_lock_bh){....}-{1:2}, at: rcu_lock_acquire (include/linux/rcupdate.h:326) [ 5723.180109] stack backtrace: [ 5723.180111] CPU: 14 PID: 55856 Comm: cat Tainted: G S I 6.3.0-dbx-DEV #528 [ 5723.180115] Call Trace: [ 5723.180117] <TASK> [ 5723.180119] dump_stack_lvl (lib/dump_stack.c:107) [ 5723.180124] dump_stack (lib/dump_stack.c:114) [ 5723.180126] lockdep_rcu_suspicious (include/linux/context_tracking.h:122) [ 5723.180132] ipv6_route_seq_show (include/net/nexthop.h:?) [ 5723.180135] ? ipv6_route_seq_next (net/ipv6/ip6_fib.c:2605) [ 5723.180140] seq_read_iter (fs/seq_file.c:272) [ 5723.180145] seq_read (fs/seq_file.c:163) [ 5723.180151] proc_reg_read (fs/proc/inode.c:316 fs/proc/inode.c:328) [ 5723.180155] vfs_read (fs/read_write.c:468) [ 5723.180160] ? up_read (kernel/locking/rwsem.c:1617) [ 5723.180164] ksys_read (fs/read_write.c:613) [ 5723.180168] __x64_sys_read (fs/read_write.c:621) [ 5723.180170] do_syscall_64 (arch/x86/entry/common.c:?) [ 5723.180174] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) [ 5723.180177] RIP: 0033:0x7fa455677d2a Fixes: 09eed11 ("neighbour: switch to standard rcu, instead of rcu_bh") Reported-by: syzbot <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e93c937 commit ef1148d

File tree

2 files changed

+8
-31
lines changed

2 files changed

+8
-31
lines changed

include/net/nexthop.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -497,29 +497,6 @@ static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh)
497497
return NULL;
498498
}
499499

500-
/* Variant of nexthop_fib6_nh().
501-
* Caller should either hold rcu_read_lock(), or RTNL.
502-
*/
503-
static inline struct fib6_nh *nexthop_fib6_nh_bh(struct nexthop *nh)
504-
{
505-
struct nh_info *nhi;
506-
507-
if (nh->is_group) {
508-
struct nh_group *nh_grp;
509-
510-
nh_grp = rcu_dereference_rtnl(nh->nh_grp);
511-
nh = nexthop_mpath_select(nh_grp, 0);
512-
if (!nh)
513-
return NULL;
514-
}
515-
516-
nhi = rcu_dereference_rtnl(nh->nh_info);
517-
if (nhi->family == AF_INET6)
518-
return &nhi->fib6_nh;
519-
520-
return NULL;
521-
}
522-
523500
static inline struct net_device *fib6_info_nh_dev(struct fib6_info *f6i)
524501
{
525502
struct fib6_nh *fib6_nh;

net/ipv6/ip6_fib.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ static int ipv6_route_native_seq_show(struct seq_file *seq, void *v)
24912491
const struct net_device *dev;
24922492

24932493
if (rt->nh)
2494-
fib6_nh = nexthop_fib6_nh_bh(rt->nh);
2494+
fib6_nh = nexthop_fib6_nh(rt->nh);
24952495

24962496
seq_printf(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen);
24972497

@@ -2556,14 +2556,14 @@ static struct fib6_table *ipv6_route_seq_next_table(struct fib6_table *tbl,
25562556

25572557
if (tbl) {
25582558
h = (tbl->tb6_id & (FIB6_TABLE_HASHSZ - 1)) + 1;
2559-
node = rcu_dereference_bh(hlist_next_rcu(&tbl->tb6_hlist));
2559+
node = rcu_dereference(hlist_next_rcu(&tbl->tb6_hlist));
25602560
} else {
25612561
h = 0;
25622562
node = NULL;
25632563
}
25642564

25652565
while (!node && h < FIB6_TABLE_HASHSZ) {
2566-
node = rcu_dereference_bh(
2566+
node = rcu_dereference(
25672567
hlist_first_rcu(&net->ipv6.fib_table_hash[h++]));
25682568
}
25692569
return hlist_entry_safe(node, struct fib6_table, tb6_hlist);
@@ -2593,7 +2593,7 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
25932593
if (!v)
25942594
goto iter_table;
25952595

2596-
n = rcu_dereference_bh(((struct fib6_info *)v)->fib6_next);
2596+
n = rcu_dereference(((struct fib6_info *)v)->fib6_next);
25972597
if (n)
25982598
return n;
25992599

@@ -2619,12 +2619,12 @@ static void *ipv6_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
26192619
}
26202620

26212621
static void *ipv6_route_seq_start(struct seq_file *seq, loff_t *pos)
2622-
__acquires(RCU_BH)
2622+
__acquires(RCU)
26232623
{
26242624
struct net *net = seq_file_net(seq);
26252625
struct ipv6_route_iter *iter = seq->private;
26262626

2627-
rcu_read_lock_bh();
2627+
rcu_read_lock();
26282628
iter->tbl = ipv6_route_seq_next_table(NULL, net);
26292629
iter->skip = *pos;
26302630

@@ -2645,15 +2645,15 @@ static bool ipv6_route_iter_active(struct ipv6_route_iter *iter)
26452645
}
26462646

26472647
static void ipv6_route_native_seq_stop(struct seq_file *seq, void *v)
2648-
__releases(RCU_BH)
2648+
__releases(RCU)
26492649
{
26502650
struct net *net = seq_file_net(seq);
26512651
struct ipv6_route_iter *iter = seq->private;
26522652

26532653
if (ipv6_route_iter_active(iter))
26542654
fib6_walker_unlink(net, &iter->w);
26552655

2656-
rcu_read_unlock_bh();
2656+
rcu_read_unlock();
26572657
}
26582658

26592659
#if IS_BUILTIN(CONFIG_IPV6) && defined(CONFIG_BPF_SYSCALL)

0 commit comments

Comments
 (0)