Commit 8329e7b6 authored by Johannes Berg's avatar Johannes Berg Committed by Xiangwei Li
Browse files

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

stable inclusion
from stable-v4.19.247
commit 9f1e5cc85ad77e52f54049a94db0407445ae2a34
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP3RV
CVE: CVE-2022-49416

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9f1e5cc85ad77e52f54049a94db0407445ae2a34



--------------------------------

commit 2965c4cd upstream.

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.

Cc: stable@vger.kernel.org
Fixes: 5bcae31d ("mac80211: implement multi-vif in-place reservations")
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarXiangwei Li <liwei728@huawei.com>
parent d734d6bb
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -1638,12 +1638,9 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata)

	if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {
		if (old_ctx)
			err = ieee80211_vif_use_reserved_reassign(sdata);
		else
			err = ieee80211_vif_use_reserved_assign(sdata);
			return ieee80211_vif_use_reserved_reassign(sdata);

		if (err)
			return err;
		return ieee80211_vif_use_reserved_assign(sdata);
	}

	/*