From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 310FB2AEF5 for ; Fri, 10 Jul 2026 01:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783647446; cv=none; b=OHQqsv1AA1HqhfhmY/hFbyW/NKcXn2tN2T7s+ZBL/I7r9TRk0SEsnejqpfA5IeaD1EVhTXUM+kjztFzmpoucFIXhQUX9suibT/oqwokMslyyR0gfCJBxDQUlU4Cq7IzLlXFM4zr7h+wdEzbAPNlIkufzAsmmdWSjXp0VM8cUvbI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783647446; c=relaxed/simple; bh=kiLYTa4fg32+kbVVyQqihotANOvIO+QWkrn6WnE2HjU=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=G+i8dvor3pQSmKTmDhdV8QNUcerH6jRQWEOa82vQ49FVBYVXNKRjIppg2E+4k9XoEtXiGsIx0hOCtNTTzlVjy8CApYZEwBCJqf1Wrh2XNSlOBTzuhG2Keuckh3BsuYvYLqGo/uneWNs973//Ee4VIMYIug59evn6gBhuwFQmCjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-7e9ee20bde0so370121a34.2 for ; Thu, 09 Jul 2026 18:37:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783647444; x=1784252244; h=content-type:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Gntw/ZliK/zq3eD+AgTkv437D94xYX8TDbEbhJ36C30=; b=NTjivF8lweyPUI56wA0OEgMnfkc2HLiBpdIGBi6cAOs0bv2nzwxc/ZfxlGW9Ro2Nj3 TmMtuhhwSzwgkXJhuDi5zF4OG09HJh4LX8XfkKMNmx7IJh+tL0VFM+AuLHPqF+/Bshq0 mRbr8/0NKV8RBk5nuwdTmLrJXYK5AZGwF4j71VmpIe+ktspObJC1WoSXRyu0Qz0NNEvZ fxCU09XalWm2i8AJosT6O/AVICO4G7YUU/87GKj7u1//HKjbZD/4If9MYOBoFXGBgNZO yPze21pP08NGLtk9jyMKb/uuaw79PHaxVHdLwg/0Mljr6iauMPpVPy8MdgMajXhLOFEp CF9A== X-Gm-Message-State: AOJu0YzN/ez0bRinILTwxLrbIV4Gns6+utJBU7Dq9bn1DrOzJ/pTSaZi Zk8wKu0jpzFDVEQ/DU2sBYR5eiSnh+TQrxlcS4lnBb+qkmEDTwpcKOAhwmGOya2g319+CgRivqL iAXLRoM9PVjCPTTb4sEkd0yyDvI+KhxO3vl4ZDvukoRux/UgFst4Yb6N1iNE= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:570e:10b0:6a3:795f:5fe0 with SMTP id 006d021491bc7-6a3795f75d8mr3156013eaf.57.1783647444165; Thu, 09 Jul 2026 18:37:24 -0700 (PDT) Date: Thu, 09 Jul 2026 18:37:24 -0700 In-Reply-To: <6a4fcd58.a1ad617e.25832.000e.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a504cd4.c76b52dc.2a15e.0003.GAE@google.com> Subject: Forwarded: [PATCH] wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci Syzkaller reported a KASAN slab-out-of-bounds read in skip_ie() and a fortify memcpy panic in cfg80211_sme_get_conn_ies(). 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. Add cfg80211_validate_ies() which walks the buffer and verifies every element has at least 2 bytes (type + length) and sufficient data bytes as indicated by its length field. Return -EINVAL if validation fails. Reported-by: syzbot+cc867e537e4bd36f69bb@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=cc867e537e4bd36f69bb Signed-off-by: Deepanshu Kartikey --- include/net/cfg80211.h | 1 + net/wireless/util.c | 16 ++++++++++++++++ net/wireless/wext-sme.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8188ad200de5..32cef926f8a4 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -10992,4 +10992,5 @@ void cfg80211_incumbent_signal_notify(struct wiphy *wiphy, u32 signal_interference_bitmap, gfp_t gfp); +bool cfg80211_validate_ies(const u8 *ies, size_t ies_len); #endif /* __NET_CFG80211_H */ diff --git a/net/wireless/util.c b/net/wireless/util.c index 24527bf321b2..a685020c8efc 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -3083,3 +3083,19 @@ bool cfg80211_wdev_channel_allowed(struct wireless_dev *wdev, return false; } EXPORT_SYMBOL(cfg80211_wdev_channel_allowed); + +bool cfg80211_validate_ies(const u8 *ies, size_t ies_len) +{ + size_t pos = 0; + + while (pos < ies_len) { + if (pos + 2 > ies_len) + return false; + if (pos + 2 + ies[pos + 1] > ies_len) + return false; + pos += 2 + ies[pos + 1]; + } + + return true; +} +EXPORT_SYMBOL(cfg80211_validate_ies); diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c index 573b6b15a446..3e9b071f6d66 100644 --- a/net/wireless/wext-sme.c +++ b/net/wireless/wext-sme.c @@ -319,6 +319,8 @@ int cfg80211_wext_siwgenie(struct net_device *dev, return 0; if (ie_len) { + if (!cfg80211_validate_ies(extra, ie_len)) + return -EINVAL; ie = kmemdup(extra, ie_len, GFP_KERNEL); if (!ie) return -ENOMEM; -- 2.43.0