From nobody Sat Jul 25 23:41:45 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 4A7AF2EBBB7 for ; Sat, 11 Jul 2026 07:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783754020; cv=none; b=VeEqav89rhNOUM2Pshtp4J61UXM5PMKuIlBbW2nrkwZI7uJ3Xq25MWiIsfk28qi/gpqI+WkBRrKRYGkNyYLCeX0ydTiLEgzffdw459eLoVCg2V3rSD9bnD1MAB8A9DF4+ssOhvFvaxSYCOyYtuFoob3G12QMrkEeYb8y+TZNs70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783754020; c=relaxed/simple; bh=l1nTEnW4tyVLMirJ9chs6xy2eJk5XwYVLCldUleOk3s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EbT/Kp9Ng9tv49+tXACRO0X83kSPca+zc4wsmLTVJxp0wkKcwIWB0bm6ZBi3soJMigQ3Si7d/woMu8akzBHHoiDnIs5zs5ieuduOg1xt5TMIA49zUGPnhQ/Aam8dvlfXoC0pRtIBCehs6zpJ26R8+pm1575XEa2y5/BYe1WRPgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=jzIllUFW; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="jzIllUFW" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493bc8fda98so9737605e9.0 for ; Sat, 11 Jul 2026 00:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1783754017; x=1784358817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=uMdRysv21XDV5wd6Qo9vGpr0v0YkiSkKSKqPPMpdIJo=; b=jzIllUFWy6DEXeh9nBq7AxK+Jh2qaQ8+4z0zUEjnyZRWxtne/2BUaj0yEzeo3uLyo0 x+GKq+asIUC7PXZoFCGAf8OpfTczZ/QYaawStRSyvLq7qGMw32B9w63GeIwgHZtm9zyy Kr15x7uBVXhNI+I+cBy9Ysy1qesFXV66k9UYpBngev7/rWXsdNDH6plKfqTKsoq8e1V6 S2oHjusZmNdfXhx/xH83CVgHNCL92/0YesS9ewLKpUQ1EXx7cxqlXkIWHoJAcLlNQhwf I0wRfuQ4bb13C8RVlDIvJiorwRutKcAwOI1G0dw5dHrWtxM3qkap9dtxxKC34Tws2wma FFXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783754017; x=1784358817; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uMdRysv21XDV5wd6Qo9vGpr0v0YkiSkKSKqPPMpdIJo=; b=hFJgcAac2U36J4lAyfcvMmqRNAMNF7viXe8L5jba1jjlXa2FdzQKm/mFFlKQ77+/hI PQg1VorWhwamhYvUmO1GHWggjw7sTJnTx1UblaalPSKx0LUNliklT9sKpSRh/vVlPdu/ qX8zWzAfyjG3yc/3PWT3UHQ4+TPxkB22NRehlS+T3NLa4JIUjzEEZD7cvNFFMYJn8JW1 fD5V642trvytuyd1mRIbK/rlXi8JYE0m56yWuOOKc3s/Ou7h3kR5Bkqd9JOQr0o68J84 9Wczfy0qrftX753bInPrZM360J1OLcsMigAUYQw4m4NIHaxGDqXpjD34WRUcb/+e2vD3 0n6Q== X-Forwarded-Encrypted: i=1; AHgh+RoSVUkkY3KXuoAIRYWYQy9Z8h3yrxckQ/OFG/bhXGzy4jal+SMx2DW0gq9BOtevslkPRGrB7lOaBossduY=@vger.kernel.org X-Gm-Message-State: AOJu0YyMC5d9toSJpSk8+9Q/0XYehF2qu+GqCOVBhospkd4GsgWPEejk 3KA+xrbaYdAohyQdJmMbieC/VFFCfKHMwTBr5czJv7uQYPQXpO02ALDwaYvCwClFPF/0jTWCasw EfdE5NgS5 X-Gm-Gg: AfdE7clANj2pQamM81DONtLYamKa5THsUYHnLIue7/ZkJRcLWXB3+/v6kYTv+PpeAuD +7wtTZCXJOlwdesbZLez7ttCkfBVeG/N5eMO5a9NpMkApmd/+m32I3HQ4ttSvuODoRZ5iUW3BLl S1S+zG6pPPXGrz7k9zMTEqF7NhBceDGiC7Kpgdo58tiOdtq1GdbQ8KYskQtiaN8QvnSHzA74Zf5 DmSOx2NTIMd//Sc9c8sK2zBK6qKc75kjRO/neJmL1u3lpwp1E/6NmLHhqZO18KtRvywwRmBqFs0 +hVCFFzC/bTJhh05Y9tqYhVbfdFyHvqQmc3YSAPGT9Cn5CpptCMgGAXtI4XDa48Q9ajYI+FWnJj AK69PKDdr+y2w4CtTFNpGfsDI+VBYVwmklL6yDAOAEN2NvBjBblLh3DF2FTeBfkJGFBYs2XTDjQ xnRp1VjoDa/xyQIrDGH6W23v1y5IPB4sMF8bXFy5JXVR53LuPcmtlSRRr4px6POYFaREeGVHAxM KPUdsdOHBZQ0ijHoErvS3hXswMQt0xYIlw= X-Received: by 2002:a05:600c:6387:b0:492:7142:f46e with SMTP id 5b1f17b1804b1-493f87d8583mr17156215e9.2.1783754016569; Sat, 11 Jul 2026 00:13:36 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.188]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493eb6f373csm324565475e9.14.2026.07.11.00.13.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 11 Jul 2026 00:13:36 -0700 (PDT) From: Doruk Tan Ozturk To: Brian Norris Cc: Francesco Dolcini , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] wifi: mwifiex: bound the pairwise-cipher OUI walk to the IE length Date: Sat, 11 Jul 2026 09:13:34 +0200 Message-ID: <20260711071334.58307-1-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mwifiex_search_oui_in_ie() reads the pairwise-cipher (PTK) count from a beacon/probe-response RSN or WPA information element: count =3D iebody->ptk_cnt[0]; and then walks "count" 4-byte OUIs from the element, comparing each with memcmp(). The count byte comes straight from the (attacker-supplied) IE and is never checked against the element's own length. The callers admit the element on element_id alone (has_ieee_hdr() / has_vendor_hdr(), no length check), so a crafted RSN/WPA IE with a large pairwise count makes the walk read up to 255 * 4 bytes past the element -- an out-of-bounds read of the kmemdup()'d beacon buffer, reachable from any AP whose beacon/probe response is processed during scan result parsing. Pass the number of available IE bytes to the walk and reject a count whose OUI list would not fit, keeping the loop within the element. Found by 0sec (https://0sec.ai) using automated source analysis; the unbounded count-driven walk is evident from source. Compile-tested. Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex= driver") Cc: stable@vger.kernel.org Assisted-by: 0sec:claude-opus-4-8 Signed-off-by: Doruk Tan Ozturk --- drivers/net/wireless/marvell/mwifiex/scan.c | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wire= less/marvell/mwifiex/scan.c index 97c0ec3b822e..3a55fc6f1b54 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -104,12 +104,21 @@ has_vendor_hdr(struct ieee_types_vendor_specific *ie,= u8 key) * a given oui in PTK. */ static u8 -mwifiex_search_oui_in_ie(struct ie_body *iebody, u8 *oui) +mwifiex_search_oui_in_ie(struct ie_body *iebody, u8 *oui, int ie_len) { u8 count; =20 + /* Need grp_key_oui[4] + ptk_cnt[2] before reading the OUI count. */ + if (ie_len < (int)offsetof(struct ie_body, ptk_body)) + return MWIFIEX_OUI_NOT_PRESENT; + count =3D iebody->ptk_cnt[0]; =20 + /* Reject an OUI count whose list would run past the element. */ + if (offsetof(struct ie_body, ptk_body) + + count * sizeof(iebody->ptk_body) > (size_t)ie_len) + return MWIFIEX_OUI_NOT_PRESENT; + /* There could be multiple OUIs for PTK hence 1) Take the length. 2) Check all the OUIs for AES. @@ -143,11 +152,14 @@ mwifiex_is_rsn_oui_present(struct mwifiex_bssdescript= or *bss_desc, u32 cipher) u8 ret =3D MWIFIEX_OUI_NOT_PRESENT; =20 if (has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) { + int ie_len =3D (int)bss_desc->bcn_rsn_ie->ieee_hdr.len - + RSN_GTK_OUI_OFFSET; + iebody =3D (struct ie_body *) (((u8 *) bss_desc->bcn_rsn_ie->data) + RSN_GTK_OUI_OFFSET); oui =3D &mwifiex_rsn_oui[cipher][0]; - ret =3D mwifiex_search_oui_in_ie(iebody, oui); + ret =3D mwifiex_search_oui_in_ie(iebody, oui, ie_len); if (ret) return ret; } @@ -169,10 +181,14 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescript= or *bss_desc, u32 cipher) u8 ret =3D MWIFIEX_OUI_NOT_PRESENT; =20 if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) { + int ie_len =3D (int)bss_desc->bcn_wpa_ie->vend_hdr.len - + (int)sizeof(bss_desc->bcn_wpa_ie->vend_hdr.oui) - + WPA_GTK_OUI_OFFSET; + iebody =3D (struct ie_body *)((u8 *)bss_desc->bcn_wpa_ie->data + WPA_GTK_OUI_OFFSET); oui =3D &mwifiex_wpa_oui[cipher][0]; - ret =3D mwifiex_search_oui_in_ie(iebody, oui); + ret =3D mwifiex_search_oui_in_ie(iebody, oui, ie_len); if (ret) return ret; } --=20 2.43.0