Commit 1d47f119 authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg

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: default avatarThomas Pedersen <thomas@adapt-ip.com>
Link: https://lore.kernel.org/r/20200908190323.15814-5-thomas@adapt-ip.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 68dbad8c
...@@ -209,14 +209,23 @@ static int validate_beacon_head(const struct nlattr *attr, ...@@ -209,14 +209,23 @@ static int validate_beacon_head(const struct nlattr *attr,
unsigned int len = nla_len(attr); unsigned int len = nla_len(attr);
const struct element *elem; const struct element *elem;
const struct ieee80211_mgmt *mgmt = (void *)data; const struct ieee80211_mgmt *mgmt = (void *)data;
unsigned int fixedlen = offsetof(struct ieee80211_mgmt, bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
unsigned int fixedlen, hdrlen;
if (s1g_bcn) {
fixedlen = offsetof(struct ieee80211_ext,
u.s1g_beacon.variable);
hdrlen = offsetof(struct ieee80211_ext, u.s1g_beacon);
} else {
fixedlen = offsetof(struct ieee80211_mgmt,
u.beacon.variable); u.beacon.variable);
hdrlen = offsetof(struct ieee80211_mgmt, u.beacon);
}
if (len < fixedlen) if (len < fixedlen)
goto err; goto err;
if (ieee80211_hdrlen(mgmt->frame_control) != if (ieee80211_hdrlen(mgmt->frame_control) != hdrlen)
offsetof(struct ieee80211_mgmt, u.beacon))
goto err; goto err;
data += fixedlen; data += fixedlen;
......
...@@ -399,6 +399,11 @@ unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc) ...@@ -399,6 +399,11 @@ unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc)
{ {
unsigned int hdrlen = 24; unsigned int hdrlen = 24;
if (ieee80211_is_ext(fc)) {
hdrlen = 4;
goto out;
}
if (ieee80211_is_data(fc)) { if (ieee80211_is_data(fc)) {
if (ieee80211_has_a4(fc)) if (ieee80211_has_a4(fc))
hdrlen = 30; hdrlen = 30;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment