From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49B28C31E45 for ; Thu, 13 Jun 2019 18:12:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D4F120665 for ; Thu, 13 Jun 2019 18:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbfFMSMl (ORCPT ); Thu, 13 Jun 2019 14:12:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:35058 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725889AbfFMSMl (ORCPT ); Thu, 13 Jun 2019 14:12:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 10E6AAD81; Thu, 13 Jun 2019 18:12:40 +0000 (UTC) Date: Thu, 13 Jun 2019 20:12:39 +0200 Message-ID: From: Takashi Iwai To: Brian Norris Cc: linux-wireless@vger.kernel.org, Amitkumar Karwar , Nishant Sarmukadam , Ganapathi Bhat , Xinming Hu , Kalle Valo , huangwen@venustech.com.cn, Solar Designer , Marcus Meissner Subject: Re: [PATCH 2/2] mwifiex: Abort at too short BSS descriptor element In-Reply-To: <20190613174938.GA260350@google.com> References: <20190529125220.17066-1-tiwai@suse.de> <20190529125220.17066-3-tiwai@suse.de> <20190613174938.GA260350@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, 13 Jun 2019 19:49:40 +0200, Brian Norris wrote: > > Hi Takashi, > > On Wed, May 29, 2019 at 02:52:20PM +0200, Takashi Iwai wrote: > > Currently mwifiex_update_bss_desc_with_ie() implicitly assumes that > > the source descriptor entries contain the enough size for each type > > and performs copying without checking the source size. This may lead > > to read over boundary. > > > > Fix this by putting the source size check in appropriate places. > > > > Signed-off-by: Takashi Iwai > > --- > > drivers/net/wireless/marvell/mwifiex/scan.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c > > index 64ab6fe78c0d..c269a0de9413 100644 > > --- a/drivers/net/wireless/marvell/mwifiex/scan.c > > +++ b/drivers/net/wireless/marvell/mwifiex/scan.c > > @@ -1269,6 +1269,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, > > break; > > > > case WLAN_EID_FH_PARAMS: > > + if (element_len + 2 < sizeof(*fh_param_set)) > > "element_len + 2" would be much more readable as "total_ie_len". (Same for > several other usages in this patch.) I can send such a patch myself as a > follow-up I suppose. Yes, please. > > + return -EINVAL; > > fh_param_set = > > (struct ieee_types_fh_param_set *) current_ptr; > > memcpy(&bss_entry->phy_param_set.fh_param_set, > > [...] > > > @@ -1349,6 +1361,9 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, > > break; > > > > case WLAN_EID_VENDOR_SPECIFIC: > > + if (element_len + 2 < sizeof(vendor_ie->vend_hdr)) > > Why 'sizeof(vendor_ie->vend_hdr)'? The (mwifiex-specific compare with the > ieee80211.h generic struct ieee80211_vendor_ie) ieee_types_vendor_header struct > includes the 'oui_subtype' and 'version' fields, which are not standard > requirements for the vendor header (in fact, even the 4th byte of the > OUI -- "oui_type" -- doesn't appear to be in the 802.11 specification). > So it looks to me like you might be rejecting valid vendor headers (that > we should just be skipping) that might have vendor-specific content with > length 0 or 1 bytes. > > It seems like we should only be validating the standard pieces (e.g., up to the > length/OUI), and only after an appropriate OUI match, *then* validating the rest of > the vendor element (the pieces we'll use later). Hm, right, that looks too strict. Instead we need to check right before both memcmp()'s of OUI. thanks, Takashi