* [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions
@ 2015-07-22 11:03 Nikolay Aleksandrov
2015-07-22 12:52 ` Jiri Pirko
2015-07-26 23:28 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Aleksandrov @ 2015-07-22 11:03 UTC (permalink / raw)
To: netdev; +Cc: Nikolay Aleksandrov, bridge, jiri, davem
From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
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: 3ac636b8591c ("bridge: implement rtnl_link_ops->slave_changelink")
---
net/bridge/br_netlink.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 364bdc98bd9b..3da5525eb8a2 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -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,
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions
2015-07-22 11:03 [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions Nikolay Aleksandrov
@ 2015-07-22 12:52 ` Jiri Pirko
2015-07-26 23:28 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2015-07-22 12:52 UTC (permalink / raw)
To: Nikolay Aleksandrov; +Cc: netdev, davem, bridge, stephen, Nikolay Aleksandrov
Wed, Jul 22, 2015 at 01:03:40PM CEST, razor@blackwall.org wrote:
>From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>
>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: 3ac636b8591c ("bridge: implement rtnl_link_ops->slave_changelink")
Looks fine to me, thanks for this fix.
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions
2015-07-22 11:03 [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions Nikolay Aleksandrov
2015-07-22 12:52 ` Jiri Pirko
@ 2015-07-26 23:28 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-07-26 23:28 UTC (permalink / raw)
To: razor; +Cc: netdev, bridge, jiri, nikolay
From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Wed, 22 Jul 2015 13:03:40 +0200
> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>
> 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: 3ac636b8591c ("bridge: implement rtnl_link_ops->slave_changelink")
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-26 23:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-22 11:03 [PATCH net] bridge: netlink: fix slave_changelink/br_setport race conditions Nikolay Aleksandrov
2015-07-22 12:52 ` Jiri Pirko
2015-07-26 23:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).