From nobody Sat Jul 25 16:48:57 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 8B76843F093 for ; Wed, 15 Jul 2026 18:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784141749; cv=none; b=BTalb8Etes0DozE8cwGdde5OLplupgH9pc6ramiRoG0dnq/Lh/bKEyRytZlwDNAtjfHnh6rFYqEpjuOAAlxZDmndc2vdxsuFaqixXHH4t9qgo1du+Wlv48Cs+yltiVwx2W/dH77Q1uMxpZNtJiT2XZzrZFNYHNchBGFcuVM+7RA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784141749; c=relaxed/simple; bh=7xBH/qlb9XYZQzIUvmR9CxJESOG3KhM08+kyoV4tfm4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bk4+i+L1ZLBstrz3Y/UBF/K3BVdpIkSayYJS7392pJa3mXMcorb3802y7oeioaRp8ms2THo+VBZg9mNutkYDDaOplXE0VTEZ4Ph5qY5WNak91hek5XB3P69P6Tb5t+75+f+fd0aEl0X7ar+dbcLLjUbnGsdES/vARPTgCWTfPeU= 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=RbTm8SxL; arc=none smtp.client-ip=209.85.128.50 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="RbTm8SxL" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so48996635e9.0 for ; Wed, 15 Jul 2026 11:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1784141743; x=1784746543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dBgT7C1VmTGs+SwffDnQ7vaSRKMxVj5a9hN2s5RO2E8=; b=RbTm8SxLrHDzDOaG8kAqe+wR/eKZNYM7FL8r9s6z6If0k0Dadj3qEfU7vGLjfrHkTw 06y4fodzGaZhhz7oGZ9IT1o0d3R6Rs14EDwcm/k54Hegu5ENwqEwfqmPrVNGDGF0yyWI vHfcaFwHPGOsZtYsGbP7Iz0Nk+2BAFflJHJzTZpPyjlRxqlNTlc4/Xv56QuYhDZz6EK/ iqw6VFjb71OaJMyUfuWZUBd4MJo8hzM1epxscmD3BUPTE7ENo2PRFy6J/DpI/fxZBZOb Ef2xyFMlWA0mG7ydsBwOKCX2Y7/R35vF/cCfAo/oYXbzIt6X1cl6TCZnVF62oGo5gw9l EHWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784141743; x=1784746543; h=content-transfer-encoding:mime-version:references:in-reply-to :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=dBgT7C1VmTGs+SwffDnQ7vaSRKMxVj5a9hN2s5RO2E8=; b=tIdXh3x1X2cn9UQZ86e8E234tGKow5/KUaWnMVtIJ1jm5OY8i7E+ekV9chbuAhjAJ/ sZyxCoRcAaHHwLa9NChGu19nDSkBVizmkRMNbCUCdyYDNXBtoNVemSYScZRjffiMB/6Y 1QXJRxZFrsRrkkbU3tyPN+4vdbJ1r/xYDjgMFNgTM2Y0HwUVH5w4z1mJzcB0X2yoB/Qf fQv+pxDxXkpDxza3kBj3AhThwFs0rdVhagFl3rplVeo6aCWiLVWtYfPhou1wW+pRrXR4 D/bNVPcVtakbvb09GdlQulcxiZk3pgB2qAT/4+Tl2OScbrUj7psg4Kw1/unkvPo6OR4m nQGw== X-Forwarded-Encrypted: i=1; AHgh+RrruQuUCsPMIUvz+/Bg2llfiglKlUrVKQWYUUxXHGUlHcQJsuFXugIb845G7OXePOaN0N96jEaNCfM0Fu0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6AJ8MAxxClCXiCVIu5FaNyVz+h2ODDVSGakA4oZ7RZw8qzEk0 DzLrMyPLa+TqmsT39FhVTGEshwX6l6Boj2loLakwmSfI7NUrUj78MLnHbYkVSZ7cTyJu X-Gm-Gg: AfdE7clmBd7bvgxw+ruH16/gTDYFmHBDyO9MdcbD9jd/BUyJb0UE+feugc7/GWyXTp4 B/G1daBNQW4qdwh/0+RYYJ5nzgHsi1Phkh8eVnWCCWdbk3o1MUElqMErUI0D5zWdIgr5WUm4CzR rHTUFQIP8PIuT3ae4s2kBmqiYqIOFbk6NA3fV3dWgED3kS4M8g5t+vePPOvbwhixWLGYRWAHGom Imwb38TVWI75UEN9Z29mbDMmEpf/Up7gOXCne8ODAaH2RMgSZYFU4I+BgxX7x3Izo3VottZMaJ+ w+fwlnMrLvDyAvioKSOl2DrTIVWSXrKE0sWG7VmDDt6QMvleY6pDkuzQ1IETOw53lXyQSVk26U3 r0+905iFcz7VkWXUIpvT1d/7FESDA1VQFXkIkLscaDeYjdHv5mMbPY3K50kfgbT0WUlIV8UVfcC uEx6xUPwy1GKXvYF5dh6FTIh9jhkB/F53ro4/JW4d1hClgNg3XwtcZe85WjvPPKEg8X/diG8Y4A J+IInLwOyg2Fs6FNTOVs9jXRSLS2FlIero= X-Received: by 2002:a05:600c:548a:b0:495:3f0f:d515 with SMTP id 5b1f17b1804b1-4953f0fd576mr33398805e9.36.1784141743212; Wed, 15 Jul 2026 11:55:43 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.188]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f464c89e5sm18280933f8f.34.2026.07.15.11.55.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 15 Jul 2026 11:55:42 -0700 (PDT) From: Doruk Tan Ozturk To: briannorris@chromium.org Cc: francesco@dolcini.it, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] wifi: mwifiex: bound the pairwise-cipher OUI walk to the IE length Date: Wed, 15 Jul 2026 20:55:41 +0200 Message-ID: <20260715185541.14350-1-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260711071334.58307-1-doruk@0sec.ai> References: <20260711071334.58307-1-doruk@0sec.ai> 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 automated security-research tooling (https://0sec.ai). Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex= driver") Cc: stable@vger.kernel.org Assisted-by: 0sec:multi-model Signed-off-by: Doruk Tan Ozturk --- Changes in v2 (per Francesco Dolcini's review): - store offsetof(struct ie_body, ptk_body) in a named variable (ptk_body_offset) and reuse it in both bounds checks; no functional change. - switch the Assisted-by trailer to 0sec:multi-model. 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..33ef8af0a5e1 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) { + const size_t ptk_body_offset =3D offsetof(struct ie_body, ptk_body); u8 count; =20 + /* Need grp_key_oui[4] + ptk_cnt[2] before reading the OUI count. */ + if (ie_len < (int)ptk_body_offset) + return MWIFIEX_OUI_NOT_PRESENT; + count =3D iebody->ptk_cnt[0]; =20 + /* Reject an OUI count whose list would run past the element. */ + if (ptk_body_offset + 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