]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: cfg80211: bound element ID read when checking non-inheritance
authorHE WEI (ギカク) <skyexpoc@gmail.com>
Tue, 7 Jul 2026 09:48:28 +0000 (18:48 +0900)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 7 Jul 2026 12:00:35 +0000 (14:00 +0200)
cfg80211_is_element_inherited() reads the first data octet of the
candidate element (id = elem->data[0]) to look it up in an extension
non-inheritance list. It does so after testing elem->id, but without
verifying that the element actually has a data octet. A zero-length
extension element (WLAN_EID_EXTENSION with length 0) therefore makes it
read one octet past the end of the element.

_ieee802_11_parse_elems_full() runs this check for every element of a
frame once a non-inheritance context exists -- e.g. while parsing a
per-STA profile of a Multi-Link element in a (re)association response,
or a non-transmitted BSS profile -- so a crafted frame from an AP can
trigger a one-octet slab-out-of-bounds read during element parsing:

  BUG: KASAN: slab-out-of-bounds in cfg80211_is_element_inherited
  Read of size 1 ... in net/wireless/scan.c

Return early (treat the element as inherited) when an extension element
carries no data, mirroring the existing handling of empty ID lists.

The bug was found by fuzzing ieee802_11_parse_elems_full() under KASAN.

Fixes: f7dacfb11475 ("cfg80211: support non-inheritance element")
Signed-off-by: HE WEI (ギカク) <skyexpoc@gmail.com>
Link: https://patch.msgid.link/20260707094828.16465-1-skyexpoc@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/scan.c

index 5c97b5bd5d69c4e4297cdea3f2ceab633d24ad9d..071083cc336725e2cdf01804783e35b8b6e1cee0 100644 (file)
@@ -205,7 +205,7 @@ bool cfg80211_is_element_inherited(const struct element *elem,
                return true;
 
        if (elem->id == WLAN_EID_EXTENSION) {
-               if (!ext_id_len)
+               if (!ext_id_len || !elem->datalen)
                        return true;
                loop_len = ext_id_len;
                list = &non_inherit_elem->data[3 + id_len];