From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 86885211A43DB for ; Sat, 15 Dec 2018 05:36:44 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id n190so8199747wmd.0 for ; Sat, 15 Dec 2018 05:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NPoD4Y97vAKo9/TfLO5i4jKP4kEwIROWoc3D1QTNx4Y=; b=JZfYIjQ2UMp2oRyF/gQ3Pqw89fkNJSNX3GMCYKP9GIDiQlCDu8cFxaRL/PtSOc9L5J v6MWEzCG8b2+k0HjUiDRI8H4t0nXMei6XxBbysQj9hN6noOMhIdBrNAY9DNY8QYZ1Zqj 8FY7uA4KgnfEQIzwUF0TXu3ti1tFyUFHX9nRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NPoD4Y97vAKo9/TfLO5i4jKP4kEwIROWoc3D1QTNx4Y=; b=QC/kasDxbpHgrkm/j8tDB5MqvKkJYG7XiqEvmMDp85HNXp4z7wzbXb+2sGPWkfme42 j7Ud2l2xqzOsd8Lfc/XKeX9/jyVuWp6y1UQAfWhp7JosokstYZ85y4YHIcYQbA1UVPTG IJR0yCE84wuQT4Sj3wT8eajvJdFofjroLslwfy23U59kdiwUdYg+vxCYfLxXx0QOWo+c tYmSWUcs7KKZsq1v6FmWw92RnmsdsMjVNymMiMe7BKmKqajNvVuUDF6i95me+yetSEbI MUXSkaAkwhv8BnG7RZJ6PpNuXjUnOa8GgAcMcYlaBv2XhgNjQR8tP2oRGpALFab3La4s hx3A== X-Gm-Message-State: AA+aEWZfsyfv7nWFUCa1Lb4oKNyWBUebznFHZcnkHHmGJq7jRDzCAKgP LaZ/kzhQ0mpKZsE2o7z8ENTnm+Em/mk= X-Google-Smtp-Source: AFSGD/U5zQQQYAad47Vs7kpRZ8y+aww/bhfbs2nUTtN9XxvNTP8uwGOwOFg6BcEv1cYIFFfP7zC74g== X-Received: by 2002:a1c:b1d5:: with SMTP id a204mr6704173wmf.32.1544881002849; Sat, 15 Dec 2018 05:36:42 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id h16sm19942491wrb.62.2018.12.15.05.36.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Dec 2018 05:36:42 -0800 (PST) Date: Sat, 15 Dec 2018 13:36:40 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: Vladimir Olovyannikov , "Zeng, Star" , "edk2-devel@lists.01.org" , Ruiyu Ni , Jian J Wang , Hao Wu Message-ID: <20181215133640.h2ohfbsfi6jok3cy@bivouac.eciton.net> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) 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: Sat, 15 Dec 2018 13:36:44 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Jian, Hao, I guess Ray and Star are no longer maintainers of this package. This patch never got pushed - could you have a look please? Regards, Leif 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/NonDiscoverablePciDeviceIo.c b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c > > index 0e42ae4bf6ec..07118d59fd68 100644 > > --- a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c > > +++ b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c > > @@ -52,6 +52,10 @@ GetBarResource ( > > > > BarIndex -= (UINT8)Dev->BarOffset; > > > > + if (BarIndex >= Dev->BarCount) { > > + return EFI_UNSUPPORTED; > > + } > > + > > for (Desc = Dev->Device->Resources; > > Desc->Desc != ACPI_END_TAG_DESCRIPTOR; > > Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3)) { > > @@ -597,6 +601,19 @@ CoherentPciIoMap ( > > EFI_STATUS Status; > > NON_DISCOVERABLE_PCI_DEVICE_MAP_INFO *MapInfo; > > > > + if (Operation != EfiPciIoOperationBusMasterRead && > > + Operation != EfiPciIoOperationBusMasterWrite && > > + Operation != EfiPciIoOperationBusMasterCommonBuffer) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (HostAddress == NULL || > > + NumberOfBytes == NULL || > > + DeviceAddress == NULL || > > + Mapping == NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > // > > // If HostAddress exceeds 4 GB, and this device does not support 64-bit DMA > > // addressing, we need to allocate a bounce buffer and copy over the data. > > @@ -720,6 +737,11 @@ CoherentPciIoAllocateBuffer ( > > return EFI_UNSUPPORTED; > > } > > > > + if ((MemoryType != EfiBootServicesData) && > > + (MemoryType != 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, there > > @@ -877,6 +899,10 @@ NonCoherentPciIoAllocateBuffer ( > > NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION *Alloc; > > VOID *AllocAddress; > > > > + if (HostAddress == NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This); > > > > Status = CoherentPciIoAllocateBuffer (This, Type, MemoryType, Pages, > > @@ -995,6 +1021,19 @@ NonCoherentPciIoMap ( > > EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; > > BOOLEAN Bounce; > > > > + if (HostAddress == NULL || > > + NumberOfBytes == NULL || > > + DeviceAddress == NULL || > > + Mapping == NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Operation != EfiPciIoOperationBusMasterRead && > > + Operation != EfiPciIoOperationBusMasterWrite && > > + Operation != EfiPciIoOperationBusMasterCommonBuffer) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > MapInfo = AllocatePool (sizeof *MapInfo); > > if (MapInfo == 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 = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This); > > > > + if (Attributes) { > > + if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) { > > + return EFI_UNSUPPORTED; > > + } > > + } > > + > > Enable = FALSE; > > switch (Operation) { > > case EfiPciIoAttributeOperationGet: > > @@ -1243,7 +1291,7 @@ PciIoAttributes ( > > if (Result == NULL) { > > return EFI_INVALID_PARAMETER; > > } > > - *Result = EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE; > > + *Result = DEV_SUPPORTED_ATTRIBUTES; > > break; > > > > case EfiPciIoAttributeOperationEnable: > > -- > > 2.18.0 > >