diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-04-23 03:47:15 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-04-23 21:25:35 -0400 |
commit | 1ebebea8e844d01c80b93b8ee4d696ee7c0cbc27 (patch) | |
tree | 9e246a1aa36afcd735940a07253124b138e0ed03 /net/mac80211 | |
parent | d1d8f44a4e3c730984283c0bf4b3458e3a88c15a (diff) |
mac80211: Fix race between ieee80211_rx_bss_put and lookup routines.
The put routine first decrements the users counter and then
(if it is zero) locks the sta_bss_lock and removes one from
the list and the hash.
Thus, any of ieee80211_sta_config_auth, ieee80211_rx_bss_get
or ieee80211_rx_mesh_bss_get can race with it by finding a
bss that is about to get kfree-ed.
Using atomic_dec_and_lock in ieee80211_rx_bss_put takes care
of this race.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/mlme.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index c0a5345c8a61..a5e5c31c23ab 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -2248,10 +2248,13 @@ static void ieee80211_rx_bss_put(struct net_device *dev, | |||
2248 | struct ieee80211_sta_bss *bss) | 2248 | struct ieee80211_sta_bss *bss) |
2249 | { | 2249 | { |
2250 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 2250 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
2251 | if (!atomic_dec_and_test(&bss->users)) | 2251 | |
2252 | local_bh_disable(); | ||
2253 | if (!atomic_dec_and_lock(&bss->users, &local->sta_bss_lock)) { | ||
2254 | local_bh_enable(); | ||
2252 | return; | 2255 | return; |
2256 | } | ||
2253 | 2257 | ||
2254 | spin_lock_bh(&local->sta_bss_lock); | ||
2255 | __ieee80211_rx_bss_hash_del(dev, bss); | 2258 | __ieee80211_rx_bss_hash_del(dev, bss); |
2256 | list_del(&bss->list); | 2259 | list_del(&bss->list); |
2257 | spin_unlock_bh(&local->sta_bss_lock); | 2260 | spin_unlock_bh(&local->sta_bss_lock); |