Skip to content

Commit cc1a702

Browse files
jmberg-intelgregkh
authored andcommitted
cfg80211: check S1G beacon compat element length
commit b5ac014 upstream. We need to check the length of this element so that we don't access data beyond its end. Fix that. Fixes: 9eaffe5 ("cfg80211: convert S1G beacon to scan results") Link: https://lore.kernel.org/r/20210408142826.f6f4525012de.I9fdeff0afdc683a6024e5ea49d2daa3cd2459d11@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fea5234 commit cc1a702

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎net/wireless/scan.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,14 +2351,16 @@ cfg80211_inform_single_bss_frame_data(struct wiphy *wiphy,
23512351
return NULL;
23522352

23532353
if (ext) {
2354-
struct ieee80211_s1g_bcn_compat_ie *compat;
2355-
u8 *ie;
2354+
const struct ieee80211_s1g_bcn_compat_ie *compat;
2355+
const struct element *elem;
23562356

2357-
ie = (void *)cfg80211_find_ie(WLAN_EID_S1G_BCN_COMPAT,
2358-
variable, ielen);
2359-
if (!ie)
2357+
elem = cfg80211_find_elem(WLAN_EID_S1G_BCN_COMPAT,
2358+
variable, ielen);
2359+
if (!elem)
2360+
return NULL;
2361+
if (elem->datalen < sizeof(*compat))
23602362
return NULL;
2361-
compat = (void *)(ie + 2);
2363+
compat = (void *)elem->data;
23622364
bssid = ext->u.s1g_beacon.sa;
23632365
capability = le16_to_cpu(compat->compat_info);
23642366
beacon_int = le16_to_cpu(compat->beacon_int);

0 commit comments

Comments
 (0)