wifi: mac80211: fix MBSSID parsing use-after-free
authorJohannes Berg <johannes.berg@intel.com>
Wed, 28 Sep 2022 20:07:15 +0000 (22:07 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 10 Oct 2022 07:50:23 +0000 (09:50 +0200)
commitff05d4b45dd89b922578dac497dcabf57cf771c6
treeb67ee15aea80b40cc40d2d76058b744deb3b080c
parent8f033d2becc24aa6bfd2a5c104407963560caabc
wifi: mac80211: fix MBSSID parsing use-after-free

When we parse a multi-BSSID element, we might point some
element pointers into the allocated nontransmitted_profile.
However, we free this before returning, causing UAF when the
relevant pointers in the parsed elements are accessed.

Fix this by not allocating the scratch buffer separately but
as part of the returned structure instead, that way, there
are no lifetime issues with it.

The scratch buffer introduction as part of the returned data
here is taken from MLO feature work done by Ilan.

This fixes CVE-2022-42719.

Fixes: 5023b14cf4df ("mac80211: support profile split between elements")
Co-developed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/util.c