Skip to content

Commit b514191

Browse files
idoschdavem330
authored andcommitted
vxlan: Ensure FDB dump is performed under RCU
The commit cited below removed the RCU read-side critical section from rtnl_fdb_dump() which means that the ndo_fdb_dump() callback is invoked without RCU protection. This results in the following warning [1] in the VXLAN driver, which relied on the callback being invoked from an RCU read-side critical section. Fix this by calling rcu_read_lock() in the VXLAN driver, as already done in the bridge driver. [1] WARNING: suspicious RCU usage 5.8.0-rc4-custom-01521-g481007553ce6 #29 Not tainted ----------------------------- drivers/net/vxlan.c:1379 RCU-list traversed in non-reader section!! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by bridge/166: #0: ffffffff85a27850 (rtnl_mutex){+.+.}-{3:3}, at: netlink_dump+0xea/0x1090 stack backtrace: CPU: 1 PID: 166 Comm: bridge Not tainted 5.8.0-rc4-custom-01521-g481007553ce6 #29 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014 Call Trace: dump_stack+0x100/0x184 lockdep_rcu_suspicious+0x153/0x15d vxlan_fdb_dump+0x51e/0x6d0 rtnl_fdb_dump+0x4dc/0xad0 netlink_dump+0x540/0x1090 __netlink_dump_start+0x695/0x950 rtnetlink_rcv_msg+0x802/0xbd0 netlink_rcv_skb+0x17a/0x480 rtnetlink_rcv+0x22/0x30 netlink_unicast+0x5ae/0x890 netlink_sendmsg+0x98a/0xf40 __sys_sendto+0x279/0x3b0 __x64_sys_sendto+0xe6/0x1a0 do_syscall_64+0x54/0xa0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fe14fa2ade0 Code: Bad RIP value. RSP: 002b:00007fff75bb5b88 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00005614b1ba0020 RCX: 00007fe14fa2ade0 RDX: 000000000000011c RSI: 00007fff75bb5b90 RDI: 0000000000000003 RBP: 00007fff75bb5b90 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00005614b1b89160 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Fixes: 5e6d243 ("bridge: netlink dump interface at par with brctl") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1ed06db commit b514191

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/net/vxlan.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,7 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
13761376
for (h = 0; h < FDB_HASH_SIZE; ++h) {
13771377
struct vxlan_fdb *f;
13781378

1379+
rcu_read_lock();
13791380
hlist_for_each_entry_rcu(f, &vxlan->fdb_head[h], hlist) {
13801381
struct vxlan_rdst *rd;
13811382

@@ -1387,8 +1388,10 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
13871388
cb->nlh->nlmsg_seq,
13881389
RTM_NEWNEIGH,
13891390
NLM_F_MULTI, NULL);
1390-
if (err < 0)
1391+
if (err < 0) {
1392+
rcu_read_unlock();
13911393
goto out;
1394+
}
13921395
skip_nh:
13931396
*idx += 1;
13941397
continue;
@@ -1403,12 +1406,15 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
14031406
cb->nlh->nlmsg_seq,
14041407
RTM_NEWNEIGH,
14051408
NLM_F_MULTI, rd);
1406-
if (err < 0)
1409+
if (err < 0) {
1410+
rcu_read_unlock();
14071411
goto out;
1412+
}
14081413
skip:
14091414
*idx += 1;
14101415
}
14111416
}
1417+
rcu_read_unlock();
14121418
}
14131419
out:
14141420
return err;

0 commit comments

Comments
 (0)