Skip to content

Commit 2f56f6b

Browse files
jmberg-inteldavem330
authored andcommitted
bridge: fix bridge netlink RCU usage
When the STP timer fires, it can call br_ifinfo_notify(), which in turn ends up in the new br_get_link_af_size(). This function is annotated to be using RTNL locking, which clearly isn't the case here, and thus lockdep warns: =============================== [ INFO: suspicious RCU usage. ] 3.19.0+ #569 Not tainted ------------------------------- net/bridge/br_private.h:204 suspicious rcu_dereference_protected() usage! Fix this by doing RCU locking here. Fixes: b7853d7 ("bridge: add vlan info to bridge setlink and dellink notification messages") Signed-off-by: Johannes Berg <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 71a83a6 commit 2f56f6b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/bridge/br_netlink.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,19 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev,
8181
struct net_port_vlans *pv;
8282
int num_vlan_infos;
8383

84+
rcu_read_lock();
8485
if (br_port_exists(dev))
85-
pv = nbp_get_vlan_info(br_port_get_rtnl(dev));
86+
pv = nbp_get_vlan_info(br_port_get_rcu(dev));
8687
else if (dev->priv_flags & IFF_EBRIDGE)
8788
pv = br_get_vlan_info((struct net_bridge *)netdev_priv(dev));
8889
else
89-
return 0;
90-
91-
if (!pv)
92-
return 0;
90+
pv = NULL;
91+
if (pv)
92+
num_vlan_infos = br_get_num_vlan_infos(pv, filter_mask);
93+
else
94+
num_vlan_infos = 0;
95+
rcu_read_unlock();
9396

94-
num_vlan_infos = br_get_num_vlan_infos(pv, filter_mask);
9597
if (!num_vlan_infos)
9698
return 0;
9799

0 commit comments

Comments
 (0)