Skip to content

Commit 9eb8a0f

Browse files
egrumbachsmb49
authored andcommitted
wifi: mac80211: flush the station before moving it to UN-AUTHORIZED state
BugLink: https://bugs.launchpad.net/bugs/2110173 [ 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]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 25c7975 commit 9eb8a0f

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

13191319
/* notify the driver before the actual changes so it can
1320-
* fail the transition
1320+
* fail the transition if the state is increasing.
1321+
* The driver is required not to fail when the transition
1322+
* is decreasing the state, so first, do all the preparation
1323+
* work and only then, notify the driver.
13211324
*/
1322-
if (test_sta_flag(sta, WLAN_STA_INSERTED)) {
1325+
if (new_state > sta->sta_state &&
1326+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
13231327
int err = drv_sta_state(sta->local, sta->sdata, sta,
13241328
sta->sta_state, new_state);
13251329
if (err)
@@ -1395,6 +1399,16 @@ static int _sta_info_move_state(struct sta_info *sta,
13951399
break;
13961400
}
13971401

1402+
if (new_state < sta->sta_state &&
1403+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
1404+
int err = drv_sta_state(sta->local, sta->sdata, sta,
1405+
sta->sta_state, new_state);
1406+
1407+
WARN_ONCE(err,
1408+
"Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n",
1409+
err);
1410+
}
1411+
13981412
sta->sta_state = new_state;
13991413

14001414
return 0;

0 commit comments

Comments
 (0)