Skip to content

Commit 1d47f11

Browse files
twpedersenjmberg-intel
authored andcommitted
nl80211: correctly validate S1G beacon head
The S1G beacon has a different header size than regular beacons, so adjust the beacon head validator. Signed-off-by: Thomas Pedersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 68dbad8 commit 1d47f11

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

net/wireless/nl80211.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,23 @@ static int validate_beacon_head(const struct nlattr *attr,
209209
unsigned int len = nla_len(attr);
210210
const struct element *elem;
211211
const struct ieee80211_mgmt *mgmt = (void *)data;
212-
unsigned int fixedlen = offsetof(struct ieee80211_mgmt,
213-
u.beacon.variable);
212+
bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
213+
unsigned int fixedlen, hdrlen;
214+
215+
if (s1g_bcn) {
216+
fixedlen = offsetof(struct ieee80211_ext,
217+
u.s1g_beacon.variable);
218+
hdrlen = offsetof(struct ieee80211_ext, u.s1g_beacon);
219+
} else {
220+
fixedlen = offsetof(struct ieee80211_mgmt,
221+
u.beacon.variable);
222+
hdrlen = offsetof(struct ieee80211_mgmt, u.beacon);
223+
}
214224

215225
if (len < fixedlen)
216226
goto err;
217227

218-
if (ieee80211_hdrlen(mgmt->frame_control) !=
219-
offsetof(struct ieee80211_mgmt, u.beacon))
228+
if (ieee80211_hdrlen(mgmt->frame_control) != hdrlen)
220229
goto err;
221230

222231
data += fixedlen;

net/wireless/util.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc)
399399
{
400400
unsigned int hdrlen = 24;
401401

402+
if (ieee80211_is_ext(fc)) {
403+
hdrlen = 4;
404+
goto out;
405+
}
406+
402407
if (ieee80211_is_data(fc)) {
403408
if (ieee80211_has_a4(fc))
404409
hdrlen = 30;

0 commit comments

Comments
 (0)