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.136; helo=mga12.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 78A8921199B3E for ; Sun, 16 Dec 2018 16:17:01 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Dec 2018 16:17:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,363,1539673200"; d="scan'208";a="119329908" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 16 Dec 2018 16:17:01 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 16 Dec 2018 16:17:01 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.222]) with mapi id 14.03.0415.000; Mon, 17 Dec 2018 08:16:58 +0800 From: "Wang, Jian J" To: Leif Lindholm , Ard Biesheuvel CC: Vladimir Olovyannikov , "Zeng, Star" , "edk2-devel@lists.01.org" , "Ni, Ruiyu" , "Wu, Hao A" Thread-Topic: [PATCH 3/3] MdeModulePkg/NonDiscoverablePciDeviceDxe: add missing validation Thread-Index: AQHUlHs6+Qb5H/Re1UaC4TFa6K6LmKWCEljQ Date: Mon, 17 Dec 2018 00:16:57 +0000 Message-ID: References: <20181215133640.h2ohfbsfi6jok3cy@bivouac.eciton.net> In-Reply-To: <20181215133640.h2ohfbsfi6jok3cy@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzIyMzU1YjEtNTU0Yy00ZTM3LWIyZGMtMjUwZDczYzQ1OTNiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQnNUOHBLOVFtY2ViOWdzcFNUUDhSandmUTZGWXA4YVFHbFZrYTZQRFwvVVFVNmtlYWNpWmFVc1d6NTFuRXk1Mk8ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 3/3] MdeModulePkg/NonDiscoverablePciDeviceDxe: add missing validation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2018 00:17:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Leif, Thanks for reminding. I'll take care of it. Regards, Jian > -----Original Message----- > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > Sent: Saturday, December 15, 2018 9:37 PM > To: Ard Biesheuvel > Cc: Vladimir Olovyannikov ; Zeng, Sta= r > ; edk2-devel@lists.01.org; Ni, Ruiyu > ; Wang, Jian J ; Wu, Hao A > > Subject: Re: [PATCH 3/3] MdeModulePkg/NonDiscoverablePciDeviceDxe: add > missing validation >=20 > Jian, Hao, >=20 > I guess Ray and Star are no longer maintainers of this package. > This patch never got pushed - could you have a look please? >=20 > Regards, >=20 > Leif >=20 > On Fri, Sep 07, 2018 at 12:36:32PM +0200, Ard Biesheuvel wrote: > > On 6 September 2018 at 20:55, Vladimir Olovyannikov > > wrote: > > > UEFI SCT crashed and failed in NonDiscoverablePciDeviceDxe becase > > > required checks were not performed. Perform parameters validation in > > > NonDiscoverablePciDeviceDxe. > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > Signed-off-by: Vladimir Olovyannikov > > > > > Reviewed-by: Ard Biesheuvel > > > > > --- > > > .../NonDiscoverablePciDeviceIo.c | 50 +++++++++++++++++= +- > > > 1 file changed, 49 insertions(+), 1 deletion(-) > > > > > > diff --git > a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciD > eviceIo.c > b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciD > eviceIo.c > > > index 0e42ae4bf6ec..07118d59fd68 100644 > > > --- > a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciD > eviceIo.c > > > +++ > b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciD > eviceIo.c > > > @@ -52,6 +52,10 @@ GetBarResource ( > > > > > > BarIndex -=3D (UINT8)Dev->BarOffset; > > > > > > + if (BarIndex >=3D Dev->BarCount) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + > > > for (Desc =3D Dev->Device->Resources; > > > Desc->Desc !=3D ACPI_END_TAG_DESCRIPTOR; > > > Desc =3D (VOID *)((UINT8 *)Desc + Desc->Len + 3)) { > > > @@ -597,6 +601,19 @@ CoherentPciIoMap ( > > > EFI_STATUS Status; > > > NON_DISCOVERABLE_PCI_DEVICE_MAP_INFO *MapInfo; > > > > > > + if (Operation !=3D EfiPciIoOperationBusMasterRead && > > > + Operation !=3D EfiPciIoOperationBusMasterWrite && > > > + Operation !=3D EfiPciIoOperationBusMasterCommonBuffer) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (HostAddress =3D=3D NULL || > > > + NumberOfBytes =3D=3D NULL || > > > + DeviceAddress =3D=3D NULL || > > > + Mapping =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > // > > > // If HostAddress exceeds 4 GB, and this device does not support 6= 4-bit > DMA > > > // addressing, we need to allocate a bounce buffer and copy over t= he data. > > > @@ -720,6 +737,11 @@ CoherentPciIoAllocateBuffer ( > > > return EFI_UNSUPPORTED; > > > } > > > > > > + if ((MemoryType !=3D EfiBootServicesData) && > > > + (MemoryType !=3D EfiRuntimeServicesData)) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > // > > > // Allocate below 4 GB if the dual address cycle attribute has not > > > // been set. If the system has no memory available below 4 GB, the= re > > > @@ -877,6 +899,10 @@ NonCoherentPciIoAllocateBuffer ( > > > NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION *Alloc; > > > VOID *AllocAddress; > > > > > > + if (HostAddress =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > Dev =3D NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This); > > > > > > Status =3D CoherentPciIoAllocateBuffer (This, Type, MemoryType, Pa= ges, > > > @@ -995,6 +1021,19 @@ NonCoherentPciIoMap ( > > > EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; > > > BOOLEAN Bounce; > > > > > > + if (HostAddress =3D=3D NULL || > > > + NumberOfBytes =3D=3D NULL || > > > + DeviceAddress =3D=3D NULL || > > > + Mapping =3D=3D NULL) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > + if (Operation !=3D EfiPciIoOperationBusMasterRead && > > > + Operation !=3D EfiPciIoOperationBusMasterWrite && > > > + Operation !=3D EfiPciIoOperationBusMasterCommonBuffer) { > > > + return EFI_INVALID_PARAMETER; > > > + } > > > + > > > MapInfo =3D AllocatePool (sizeof *MapInfo); > > > if (MapInfo =3D=3D NULL) { > > > return EFI_OUT_OF_RESOURCES; > > > @@ -1228,8 +1267,17 @@ PciIoAttributes ( > > > NON_DISCOVERABLE_PCI_DEVICE *Dev; > > > BOOLEAN Enable; > > > > > > + #define DEV_SUPPORTED_ATTRIBUTES \ > > > + (EFI_PCI_DEVICE_ENABLE | > EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) > > > + > > > Dev =3D NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This); > > > > > > + if (Attributes) { > > > + if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) !=3D 0) { > > > + return EFI_UNSUPPORTED; > > > + } > > > + } > > > + > > > Enable =3D FALSE; > > > switch (Operation) { > > > case EfiPciIoAttributeOperationGet: > > > @@ -1243,7 +1291,7 @@ PciIoAttributes ( > > > if (Result =3D=3D NULL) { > > > return EFI_INVALID_PARAMETER; > > > } > > > - *Result =3D EFI_PCI_DEVICE_ENABLE | > EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE; > > > + *Result =3D DEV_SUPPORTED_ATTRIBUTES; > > > break; > > > > > > case EfiPciIoAttributeOperationEnable: > > > -- > > > 2.18.0 > > >