From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4025A20352602 for ; Mon, 30 Oct 2017 03:19:44 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2017 03:23:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,319,1505804400"; d="scan'208";a="166786928" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga005.jf.intel.com with ESMTP; 30 Oct 2017 03:23:18 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 30 Oct 2017 03:23:17 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 30 Oct 2017 03:23:17 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Mon, 30 Oct 2017 18:23:15 +0800 From: "Ni, Ruiyu" To: "Zeng, Star" , Heyi Guo , "linaro-uefi@lists.linaro.org" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , Ard Biesheuvel Thread-Topic: [edk2][PATCH] MdeModulePkg/NonDiscoverable: fix memory override bug Thread-Index: AQHTUWbjYLpfKJsDsUuwIXy18gVJvqL8L0WQ Date: Mon, 30 Oct 2017 10:23:15 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BAAC00C@SHSMSX104.ccr.corp.intel.com> References: <1509342472-1688-1-git-send-email-heyi.guo@linaro.org> <0C09AFA07DD0434D9E2A0C6AEB0483103B9AFC6A@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B9AFC6A@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/NonDiscoverable: fix memory override bug X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Oct 2017 10:19:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I will wait for Ard's feedback. It's an ARM specific module. Thanks/Ray > -----Original Message----- > From: Zeng, Star > Sent: Monday, October 30, 2017 6:07 PM > To: Ni, Ruiyu ; Heyi Guo ; linar= o- > uefi@lists.linaro.org; edk2-devel@lists.01.org > Cc: Dong, Eric ; Ard Biesheuvel > ; Zeng, Star > Subject: RE: [edk2][PATCH] MdeModulePkg/NonDiscoverable: fix memory > override bug >=20 > Ray, > Please help take a review to this patch. >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Heyi Guo [mailto:heyi.guo@linaro.org] > Sent: Monday, October 30, 2017 1:48 PM > To: linaro-uefi@lists.linaro.org; edk2-devel@lists.01.org > Cc: Heyi Guo ; Zeng, Star ; > Dong, Eric ; Ard Biesheuvel > ; Ni, Ruiyu > Subject: [edk2][PATCH] MdeModulePkg/NonDiscoverable: fix memory > override bug >=20 > For PciIoPciRead interface, memory prior to Buffer would be written with > zeros if Offset was larger than sizeof (Dev->ConfigSpace), which would ca= use > serious system exception. >=20 > So we add a pre-check branch to avoid memory override. >=20 > Cc: Star Zeng > Cc: Eric Dong > Cc: Ard Biesheuvel > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Heyi Guo > --- > .../Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c | 5 > +++++ > 1 file changed, 5 insertions(+) >=20 > diff --git > a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable > PciDeviceIo.c > b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable > PciDeviceIo.c > index c836ad6..0e42ae4 100644 > --- > a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable > PciDeviceIo.c > +++ > b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable > Pc > +++ iDeviceIo.c > @@ -465,6 +465,11 @@ PciIoPciRead ( > Address =3D (UINT8 *)&Dev->ConfigSpace + Offset; > Length =3D Count << ((UINTN)Width & 0x3); >=20 > + if (Offset >=3D sizeof (Dev->ConfigSpace)) { > + ZeroMem (Buffer, Length); > + return EFI_SUCCESS; > + } > + > if (Offset + Length > sizeof (Dev->ConfigSpace)) { > // > // Read all zeroes for config space accesses beyond the first > -- > 1.9.1