From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 154DA377034 for ; Tue, 11 Aug 2026 23:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786489676; cv=none; b=iXTMW4rSnyTRqFjR7KGLTj77ZueN//HO0J7tKAxXRmf17z8yFfqv0/YS8M6kYjA0G6iIo279Lz+1Xw8XwetKZ+0LjZt5IJJ8bsKmX6tnSvDE3kHc4Dtpm46hTH5QCQb28q4i8CQJrgr0qGwByJX9QpOBywS+GLyFxRuM3cLsivU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786489676; c=relaxed/simple; bh=hZ2+doldLFi5Or3oJGS1Q6/v0N2AdkGLlj5306iVrjg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Pn/+3hZ5wv5aml9QyLqSdTyvC4BmmiaGEYxIzyG6uy6+eBJ/TvgGAE975CLkEgryQ5AZ0HSpqLB0kkZazcXSwd1tRlrs4HjUTHBw/cv9l0cXOxcRdk0r9hGSQmI7Y3Omi0qfxYcfSPgm3HTPwEOPwTHZIL1RVcyWy4sXumqImHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=MYBMZwAp; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MYBMZwAp" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2d01663d816so4235175ad.1 for ; Tue, 11 Aug 2026 16:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1786489673; x=1787094473; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MxdgMqtF68s+a8E8Ijlw0yd5ACEIUeoM0nOyAFFalno=; b=MYBMZwApurV4XG5Ul0gir32r3Dx/WyXhWSDX4oznjbHqAWu1KzuD2wheJtxHR44hB2 NDMkpbs0nahalEFPMC7ZGsTJfKNWNx+mopugFiGJvPFR1Hiyntrwvj5PeOLdJzIYdPid QBHajW8lvzt7VbpuYbXfbDXWWuhaW5JedwqE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786489673; x=1787094473; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MxdgMqtF68s+a8E8Ijlw0yd5ACEIUeoM0nOyAFFalno=; b=hLYRVwFk2ScYTwv7cqNNwEQUHFQcdMkMWz4oZDKHKY3bfxI++8xa6Ov0S/DUGMcKJ4 u1GQD6ZA4dEwXTjzozDJ19UipHCTBhqavJu0NesQ5fyID/777O8mSVhu4bY5bJpoTiHy Or6l4I0irjoG2Psq/5vU8bjYxaNt7wPBlTZInKsRe6gsQJWXoq/XN/TYFvnjioTA7zIP bI7sKHnVLrJ+wgwrXVtwnV1i11ytVjvBhC/iLhII+8mkps15iam2IdXwyFqSyAj6q9ek iSWdUeOwmuiFZGsQUyhTFdRUTHuGt9zZGl7Z764vT40t39EV2uHQMvRFpYQnwIueLYPZ ZkbQ== X-Forwarded-Encrypted: i=1; AHgh+Ro6H+ukU5VJoigf82+sGV6/shT4kYvrYn688EIXqZ/46KSgantfq6PdN66Lku+60Bqf4HK9ALYYVks/oBg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1oyvF47YNmVN4okvtYfHoC4Fz7tPl/IQcMBSfQ0SnFu5+id1C 2BRhGNIc5LVJZ/kXm+gMdJ9K7UtZPb/jZ5rKjZzp8uhzeUev7fyooXl8ONdFWJZ/MQ== X-Gm-Gg: AR+sD10kZ9Hnwwu9NXSKQ8JqyIzV3x7QUsfu0fLPtb97qorkOgSSI3s0fHHCM9dcsvn vrq72I2bNsjyK9rBXpJgV3+2D2DK9p1MCd6jMLY0pW0/O9M6OG9EPwf1Q26+DbGYVyWjEiID0KJ qN5naisxViyyaA7RfFPevuoUy8rILw71UoUBD1N1+RfyFl2pi46PrR2Tya6GfOy/OAT/Qg7pNaG 9pxG37tQuyQwB6I+PQ2Lc+vSuv7Aw8PhsXuCMaUZogw9Z/QieTQRMPz856l1GxPk/Hda6THHAoJ NdKcbjz3mJ9YrOPjzBj0UVkvEUVGdPsmNWOFRty5/6ElxbD2sxcqc/VcPTXgrodwAjpCj7InXf/ hZJAvTTL3996g/7SAewMGxBIljmwKijbXZaAuTfHh5ISvpytM3bF9C0/CV7w+VcQ7KInp1xE4AV 04AMqc8sHrPJWdRQSksyThpFPo3g22reF6qnWySwv4OzoIUiYrH57bJiTLky9n4lOYxuWMwoJdQ KzO7kqSbwj9cGthvwVrAWXmRqU= X-Received: by 2002:a17:90a:ec8e:b0:38e:250b:122f with SMTP id 98e67ed59e1d1-3930162a6cemr543682a91.16.1786489673385; Tue, 11 Aug 2026 16:07:53 -0700 (PDT) Received: from localhost ([2a00:79e0:2e7c:8:79fa:d268:80cb:4947]) by smtp.gmail.com with UTF8SMTPSA id a92af1059eb24-141245540fesm5012264c88.9.2026.08.11.16.07.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 16:07:52 -0700 (PDT) Date: Tue, 11 Aug 2026 16:07:50 -0700 From: Brian Norris To: Doruk Tan Ozturk Cc: francesco@dolcini.it, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] wifi: mwifiex: bound the pairwise-cipher OUI walk to the IE length Message-ID: References: <20260711071334.58307-1-doruk@0sec.ai> <20260715185541.14350-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260715185541.14350-1-doruk@0sec.ai> Hi, On Wed, Jul 15, 2026 at 08:55:41PM +0200, Doruk Tan Ozturk wrote: > mwifiex_search_oui_in_ie() reads the pairwise-cipher (PTK) count from a > beacon/probe-response RSN or WPA information element: > > count = 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/wireless/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 = offsetof(struct ie_body, ptk_body); > u8 count; > > + /* 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 = iebody->ptk_cnt[0]; > > + /* 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_bssdescriptor *bss_desc, u32 cipher) > u8 ret = MWIFIEX_OUI_NOT_PRESENT; > > if (has_ieee_hdr(bss_desc->bcn_rsn_ie, WLAN_EID_RSN)) { > + int ie_len = (int)bss_desc->bcn_rsn_ie->ieee_hdr.len - > + RSN_GTK_OUI_OFFSET; Are you ensuring you don't underflow when computing ie_len here? What if bss_desc->bcn_rsn_ie->ieee_hdr.len is small / zero? > + > iebody = (struct ie_body *) > (((u8 *) bss_desc->bcn_rsn_ie->data) + > RSN_GTK_OUI_OFFSET); > oui = &mwifiex_rsn_oui[cipher][0]; > - ret = mwifiex_search_oui_in_ie(iebody, oui); > + ret = mwifiex_search_oui_in_ie(iebody, oui, ie_len); > if (ret) > return ret; > } > @@ -169,10 +181,14 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher) > u8 ret = MWIFIEX_OUI_NOT_PRESENT; > > if (has_vendor_hdr(bss_desc->bcn_wpa_ie, WLAN_EID_VENDOR_SPECIFIC)) { > + int ie_len = (int)bss_desc->bcn_wpa_ie->vend_hdr.len - > + (int)sizeof(bss_desc->bcn_wpa_ie->vend_hdr.oui) - > + WPA_GTK_OUI_OFFSET; Same question. Brian > + > iebody = (struct ie_body *)((u8 *)bss_desc->bcn_wpa_ie->data + > WPA_GTK_OUI_OFFSET); > oui = &mwifiex_wpa_oui[cipher][0]; > - ret = mwifiex_search_oui_in_ie(iebody, oui); > + ret = mwifiex_search_oui_in_ie(iebody, oui, ie_len); > if (ret) > return ret; > } > -- > 2.43.0 >