Commit b5ac0146 authored by Johannes Berg's avatar Johannes Berg
Browse files

cfg80211: check S1G beacon compat element length

We need to check the length of this element so that we don't
access data beyond its end. Fix that.

Fixes: 9eaffe50 ("cfg80211: convert S1G beacon to scan results")
Link: https://lore.kernel.org/r/20210408142826.f6f4525012de.I9fdeff0afdc683a6024e5ea49d2daa3cd2459d11@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent b57aa17f
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -2352,14 +2352,16 @@ cfg80211_inform_single_bss_frame_data(struct wiphy *wiphy,
		return NULL;

	if (ext) {
		struct ieee80211_s1g_bcn_compat_ie *compat;
		u8 *ie;
		const struct ieee80211_s1g_bcn_compat_ie *compat;
		const struct element *elem;

		ie = (void *)cfg80211_find_ie(WLAN_EID_S1G_BCN_COMPAT,
		elem = cfg80211_find_elem(WLAN_EID_S1G_BCN_COMPAT,
					  variable, ielen);
		if (!ie)
		if (!elem)
			return NULL;
		if (elem->datalen < sizeof(*compat))
			return NULL;
		compat = (void *)(ie + 2);
		compat = (void *)elem->data;
		bssid = ext->u.s1g_beacon.sa;
		capability = le16_to_cpu(compat->compat_info);
		beacon_int = le16_to_cpu(compat->beacon_int);