Skip to content

Commit 02654ee

Browse files
egrumbachopsiff
authored andcommitted
wifi: mac80211: flush the station before moving it to UN-AUTHORIZED state
[ Upstream commit 43e0407 ] 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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit e87b8f2)
1 parent 588c334 commit 02654ee

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>
@@ -1329,9 +1329,13 @@ static int _sta_info_move_state(struct sta_info *sta,
13291329
sta->sta.addr, new_state);
13301330

13311331
/* notify the driver before the actual changes so it can
1332-
* fail the transition
1332+
* fail the transition if the state is increasing.
1333+
* The driver is required not to fail when the transition
1334+
* is decreasing the state, so first, do all the preparation
1335+
* work and only then, notify the driver.
13331336
*/
1334-
if (test_sta_flag(sta, WLAN_STA_INSERTED)) {
1337+
if (new_state > sta->sta_state &&
1338+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
13351339
int err = drv_sta_state(sta->local, sta->sdata, sta,
13361340
sta->sta_state, new_state);
13371341
if (err)
@@ -1407,6 +1411,16 @@ static int _sta_info_move_state(struct sta_info *sta,
14071411
break;
14081412
}
14091413

1414+
if (new_state < sta->sta_state &&
1415+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
1416+
int err = drv_sta_state(sta->local, sta->sdata, sta,
1417+
sta->sta_state, new_state);
1418+
1419+
WARN_ONCE(err,
1420+
"Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n",
1421+
err);
1422+
}
1423+
14101424
sta->sta_state = new_state;
14111425

14121426
return 0;

0 commit comments

Comments
 (0)