aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/sta_info.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-05-27 10:32:27 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-06-23 05:05:25 -0400
commit5ac2e35030113ed881ce9ad413d80f13ffe5b5a0 (patch)
tree81533719d9cf8b661c8eaf34ba69cce511cbc239 /net/mac80211/sta_info.h
parent20edb50e593dca7522b4f3a95b801dbf99f24c52 (diff)
mac80211: fix station/driver powersave race
It is currently possible to have a race due to the station PS unblock work like this: * station goes to sleep with frames buffered in the driver * driver blocks wakeup * station wakes up again * driver flushes/returns frames, and unblocks, which schedules the unblock work * unblock work starts to run, and checks that the station is awake (i.e. that the WLAN_STA_PS_STA flag isn't set) * we process a received frame with PM=1, setting the flag again * ieee80211_sta_ps_deliver_wakeup() runs, delivering all frames to the driver, and then clearing the WLAN_STA_PS_DRIVER and WLAN_STA_PS_STA flags In this scenario, mac80211 will think that the station is awake, while it really is asleep, and any TX'ed frames should be filtered by the device (it will know that the station is sleeping) but then passed to mac80211 again, which will not buffer it either as it thinks the station is awake, and eventually the packets will be dropped. Fix this by moving the clearing of the flags to exactly where we learn about the situation. This creates a problem of reordering, so introduce another flag indicating that delivery is being done, this new flag also queues frames and is cleared only while the spinlock is held (which the queuing code also holds) so that any concurrent delivery/TX is handled correctly. Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/sta_info.h')
-rw-r--r--net/mac80211/sta_info.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 4acc5fc402fa..dee0b645b34c 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -58,6 +58,8 @@
58 * @WLAN_STA_TOFFSET_KNOWN: toffset calculated for this station is valid. 58 * @WLAN_STA_TOFFSET_KNOWN: toffset calculated for this station is valid.
59 * @WLAN_STA_MPSP_OWNER: local STA is owner of a mesh Peer Service Period. 59 * @WLAN_STA_MPSP_OWNER: local STA is owner of a mesh Peer Service Period.
60 * @WLAN_STA_MPSP_RECIPIENT: local STA is recipient of a MPSP. 60 * @WLAN_STA_MPSP_RECIPIENT: local STA is recipient of a MPSP.
61 * @WLAN_STA_PS_DELIVER: station woke up, but we're still blocking TX
62 * until pending frames are delivered
61 */ 63 */
62enum ieee80211_sta_info_flags { 64enum ieee80211_sta_info_flags {
63 WLAN_STA_AUTH, 65 WLAN_STA_AUTH,
@@ -82,6 +84,7 @@ enum ieee80211_sta_info_flags {
82 WLAN_STA_TOFFSET_KNOWN, 84 WLAN_STA_TOFFSET_KNOWN,
83 WLAN_STA_MPSP_OWNER, 85 WLAN_STA_MPSP_OWNER,
84 WLAN_STA_MPSP_RECIPIENT, 86 WLAN_STA_MPSP_RECIPIENT,
87 WLAN_STA_PS_DELIVER,
85}; 88};
86 89
87#define ADDBA_RESP_INTERVAL HZ 90#define ADDBA_RESP_INTERVAL HZ
@@ -265,7 +268,7 @@ struct ieee80211_tx_latency_stat {
265 * @last_rx_rate_vht_nss: rx status nss of last data packet 268 * @last_rx_rate_vht_nss: rx status nss of last data packet
266 * @lock: used for locking all fields that require locking, see comments 269 * @lock: used for locking all fields that require locking, see comments
267 * in the header file. 270 * in the header file.
268 * @drv_unblock_wk: used for driver PS unblocking 271 * @drv_deliver_wk: used for delivering frames after driver PS unblocking
269 * @listen_interval: listen interval of this station, when we're acting as AP 272 * @listen_interval: listen interval of this station, when we're acting as AP
270 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly 273 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
271 * @ps_lock: used for powersave (when mac80211 is the AP) related locking 274 * @ps_lock: used for powersave (when mac80211 is the AP) related locking
@@ -345,7 +348,7 @@ struct sta_info {
345 void *rate_ctrl_priv; 348 void *rate_ctrl_priv;
346 spinlock_t lock; 349 spinlock_t lock;
347 350
348 struct work_struct drv_unblock_wk; 351 struct work_struct drv_deliver_wk;
349 352
350 u16 listen_interval; 353 u16 listen_interval;
351 354