Skip to content

Commit

Permalink
bridge: netlink: fix slave_changelink/br_setport race conditions
Browse files Browse the repository at this point in the history
Since slave_changelink support was added there have been a few race
conditions when using br_setport() since some of the port functions it
uses require the bridge lock. It is very easy to trigger a lockup due to
some internal spin_lock() usage without bh disabled, also it's possible to
get the bridge into an inconsistent state.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Fixes: 3ac636b ("bridge: implement rtnl_link_ops->slave_changelink")
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Jul 26, 2015
1 parent 4851643 commit 963ad94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/bridge/br_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,17 @@ static int br_port_slave_changelink(struct net_device *brdev,
struct nlattr *tb[],
struct nlattr *data[])
{
struct net_bridge *br = netdev_priv(brdev);
int ret;

if (!data)
return 0;
return br_setport(br_port_get_rtnl(dev), data);

spin_lock_bh(&br->lock);
ret = br_setport(br_port_get_rtnl(dev), data);
spin_unlock_bh(&br->lock);

return ret;
}

static int br_port_fill_slave_info(struct sk_buff *skb,
Expand Down

0 comments on commit 963ad94

Please sign in to comment.