Skip to content

Commit dcd479e

Browse files
committed
mac80211: always wind down STA state
When (for example) an IBSS station is pre-moved to AUTHORIZED before it's inserted, and then the insertion fails, we don't clean up the fast RX/TX states that might already have been created, since we don't go through all the state transitions again on the way down. Do that, if it hasn't been done already, when the station is freed. I considered only freeing the fast TX/RX state there, but we might add more state so it's more robust to wind down the state properly. Note that we warn if the station was ever inserted, it should have been properly cleaned up in that case, and the driver will probably not like things happening out of order. Reported-by: syzbot+2e293dbd67de2836ba42@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20201009141710.7223b322a955.I95bd08b9ad0e039c034927cce0b75beea38e059b@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 9bdaf3b commit dcd479e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

net/mac80211/sta_info.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
258258
*/
259259
void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
260260
{
261+
/*
262+
* If we had used sta_info_pre_move_state() then we might not
263+
* have gone through the state transitions down again, so do
264+
* it here now (and warn if it's inserted).
265+
*
266+
* This will clear state such as fast TX/RX that may have been
267+
* allocated during state transitions.
268+
*/
269+
while (sta->sta_state > IEEE80211_STA_NONE) {
270+
int ret;
271+
272+
WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
273+
274+
ret = sta_info_move_state(sta, sta->sta_state - 1);
275+
if (WARN_ONCE(ret, "sta_info_move_state() returned %d\n", ret))
276+
break;
277+
}
278+
261279
if (sta->rate_ctrl)
262280
rate_control_free_sta(sta);
263281

0 commit comments

Comments
 (0)