History

wifi: mac80211: fix use-after-free in chanctx code

In ieee80211_vif_use_reserved_context(), when we have an old context and the new context's replace_state is set to IEEE80211_CHANCTX_REPLACE_NONE, we free the old context in ieee80211_vif_use_reserved_reassign(). Therefore, we cannot check the old_ctx anymore, so we should set it to NULL after this point. However, since the new_ctx replace state is clearly not IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do anything else in this function and can just return to avoid accessing the freed old_ctx.

Johannes Berg committed 4 years ago

Commit 2965c4c1 parent 7711fe71 file · +2 −5Browse files

Unified · Split

net/mac80211/chan.c+2−5
@@ -1749,12 +1749,9 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata) · 1748 unmodified lines
17491749
17501750 if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {
17511751 if (old_ctx)
1752− err = ieee80211_vif_use_reserved_reassign(sdata);
1753− else
1754− err = ieee80211_vif_use_reserved_assign(sdata);
1752+ return ieee80211_vif_use_reserved_reassign(sdata);
17551753
1756− if (err)
1757− return err;
1754+ return ieee80211_vif_use_reserved_assign(sdata);
17581755 }
17591756
17601757 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t