Skip to content

Commit 43e0407

Browse files
egrumbachjmberg-intel
authored andcommitted
wifi: mac80211: flush the station before moving it to UN-AUTHORIZED state
We first want to flush the station to make sure we no longer have any frames being Tx by the station before the station is moved to un-authorized state. Failing to do that will lead to races: a frame may be sent after the station's state has been changed. Since the API clearly states that the driver can't fail the sta_state() transition down the list of state, we can easily flush the station first, and only then call the driver's sta_state(). Signed-off-by: Emmanuel Grumbach <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20250306123626.450bc40e8b04.I636ba96843c77f13309c15c9fd6eb0c5a52a7976@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 1801a94 commit 43e0407

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

net/mac80211/sta_info.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright 2006-2007 Jiri Benc <[email protected]>
55
* Copyright 2013-2014 Intel Mobile Communications GmbH
66
* Copyright (C) 2015 - 2017 Intel Deutschland GmbH
7-
* Copyright (C) 2018-2023 Intel Corporation
7+
* Copyright (C) 2018-2024 Intel Corporation
88
*/
99

1010
#include <linux/module.h>
@@ -1335,9 +1335,13 @@ static int _sta_info_move_state(struct sta_info *sta,
13351335
sta->sta.addr, new_state);
13361336

13371337
/* notify the driver before the actual changes so it can
1338-
* fail the transition
1338+
* fail the transition if the state is increasing.
1339+
* The driver is required not to fail when the transition
1340+
* is decreasing the state, so first, do all the preparation
1341+
* work and only then, notify the driver.
13391342
*/
1340-
if (test_sta_flag(sta, WLAN_STA_INSERTED)) {
1343+
if (new_state > sta->sta_state &&
1344+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
13411345
int err = drv_sta_state(sta->local, sta->sdata, sta,
13421346
sta->sta_state, new_state);
13431347
if (err)
@@ -1413,6 +1417,16 @@ static int _sta_info_move_state(struct sta_info *sta,
14131417
break;
14141418
}
14151419

1420+
if (new_state < sta->sta_state &&
1421+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
1422+
int err = drv_sta_state(sta->local, sta->sdata, sta,
1423+
sta->sta_state, new_state);
1424+
1425+
WARN_ONCE(err,
1426+
"Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n",
1427+
err);
1428+
}
1429+
14161430
sta->sta_state = new_state;
14171431

14181432
return 0;

0 commit comments

Comments
 (0)