Skip to content

Commit 9a6847b

Browse files
committed
nl80211: fix beacon head validation
If the beacon head attribute (NL80211_ATTR_BEACON_HEAD) is too short to even contain the frame control field, we access uninitialized data beyond the buffer. Fix this by checking the minimal required size first. We used to do this until S1G support was added, where the fixed data portion has a different size. Reported-and-tested-by: [email protected] Suggested-by: Eric Dumazet <[email protected]> Fixes: 1d47f11 ("nl80211: correctly validate S1G beacon head") Signed-off-by: Johannes Berg <[email protected]> Link: https://lore.kernel.org/r/20210408154518.d9b06d39b4ee.Iff908997b2a4067e8d456b3cb96cab9771d252b8@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent abaf94e commit 9a6847b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/wireless/nl80211.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,13 @@ static int validate_beacon_head(const struct nlattr *attr,
229229
unsigned int len = nla_len(attr);
230230
const struct element *elem;
231231
const struct ieee80211_mgmt *mgmt = (void *)data;
232-
bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
233232
unsigned int fixedlen, hdrlen;
233+
bool s1g_bcn;
234234

235+
if (len < offsetofend(typeof(*mgmt), frame_control))
236+
goto err;
237+
238+
s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
235239
if (s1g_bcn) {
236240
fixedlen = offsetof(struct ieee80211_ext,
237241
u.s1g_beacon.variable);

0 commit comments

Comments
 (0)