Skip to content

Commit fd32f1e

Browse files
Eric Dumazetgregkh
Eric Dumazet
authored andcommitted
ipv6: remove nexthop_fib6_nh_bh()
commit ef1148d upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent edeccce commit fd32f1e

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
@@ -2492,7 +2492,7 @@ static int ipv6_route_native_seq_show(struct seq_file *seq, void *v)
24922492
const struct net_device *dev;
24932493

24942494
if (rt->nh)
2495-
fib6_nh = nexthop_fib6_nh_bh(rt->nh);
2495+
fib6_nh = nexthop_fib6_nh(rt->nh);
24962496

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

@@ -2557,14 +2557,14 @@ static struct fib6_table *ipv6_route_seq_next_table(struct fib6_table *tbl,
25572557

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

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

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

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

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

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

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

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

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

2657-
rcu_read_unlock_bh();
2657+
rcu_read_unlock();
26582658
}
26592659

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

0 commit comments

Comments
 (0)