]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()
authorDeepanshu Kartikey <kartikey406@gmail.com>
Sat, 25 Jul 2026 14:20:28 +0000 (19:50 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 28 Jul 2026 13:07:18 +0000 (15:07 +0200)
The KASAN allocation trace shows that a malformed IE buffer is
stored via SIOCSIWGENIE (cfg80211_wext_siwgenie()) without any
validation. The crash trace shows that a subsequent SIOCSIWESSID
triggers a connection attempt which calls cfg80211_sme_get_conn_ies()
to process the stored IE buffer, causing:

 - An out-of-bounds read in skip_ie() which reads ies[pos+1]
   (the length byte) past the end of the 1-byte buffer.

 - An integer underflow in the memcpy size argument when offs
   returned by ieee80211_ie_split() exceeds ies_len, causing
   unsigned subtraction to wrap to SIZE_MAX and triggering a
   fortify panic.

Fix this by validating the IE buffer in cfg80211_wext_siwgenie()
before storing it.

Reported-by: syzbot+cc867e537e4bd36f69bb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=cc867e537e4bd36f69bb
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Link: https://patch.msgid.link/20260725142028.32560-1-kartikey406@gmail.com
[drop unnecessary ie_len check, update commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/wext-sme.c

index 573b6b15a446ec4825f5cecc612a964640e62ff4..b5914f3658db46c9f96875ed798e281a7b74f043 100644 (file)
@@ -319,6 +319,15 @@ int cfg80211_wext_siwgenie(struct net_device *dev,
                return 0;
 
        if (ie_len) {
+               const struct element *elem;
+
+               for_each_element(elem, extra, ie_len) {
+                       /* nothing */
+               }
+
+               if (!for_each_element_completed(elem, extra, ie_len))
+                       return -EINVAL;
+
                ie = kmemdup(extra, ie_len, GFP_KERNEL);
                if (!ie)
                        return -ENOMEM;