Skip to content

Commit fe0d692

Browse files
Curt Brunedavem330
authored andcommitted
bridge: use spin_lock_bh() in br_multicast_set_hash_max
br_multicast_set_hash_max() is called from process context in net/bridge/br_sysfs_br.c by the sysfs store_hash_max() function. br_multicast_set_hash_max() calls spin_lock(&br->multicast_lock), which can deadlock the CPU if a softirq that also tries to take the same lock interrupts br_multicast_set_hash_max() while the lock is held . This can happen quite easily when any of the bridge multicast timers expire, which try to take the same lock. The fix here is to use spin_lock_bh(), preventing other softirqs from executing on this CPU. Steps to reproduce: 1. Create a bridge with several interfaces (I used 4). 2. Set the "multicast query interval" to a low number, like 2. 3. Enable the bridge as a multicast querier. 4. Repeatedly set the bridge hash_max parameter via sysfs. # brctl addbr br0 # brctl addif br0 eth1 eth2 eth3 eth4 # brctl setmcqi br0 2 # brctl setmcquerier br0 1 # while true ; do echo 4096 > /sys/class/net/br0/bridge/hash_max; done Signed-off-by: Curt Brune <curt@cumulusnetworks.com> Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 88ad314 commit fe0d692

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/bridge/br_multicast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
19981998
u32 old;
19991999
struct net_bridge_mdb_htable *mdb;
20002000

2001-
spin_lock(&br->multicast_lock);
2001+
spin_lock_bh(&br->multicast_lock);
20022002
if (!netif_running(br->dev))
20032003
goto unlock;
20042004

@@ -2030,7 +2030,7 @@ int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val)
20302030
}
20312031

20322032
unlock:
2033-
spin_unlock(&br->multicast_lock);
2033+
spin_unlock_bh(&br->multicast_lock);
20342034

20352035
return err;
20362036
}

0 commit comments

Comments
 (0)