Skip to content

Commit 53a85c3

Browse files
liujian56harshimogalapalli
authored andcommitted
net: check vlan filter feature in vlan_vids_add_by_dev() and vlan_vids_del_by_dev()
[ Upstream commit 01a564b ] I got the below warning trace: WARNING: CPU: 4 PID: 4056 at net/core/dev.c:11066 unregister_netdevice_many_notify CPU: 4 PID: 4056 Comm: ip Not tainted 6.7.0-rc4+ gregkh#15 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 RIP: 0010:unregister_netdevice_many_notify+0x9a4/0x9b0 Call Trace: rtnl_dellink rtnetlink_rcv_msg netlink_rcv_skb netlink_unicast netlink_sendmsg __sock_sendmsg ____sys_sendmsg ___sys_sendmsg __sys_sendmsg do_syscall_64 entry_SYSCALL_64_after_hwframe It can be repoduced via: ip netns add ns1 ip netns exec ns1 ip link add bond0 type bond mode 0 ip netns exec ns1 ip link add bond_slave_1 type veth peer veth2 ip netns exec ns1 ip link set bond_slave_1 master bond0 [1] ip netns exec ns1 ethtool -K bond0 rx-vlan-filter off [2] ip netns exec ns1 ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0 [3] ip netns exec ns1 ip link add link bond0 name bond0.0 type vlan id 0 [4] ip netns exec ns1 ip link set bond_slave_1 nomaster [5] ip netns exec ns1 ip link del veth2 ip netns del ns1 This is all caused by command [1] turning off the rx-vlan-filter function of bond0. The reason is the same as commit 01f4fd2 ("bonding: Fix incorrect deletion of ETH_P_8021AD protocol vid from slaves"). Commands [2] [3] add the same vid to slave and master respectively, causing command [4] to empty slave->vlan_info. The following command [5] triggers this problem. To fix this problem, we should add VLAN_FILTER feature checks in vlan_vids_add_by_dev() and vlan_vids_del_by_dev() to prevent incorrect addition or deletion of vlan_vid information. Fixes: 348a144 ("vlan: introduce functions to do mass addition/deletion of vids by another device") Signed-off-by: Liu Jian <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]>
1 parent f22913e commit 53a85c3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Diff for: net/8021q/vlan_core.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ int vlan_vids_add_by_dev(struct net_device *dev,
329329
return 0;
330330

331331
list_for_each_entry(vid_info, &vlan_info->vid_list, list) {
332+
if (!vlan_hw_filter_capable(by_dev, vid_info->proto))
333+
continue;
332334
err = vlan_vid_add(dev, vid_info->proto, vid_info->vid);
333335
if (err)
334336
goto unwind;
@@ -339,6 +341,8 @@ int vlan_vids_add_by_dev(struct net_device *dev,
339341
list_for_each_entry_continue_reverse(vid_info,
340342
&vlan_info->vid_list,
341343
list) {
344+
if (!vlan_hw_filter_capable(by_dev, vid_info->proto))
345+
continue;
342346
vlan_vid_del(dev, vid_info->proto, vid_info->vid);
343347
}
344348

@@ -358,8 +362,11 @@ void vlan_vids_del_by_dev(struct net_device *dev,
358362
if (!vlan_info)
359363
return;
360364

361-
list_for_each_entry(vid_info, &vlan_info->vid_list, list)
365+
list_for_each_entry(vid_info, &vlan_info->vid_list, list) {
366+
if (!vlan_hw_filter_capable(by_dev, vid_info->proto))
367+
continue;
362368
vlan_vid_del(dev, vid_info->proto, vid_info->vid);
369+
}
363370
}
364371
EXPORT_SYMBOL(vlan_vids_del_by_dev);
365372

0 commit comments

Comments
 (0)