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
1749 1749
1750 if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {1750 if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {
1751 if (old_ctx)1751 if (old_ctx)
1752 err = ieee80211_vif_use_reserved_reassign(sdata);1752 return ieee80211_vif_use_reserved_reassign(sdata);
1753 else
1754 err = ieee80211_vif_use_reserved_assign(sdata);
1755 1753
1756 if (err)1754 return ieee80211_vif_use_reserved_assign(sdata);
1757 return err;
1758 }1755 }
1759 1756
1760 /*1757 /*

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