Skip to content

Commit 42e4450

Browse files
jmberg-intelgregkh
authored andcommitted
nl80211: fix beacon head validation
commit 9a6847b upstream. 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: syzbot+72b99dcf4607e8c770f3@syzkaller.appspotmail.com Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Fixes: 1d47f11 ("nl80211: correctly validate S1G beacon head") Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://lore.kernel.org/r/20210408154518.d9b06d39b4ee.Iff908997b2a4067e8d456b3cb96cab9771d252b8@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 81692c6 commit 42e4450

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎net/wireless/nl80211.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ 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-
bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
213212
unsigned int fixedlen, hdrlen;
213+
bool s1g_bcn;
214214

215+
if (len < offsetofend(typeof(*mgmt), frame_control))
216+
goto err;
217+
218+
s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control);
215219
if (s1g_bcn) {
216220
fixedlen = offsetof(struct ieee80211_ext,
217221
u.s1g_beacon.variable);

0 commit comments

Comments
 (0)