Skip to content

Commit b5ac014

Browse files
committed
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: 9eaffe5 ("cfg80211: convert S1G beacon to scan results") Link: https://lore.kernel.org/r/20210408142826.f6f4525012de.I9fdeff0afdc683a6024e5ea49d2daa3cd2459d11@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent b57aa17 commit b5ac014

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/wireless/scan.c

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

23542354
if (ext) {
2355-
struct ieee80211_s1g_bcn_compat_ie *compat;
2356-
u8 *ie;
2355+
const struct ieee80211_s1g_bcn_compat_ie *compat;
2356+
const struct element *elem;
23572357

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

0 commit comments

Comments
 (0)