diff options
author | Igor Perminov <igor.perminov@inbox.ru> | 2009-08-08 17:55:18 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-14 09:13:53 -0400 |
commit | 17512dc3b7fc9ff1a60d3748ce87c323df507c3d (patch) | |
tree | 1ad4c98c3c653571552156116ce639c6e0aa2789 /drivers | |
parent | 66679a65efffffb62dc2650960b3aff758d575f9 (diff) |
rt2x00: Fix for race condition while update beacon
The patch "Implement set_tim callback for all drivers" can cause kernel
oops in rt73usb_write_beacon. The oops is caused by one of the following
race conditions:
* In case of two near calls to set_tim: rt2x00lib_beacondone_iter is
cleaning the beacon skb, whereas rt73usb_write_beacon is still using it.
* In case of two near updates of beacon: first as the result of set_tim
and second as the result of a call from an application (e.g. hostapd).
This patch fixes the race condition by rearranging the update logic and
guarding rt2x00_intf->beacon->skb with a mutex.
Signed-off-by: Igor Perminov <igor.perminov@inbox.ru>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00.h | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00dev.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00mac.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 15 |
4 files changed, 20 insertions, 8 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index e6e73be31e37..7c74c4efcb0f 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -334,6 +334,11 @@ struct rt2x00_intf { | |||
334 | u8 bssid[ETH_ALEN]; | 334 | u8 bssid[ETH_ALEN]; |
335 | 335 | ||
336 | /* | 336 | /* |
337 | * beacon->skb must be protected with the mutex. | ||
338 | */ | ||
339 | struct mutex beacon_skb_mutex; | ||
340 | |||
341 | /* | ||
337 | * Entry in the beacon queue which belongs to | 342 | * Entry in the beacon queue which belongs to |
338 | * this interface. Each interface has its own | 343 | * this interface. Each interface has its own |
339 | * dedicated beacon entry. | 344 | * dedicated beacon entry. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index e0348cc22d16..b6676c6722fc 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -186,7 +186,6 @@ static void rt2x00lib_intf_scheduled(struct work_struct *work) | |||
186 | static void rt2x00lib_beacondone_iter(void *data, u8 *mac, | 186 | static void rt2x00lib_beacondone_iter(void *data, u8 *mac, |
187 | struct ieee80211_vif *vif) | 187 | struct ieee80211_vif *vif) |
188 | { | 188 | { |
189 | struct rt2x00_dev *rt2x00dev = data; | ||
190 | struct rt2x00_intf *intf = vif_to_intf(vif); | 189 | struct rt2x00_intf *intf = vif_to_intf(vif); |
191 | 190 | ||
192 | if (vif->type != NL80211_IFTYPE_AP && | 191 | if (vif->type != NL80211_IFTYPE_AP && |
@@ -195,12 +194,6 @@ static void rt2x00lib_beacondone_iter(void *data, u8 *mac, | |||
195 | vif->type != NL80211_IFTYPE_WDS) | 194 | vif->type != NL80211_IFTYPE_WDS) |
196 | return; | 195 | return; |
197 | 196 | ||
198 | /* | ||
199 | * Clean up the beacon skb. | ||
200 | */ | ||
201 | rt2x00queue_free_skb(rt2x00dev, intf->beacon->skb); | ||
202 | intf->beacon->skb = NULL; | ||
203 | |||
204 | spin_lock(&intf->lock); | 197 | spin_lock(&intf->lock); |
205 | intf->delayed_flags |= DELAYED_UPDATE_BEACON; | 198 | intf->delayed_flags |= DELAYED_UPDATE_BEACON; |
206 | spin_unlock(&intf->lock); | 199 | spin_unlock(&intf->lock); |
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index 4164fce05987..74451f9672d9 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c | |||
@@ -274,6 +274,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw, | |||
274 | 274 | ||
275 | spin_lock_init(&intf->lock); | 275 | spin_lock_init(&intf->lock); |
276 | spin_lock_init(&intf->seqlock); | 276 | spin_lock_init(&intf->seqlock); |
277 | mutex_init(&intf->beacon_skb_mutex); | ||
277 | intf->beacon = entry; | 278 | intf->beacon = entry; |
278 | 279 | ||
279 | if (conf->type == NL80211_IFTYPE_AP) | 280 | if (conf->type == NL80211_IFTYPE_AP) |
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index e67e339d9dfd..06af823efd83 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -503,14 +503,25 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, | |||
503 | if (unlikely(!intf->beacon)) | 503 | if (unlikely(!intf->beacon)) |
504 | return -ENOBUFS; | 504 | return -ENOBUFS; |
505 | 505 | ||
506 | mutex_lock(&intf->beacon_skb_mutex); | ||
507 | |||
508 | /* | ||
509 | * Clean up the beacon skb. | ||
510 | */ | ||
511 | rt2x00queue_free_skb(rt2x00dev, intf->beacon->skb); | ||
512 | intf->beacon->skb = NULL; | ||
513 | |||
506 | if (!enable_beacon) { | 514 | if (!enable_beacon) { |
507 | rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev, QID_BEACON); | 515 | rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev, QID_BEACON); |
516 | mutex_unlock(&intf->beacon_skb_mutex); | ||
508 | return 0; | 517 | return 0; |
509 | } | 518 | } |
510 | 519 | ||
511 | intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif); | 520 | intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif); |
512 | if (!intf->beacon->skb) | 521 | if (!intf->beacon->skb) { |
522 | mutex_unlock(&intf->beacon_skb_mutex); | ||
513 | return -ENOMEM; | 523 | return -ENOMEM; |
524 | } | ||
514 | 525 | ||
515 | /* | 526 | /* |
516 | * Copy all TX descriptor information into txdesc, | 527 | * Copy all TX descriptor information into txdesc, |
@@ -548,6 +559,8 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, | |||
548 | rt2x00dev->ops->lib->write_beacon(intf->beacon); | 559 | rt2x00dev->ops->lib->write_beacon(intf->beacon); |
549 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); | 560 | rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON); |
550 | 561 | ||
562 | mutex_unlock(&intf->beacon_skb_mutex); | ||
563 | |||
551 | return 0; | 564 | return 0; |
552 | } | 565 | } |
553 | 566 | ||