Skip to content

Commit e87b8f2

Browse files
egrumbachgregkh
authored andcommitted
wifi: mac80211: flush the station before moving it to UN-AUTHORIZED state
[ Upstream commit 43e04077170799d0e6289f3e928f727e401b3d79 ] 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]>
1 parent c086320 commit e87b8f2

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

13231323
/* notify the driver before the actual changes so it can
1324-
* fail the transition
1324+
* fail the transition if the state is increasing.
1325+
* The driver is required not to fail when the transition
1326+
* is decreasing the state, so first, do all the preparation
1327+
* work and only then, notify the driver.
13251328
*/
1326-
if (test_sta_flag(sta, WLAN_STA_INSERTED)) {
1329+
if (new_state > sta->sta_state &&
1330+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
13271331
int err = drv_sta_state(sta->local, sta->sdata, sta,
13281332
sta->sta_state, new_state);
13291333
if (err)
@@ -1399,6 +1403,16 @@ static int _sta_info_move_state(struct sta_info *sta,
13991403
break;
14001404
}
14011405

1406+
if (new_state < sta->sta_state &&
1407+
test_sta_flag(sta, WLAN_STA_INSERTED)) {
1408+
int err = drv_sta_state(sta->local, sta->sdata, sta,
1409+
sta->sta_state, new_state);
1410+
1411+
WARN_ONCE(err,
1412+
"Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n",
1413+
err);
1414+
}
1415+
14021416
sta->sta_state = new_state;
14031417

14041418
return 0;

0 commit comments

Comments
 (0)