Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp252524ybg; Thu, 17 Oct 2019 22:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdpHurwyn7qXRLxmwA9/KOTKweCi1+WJejjV7d1SsBG2/eZyXUnZNRWZjCKEfVkbIHFN/1 X-Received: by 2002:a50:fc86:: with SMTP id f6mr7721462edq.233.1571376413529; Thu, 17 Oct 2019 22:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571376413; cv=none; d=google.com; s=arc-20160816; b=luQuTMDUrGW9ZckBPggj2gSQ83vh08hHveJzsbIuWj2PMjY2Pxd6dugKZbOGJtbxJG ASHpw6FdvhrLxjJN0MLNHFUqImkY9elX2uxIzHLLXkxuWOb/lMhv6Lunro7+GCQAWXr0 bIRSRRbnws5dXJqjTmh4fXaBw+tpF5KDZmYJwy6A7MleXDAngzWE/spO0iJ9OIWxBP/f shZMDo2UE6PLVo56lM8B0vRkRf0FD55rflOmbySSktkDkzeyHosUjTMpQIRBJoB81ho5 ph6gH/hjZPifUXvgW4dsb7e7KiqP4C24j3grR+yU49WJNltckcjAkayaL6pmagsJyiV2 vzMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:authenticated-by; bh=CDRsgvHsXYG+PBs1ks9e2L2tecCZImzn0BCFzug/1F8=; b=YSkN2ivoHHqyetr2KsSP9cTRDs6PdSGw+rnI1ilmdBmHplmFbPhQpA0q0N/3Ei3Jdz hvH56RZiXW8mjndbd8fslnRzy5X4LAiPPzrYRdtm+jtb69K3xzWOed3Sb60x5pa3clHJ DtW1a70HNNj0E5CVj4BOAYymJaSSL29sEelEraXbobTrB3VbQ5dZ7cLw6uU4q5rOEaH4 uBGhLHles1BMK/NyKurduxxdUpibmGUVN8LMwMR+8UGmpP6hHh25BbWo3WOA6WXlayb4 UPU/D1g7wJwVQ9HmcNxcqmxZKCXrr0w4JVm2nvAXG9EhXYhbF0wO1DGRtleHOD5o5QHH eJDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si3006186edr.20.2019.10.17.22.26.28; Thu, 17 Oct 2019 22:26:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395398AbfJQBYs convert rfc822-to-8bit (ORCPT + 99 others); Wed, 16 Oct 2019 21:24:48 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:48123 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389094AbfJQBYs (ORCPT ); Wed, 16 Oct 2019 21:24:48 -0400 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID x9H1OSdP000991, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCAS12.realtek.com.tw[172.21.6.16]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id x9H1OSdP000991 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Oct 2019 09:24:28 +0800 Received: from RTITMBSVM04.realtek.com.tw ([fe80::e404:880:2ef1:1aa1]) by RTITCAS12.realtek.com.tw ([::1]) with mapi id 14.03.0439.000; Thu, 17 Oct 2019 09:24:27 +0800 From: Pkshih To: Laura Abbott , Kalle Valo CC: "David S. Miller" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Nicolas Waisman Subject: RE: [PATCH] rtlwifi: Fix potential overflow on P2P code Thread-Topic: [PATCH] rtlwifi: Fix potential overflow on P2P code Thread-Index: AQHVhGRS0Eb+pvqKg0iKoQwx5Knt06deCEZw Date: Thu, 17 Oct 2019 01:24:26 +0000 Message-ID: <5B2DA6FDDF928F4E855344EE0A5C39D1D5C84368@RTITMBSVM04.realtek.com.tw> References: <20191016205716.2843-1-labbott@redhat.com> In-Reply-To: <20191016205716.2843-1-labbott@redhat.com> Accept-Language: en-US, zh-TW Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.69.95] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org > -----Original Message----- > From: linux-wireless-owner@vger.kernel.org [mailto:linux-wireless-owner@vger.kernel.org] On Behalf > Of Laura Abbott > Sent: Thursday, October 17, 2019 4:57 AM > To: Pkshih; Kalle Valo > Cc: Laura Abbott; David S. Miller; linux-wireless@vger.kernel.org; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; Nicolas Waisman > Subject: [PATCH] rtlwifi: Fix potential overflow on P2P code > > Nicolas Waisman noticed that even though noa_len is checked for > a compatible length it's still possible to overrun the buffers > of p2pinfo since there's no check on the upper bound of noa_num. > Bounds check noa_num against P2P_MAX_NOA_NUM. > > Reported-by: Nicolas Waisman > Signed-off-by: Laura Abbott > --- > Compile tested only as this was reported to the security list. > --- > drivers/net/wireless/realtek/rtlwifi/ps.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/net/wireless/realtek/rtlwifi/ps.c b/drivers/net/wireless/realtek/rtlwifi/ps.c > index 70f04c2f5b17..c5cff598383d 100644 > --- a/drivers/net/wireless/realtek/rtlwifi/ps.c > +++ b/drivers/net/wireless/realtek/rtlwifi/ps.c > @@ -754,6 +754,13 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, > return; > } else { > noa_num = (noa_len - 2) / 13; > + if (noa_num > P2P_MAX_NOA_NUM) { > + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, > + "P2P notice of absence: invalid noa_num.%d\n", > + noa_num); > + return; As the discussion at , I think it'd be better to use the min between noa_num and P2P_MAX_NOA_NUM, and fall through the code instead of return. Because ignore all NoA isn't better than apply two of them. > + } > + > } > noa_index = ie[3]; > if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == > @@ -848,6 +855,13 @@ static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, > return; > } else { > noa_num = (noa_len - 2) / 13; > + if (noa_num > P2P_MAX_NOA_NUM) { > + RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, > + "P2P notice of absence: invalid noa_len.%d\n", > + noa_len); > + return; > + > + } > } > noa_index = ie[3]; > if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == > -- > 2.21.0