diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-11-22 06:28:41 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-30 13:55:51 -0500 |
commit | 827d42c9ac91ddd728e4f4a31fefb906ef2ceff7 (patch) | |
tree | e29371d79d63d0a3ec2cb6d010b71147853fc771 | |
parent | 4253119acf412fd686ef4bd8749b5a4d70ea3a51 (diff) |
mac80211: fix spurious delBA handling
Lennert Buytenhek noticed that delBA handling in mac80211
was broken and has remotely triggerable problems, some of
which are due to some code shuffling I did that ended up
changing the order in which things were done -- this was
commit d75636ef9c1af224f1097941879d5a8db7cd04e5
Author: Johannes Berg <johannes@sipsolutions.net>
Date: Tue Feb 10 21:25:53 2009 +0100
mac80211: RX aggregation: clean up stop session
and other parts were already present in the original
commit d92684e66091c0f0101819619b315b4bb8b5bcc5
Author: Ron Rindjunsky <ron.rindjunsky@intel.com>
Date: Mon Jan 28 14:07:22 2008 +0200
mac80211: A-MPDU Tx add delBA from recipient support
The first problem is that I moved a BUG_ON before various
checks -- thereby making it possible to hit. As the comment
indicates, the BUG_ON can be removed since the ampdu_action
callback must already exist when the state is != IDLE.
The second problem isn't easily exploitable but there's a
race condition due to unconditionally setting the state to
OPERATIONAL when a delBA frame is received, even when no
aggregation session was ever initiated. All the drivers
accept stopping the session even then, but that opens a
race window where crashes could happen before the driver
accepts it. Right now, a WARN_ON may happen with non-HT
drivers, while the race opens only for HT drivers.
For this case, there are two things necessary to fix it:
1) don't process spurious delBA frames, and be more careful
about the session state; don't drop the lock
2) HT drivers need to be prepared to handle a session stop
even before the session was really started -- this is
true for all drivers (that support aggregation) but
iwlwifi which can be fixed easily. The other HT drivers
(ath9k and ar9170) are behaving properly already.
Reported-by: Lennert Buytenhek <buytenh@marvell.com>
Cc: stable@kernel.org
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-tx.c | 10 | ||||
-rw-r--r-- | include/net/mac80211.h | 6 | ||||
-rw-r--r-- | net/mac80211/agg-tx.c | 15 | ||||
-rw-r--r-- | net/mac80211/ht.c | 8 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 2 |
5 files changed, 27 insertions, 14 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index fb9bcfa6d947..b7e196e3c8d3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -1277,8 +1277,16 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid) | |||
1277 | return -ENXIO; | 1277 | return -ENXIO; |
1278 | } | 1278 | } |
1279 | 1279 | ||
1280 | if (priv->stations[sta_id].tid[tid].agg.state == | ||
1281 | IWL_EMPTYING_HW_QUEUE_ADDBA) { | ||
1282 | IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); | ||
1283 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
1284 | priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; | ||
1285 | return 0; | ||
1286 | } | ||
1287 | |||
1280 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON) | 1288 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON) |
1281 | IWL_WARN(priv, "Stopping AGG while state not IWL_AGG_ON\n"); | 1289 | IWL_WARN(priv, "Stopping AGG while state not ON or starting\n"); |
1282 | 1290 | ||
1283 | tid_data = &priv->stations[sta_id].tid[tid]; | 1291 | tid_data = &priv->stations[sta_id].tid[tid]; |
1284 | ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; | 1292 | ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index c75b960c8ac8..998c30fc8981 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -1283,6 +1283,12 @@ enum ieee80211_filter_flags { | |||
1283 | * | 1283 | * |
1284 | * These flags are used with the ampdu_action() callback in | 1284 | * These flags are used with the ampdu_action() callback in |
1285 | * &struct ieee80211_ops to indicate which action is needed. | 1285 | * &struct ieee80211_ops to indicate which action is needed. |
1286 | * | ||
1287 | * Note that drivers MUST be able to deal with a TX aggregation | ||
1288 | * session being stopped even before they OK'ed starting it by | ||
1289 | * calling ieee80211_start_tx_ba_cb(_irqsafe), because the peer | ||
1290 | * might receive the addBA frame and send a delBA right away! | ||
1291 | * | ||
1286 | * @IEEE80211_AMPDU_RX_START: start Rx aggregation | 1292 | * @IEEE80211_AMPDU_RX_START: start Rx aggregation |
1287 | * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation | 1293 | * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation |
1288 | * @IEEE80211_AMPDU_TX_START: start Tx aggregation | 1294 | * @IEEE80211_AMPDU_TX_START: start Tx aggregation |
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index 63224d1ee8dd..89e238b001de 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c | |||
@@ -123,13 +123,18 @@ void ieee80211_send_bar(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid, u1 | |||
123 | ieee80211_tx_skb(sdata, skb, 0); | 123 | ieee80211_tx_skb(sdata, skb, 0); |
124 | } | 124 | } |
125 | 125 | ||
126 | static int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | 126 | int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, |
127 | enum ieee80211_back_parties initiator) | 127 | enum ieee80211_back_parties initiator) |
128 | { | 128 | { |
129 | struct ieee80211_local *local = sta->local; | 129 | struct ieee80211_local *local = sta->local; |
130 | int ret; | 130 | int ret; |
131 | u8 *state; | 131 | u8 *state; |
132 | 132 | ||
133 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
134 | printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n", | ||
135 | sta->sta.addr, tid); | ||
136 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
137 | |||
133 | state = &sta->ampdu_mlme.tid_state_tx[tid]; | 138 | state = &sta->ampdu_mlme.tid_state_tx[tid]; |
134 | 139 | ||
135 | if (*state == HT_AGG_STATE_OPERATIONAL) | 140 | if (*state == HT_AGG_STATE_OPERATIONAL) |
@@ -143,7 +148,6 @@ static int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | |||
143 | 148 | ||
144 | /* HW shall not deny going back to legacy */ | 149 | /* HW shall not deny going back to legacy */ |
145 | if (WARN_ON(ret)) { | 150 | if (WARN_ON(ret)) { |
146 | *state = HT_AGG_STATE_OPERATIONAL; | ||
147 | /* | 151 | /* |
148 | * We may have pending packets get stuck in this case... | 152 | * We may have pending packets get stuck in this case... |
149 | * Not bothering with a workaround for now. | 153 | * Not bothering with a workaround for now. |
@@ -525,11 +529,6 @@ int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | |||
525 | goto unlock; | 529 | goto unlock; |
526 | } | 530 | } |
527 | 531 | ||
528 | #ifdef CONFIG_MAC80211_HT_DEBUG | ||
529 | printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n", | ||
530 | sta->sta.addr, tid); | ||
531 | #endif /* CONFIG_MAC80211_HT_DEBUG */ | ||
532 | |||
533 | ret = ___ieee80211_stop_tx_ba_session(sta, tid, initiator); | 532 | ret = ___ieee80211_stop_tx_ba_session(sta, tid, initiator); |
534 | 533 | ||
535 | unlock: | 534 | unlock: |
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c index 48ef1a282b91..cdc58e61d921 100644 --- a/net/mac80211/ht.c +++ b/net/mac80211/ht.c | |||
@@ -141,7 +141,6 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, | |||
141 | struct sta_info *sta, | 141 | struct sta_info *sta, |
142 | struct ieee80211_mgmt *mgmt, size_t len) | 142 | struct ieee80211_mgmt *mgmt, size_t len) |
143 | { | 143 | { |
144 | struct ieee80211_local *local = sdata->local; | ||
145 | u16 tid, params; | 144 | u16 tid, params; |
146 | u16 initiator; | 145 | u16 initiator; |
147 | 146 | ||
@@ -161,10 +160,9 @@ void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, | |||
161 | WLAN_BACK_INITIATOR, 0); | 160 | WLAN_BACK_INITIATOR, 0); |
162 | else { /* WLAN_BACK_RECIPIENT */ | 161 | else { /* WLAN_BACK_RECIPIENT */ |
163 | spin_lock_bh(&sta->lock); | 162 | spin_lock_bh(&sta->lock); |
164 | sta->ampdu_mlme.tid_state_tx[tid] = | 163 | if (sta->ampdu_mlme.tid_state_tx[tid] & HT_ADDBA_REQUESTED_MSK) |
165 | HT_AGG_STATE_OPERATIONAL; | 164 | ___ieee80211_stop_tx_ba_session(sta, tid, |
165 | WLAN_BACK_RECIPIENT); | ||
166 | spin_unlock_bh(&sta->lock); | 166 | spin_unlock_bh(&sta->lock); |
167 | ieee80211_stop_tx_ba_session(&local->hw, sta->sta.addr, tid, | ||
168 | WLAN_BACK_RECIPIENT); | ||
169 | } | 167 | } |
170 | } | 168 | } |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index a910bf1f092f..10d316e455de 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -1091,6 +1091,8 @@ void ieee80211_process_addba_request(struct ieee80211_local *local, | |||
1091 | 1091 | ||
1092 | int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | 1092 | int __ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, |
1093 | enum ieee80211_back_parties initiator); | 1093 | enum ieee80211_back_parties initiator); |
1094 | int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | ||
1095 | enum ieee80211_back_parties initiator); | ||
1094 | 1096 | ||
1095 | /* Spectrum management */ | 1097 | /* Spectrum management */ |
1096 | void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, | 1098 | void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, |