summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk
AgeCommit message (Collapse)AuthorFilesLines
8 daysMdeModulePkg/RamDiskDxe: fix memory leak on error path.Mike Maslenkin1-2/+7
This patch fixes a leak of memory allocated for the RAM disk in cases when an error occurred while reading contents of a file from disk or RamDiskRegister() returned some error condition. Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
2023-04-10MdeModulePkg: Update code to be more C11 compliant by using __func__Rebecca Cran3-7/+7
__FUNCTION__ is a pre-standard extension that gcc and Visual C++ among others support, while __func__ was standardized in C99. Since it's more standard, replace __FUNCTION__ with __func__ throughout MdeModulePkg. Signed-off-by: Rebecca Cran <rebecca@bsdio.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2022-01-10MdeModulePkg/PartitionDxe: Add break to handle invalid LBA0 in MBREdwards, Craig1-0/+7
Read Disk does a modification of ExtMbrStartingLba with the code MultU64x32 (ExtMbrStartingLba, BlockSize) Error detection to see if ExtMbrStartingLBA has a value of 0. This is invalid as LBA 0 = MBR. After modification, the next time ExtMbrStartingLba is in this function if ExtMbrStartingLba is set to 0 in the MBR it never passes the while/do evaluation It is multiplied by 0 by read disk , set to 0 by an invalid MBR and goes back to evaluation This condition will also cause Ws19 and WS22 to hang, however Microsoft has developed a hotfix patch that will be released in 2022 Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Craig Edwards <craig.edwards@dell.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2021-12-07MdeModulePkg: Apply uncrustify changesMichael Kubacki27-2842/+3021
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2021-12-07MdeModulePkg: Change OPTIONAL keyword usage styleMichael D Kinney1-1/+1
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3760 Update all use of ', OPTIONAL' to ' OPTIONAL,' for function params. Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael Kubacki <michael.kubacki@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2021-12-07MdeModulePkg: Change use of EFI_D_* to DEBUG_*Michael D Kinney8-64/+63
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3739 Update all use of EFI_D_* defines in DEBUG() macros to DEBUG_* defines. Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael Kubacki <michael.kubacki@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2021-09-03MdeModulePkg: Fix typo of "memory" in RamDiskDxe debug messageRebecca Cran1-1/+1
Fix a typo of "memory" in a debug message in RamDiskProtocol.c. Signed-off-by: Rebecca Cran <rebecca@bsdio.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
2021-07-14MdeModulePkg/RamDiskDxe: Init list head before registering RamDisk protocolTrammell Hudson1-5/+6
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3483 This patch initializes the linked list RegisteredRamDisks in RamDiskDxeEntryPoint before the registration of gEfiRamDiskProtocolGuid with InstallMultipleProtocolInterfaces, allowing ramdisks to be created via a callback installed with RegisterProtocolNotify as soon as the protocol is registered. Without this, calling RamDisk->Register() in the callback causes a crash: ASSERT [RamDiskDxe] MdePkg/Library/BaseLib/LinkedList.c(75): List->ForwardLink != ((void *) 0) Signed-off-by: Trammell Hudson <hudson@trmm.net> Cc: Daniel Schaefer <daniel.schaefer@hpe.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2021-07-06MdeModulePkg/PartitionDxe: Ignore PMBR BootIndicator per UEFI specNeal Gompa1-2/+1
Per UEFI Spec 2.8 (UEFI_Spec_2_8_final.pdf, page 114) 5.2.3 Protective MBR Table 20. Protective MBR Partition Record protecting the entire disk The description for BootIndicator states the following: > Set to 0x00 to indicate a non-bootable partition. If set to any > value other than 0x00 the behavior of this flag on non-UEFI > systems is undefined. Must be ignored by UEFI implementations. Unfortunately, we have been incorrectly assuming that the BootIndicator value must be 0x00, which leads to problems when the 'pmbr_boot' flag is set on a disk containing a GPT (such as with GNU parted). When the flag is set, the value changes to 0x01, causing this check to fail and the system is rendered unbootable despite it being valid from the perspective of the UEFI spec. To resolve this, we drop the check for the BootIndicator so that we stop caring about the value set there, which restores the capability to boot such disks. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3474 Cc: Chris Murphy <chrismurphy@fedoraproject.org> Cc: David Duncan <davdunc@amazon.com> Cc: Lazlo Ersek <lersek@redhat.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Neal Gompa <ngompa@fedoraproject.org> Message-Id: <20210705093603.575707-1-ngompa@fedoraproject.org> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2020-10-20Revert "MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child ..."Zhichao Gao1-3/+9
This reverts commit e0eacd7daa6f2e59de2b35a5dfe8bb4c38821e31. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3012 The patch to fix LBA size would cause a regression that make the partition of CD image with media type other than NO_EMULATOR unobserved. The patch used to fix the CD image's MBR table issue. The CD MBR table would always be ignored because it would be handled by the Eltorito partition handler first and never go into the MBR handler. So directly revert it. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Tested-by: Gary Lin <glin@suse.com>
2020-08-13MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child handerZhichao Gao1-9/+3
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2843 PartitionInstallChildHandle's parameters Start and End is counted by the BlockSize, but in the implementation it uses the parent device's BlockSize to calculate the new Start, End and LastBlock. It would cause the driver report incorrect block scope and the file system would fail to be found with right block scope. So correct it to the right value. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Gary Lin <glin@suse.com> Cc: Andrew Fish <afish@apple.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Tested-by: Gary Lin <glin@suse.com>
2020-08-13MdeModulePkg/PartitionDxe: Revert changes for the special MBRZhichao Gao1-31/+6
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 Revert "MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROM" Follow the spec definition, the ISO 9660 (and UDF) would be checked before the MBR. So it is not required to skip such MBR talbe that contian the entire block device. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Gary Lin <glin@suse.com> Cc: Andrew Fish <afish@apple.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Tested-by: Gary Lin <glin@suse.com>
2020-08-13MdeModulePkg/PartitionDxe: Put the UDF check ahead of MBRZhichao Gao1-1/+9
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 Refer to UEFI spec 2.8, Section 13.3.2, a block device should be scanned as below order: 1. GPT 2. ISO 9660 (El Torito) (UDF should aslo be here) 3. MBR 4. no partition found Note: UDF is using the same boot method as CD, so put it in the same priority with ISO 9660. This would also solve the issue that ISO image with MBR would be treat as MBR device instead of CD/DVD. That would make the behavior of the image boot different: If the CD/DVD's MBR be handled correctly, it would be enumerated as a bootable device with MBR path and FAT filesystem. Some Linux Distributions boot from such path (FAT with MBR path for ISO) would come into the grub console instead of the installation selection. With this change, the CD/DVD would always be enumerated with CD path. And it would always boot to the installation selection. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Gary Lin <glin@suse.com> Cc: Andrew Fish <afish@apple.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Tested-by: Gary Lin <glin@suse.com>
2020-07-15MdeModulePkg/PartitionDxe: Add already start check for child hanldesZhichao Gao1-0/+9
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 The partition binding driver would run serval times during BDS. If the partition support MBR, it would pass the first connection in MBR partition child handler. The second connect for the same device would return already started which would be treated as not found. And it would continue to run next partition child handler check. That is incorrect behavior to do next check if one of the routine functions is passed. It may cause one device installed serval partition child handle on it. So treat the EFI_ALREADY_STARTED as EFI_SUCCESS to avoid incorrect next partition child handle check. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
2020-07-15MdeModulePkg/PartitionDxe: Skip the MBR that add for CD-ROMZhichao Gao1-6/+31
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 Refer to http://manpages.ubuntu.com/manpages/bionic/man8/mkudffs.8.html. Some Linux ISOs may have the MBR table for compatibility reasons for Windows. The MBR tale would contain the partition entry with start LBA0 and whole media size. There are two methods to check the filesystem in the CD-ROM: 1. MBR partition check (Windows) 2. Whole disk check (MAC OS) UEFI doesn't have the MBR check for UDF and Eltorito. But it may pass the MBR check for such table and fail to detect the filesystem of UDF. Skip the MBR check if the MBR is added for Windows compatiblity so that the partition driver can continue UDF and ElTorito check. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
2020-07-15MdeModulePkg/PartitionDxe: Correct the MBR last block valueZhichao Gao1-5/+8
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2823 PartitionValidMbr function's second parameter should be the last sector of the device. For MBR partition, the block size is sector size, i.e. 512 bytes. The original value is media block last LBA which is counted by the media block size. And media block size is not always 512 bytes, it may be larger which would cause the MBR boundary check incorrect. The boundary check is based on the partition entry start LBA and size of LBA which are both counted by the sector number (512 bytes). Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
2020-04-21MdeModulePkg/RamDiskDxe: Use BaseLib linked list iteration macrosMichael Kubacki4-21/+11
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1959 Replaces usage of the linked list iteration macros defined in RamDiskImpl.h with the common definition in BaseLib.h. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
2019-05-09MdeModulePkg: Remove BootInRecoveryMode PPIxuwei61-1/+1
DEPEX from PEI storage stack. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1777 BootInRecoveryMode Ppi dependency should be removed from PEI storage stack drivers. Besides recovery, more features are using the storage stack. Platform can apply Ppi dependency in Recovery FV which contains full storage driver stack. Platform storage stack modules, such as host controller init PEI module, should also remove this dependency. Cc: Ray Ni <ray.ni@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
2019-05-09MdeModulePkg/CdExpress: Remove PcdFrameworkCompatibilitySupport usageDandan Bi2-13/+2
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1464 Currently Framework compatibility is not needed and PcdFrameworkCompatibilitySupport will be removed from edk2. So remove the usage of this PCD firstly. Cc: Hao Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2019-04-09MdeModulePkg: Replace BSD License with BSD+Patent LicenseMichael D Kinney45-320/+45
https://bugzilla.tianocore.org/show_bug.cgi?id=1373 Replace BSD 2-Clause License with BSD+Patent License. This change is based on the following emails: https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html RFCs with detailed process for the license change: V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
2019-02-28MdeModulePkg/RamDiskDxe: Restrict on RAM disk size (CVE-2018-12180)Hao Wu3-11/+20
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1134 Originally, the block size of created Ram disks is hard-coded to 512 bytes. However, if the total size of the Ram disk is not a multiple of 512 bytes, there will be potential memory access issues when dealing with the last block of the Ram disk. This commit will adjust the block size of the Ram disks to ensure that the total size is a multiple of the block size. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
2019-02-28MdeModulePkg/PartitionDxe: Ensure blocksize holds MBR (CVE-2018-12180)Hao Wu2-2/+16
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1134 The commit adds checks for detecting GPT and MBR partitions. These checks will ensure that the device block size is big enough to hold an MBR (512 bytes). Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
2018-10-31MdeModulePkg/UdfDxe: Memory free/use after free in ResolveSymlink()Hao Wu1-3/+11
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1279 For function ResolveSymlink(), the below codes: if (CompareMem ((VOID *)&PreviousFile, (VOID *)Parent, sizeof (UDF_FILE_INFO)) != 0) { CleanupFileInformation (&PreviousFile); } CopyMem ((VOID *)&PreviousFile, (VOID *)File, sizeof (UDF_FILE_INFO)); If the contents in 'PreviousFile' and 'File' are the same, call to "CleanupFileInformation (&PreviousFile);" will free the buffers in 'File' as well. This will lead to potential memory double free/use after free issues. This commit will add additional check to address the above issue. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2018-10-31MdeModulePkg/UdfDxe: Content check for 'File' in ResolveSymlink()Hao Wu1-0/+17
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1279 The content within 'File' is the output data for ResolveSymlink(). This commit will add checks to ensure the content in 'File' is valid. Otherwise, possible null pointer dereference issue will occur during the subsequent usage of the data returned by ResolveSymlink(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2018-10-31MdeModulePkg/UdfDxe: Check 'Component Type' within a Path ComponentHao Wu1-0/+7
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1279 According to the ECMA-167 standard (3rd Edition - June 1997), Section 14.16.1.1, valid values are 1 to 5. All other values will be treated as a corrupted volume. This commit will add such check within function ResolveSymlink(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2018-10-23MdeModulePkg/UdfDxe: Avoid possible use of already-freed dataHao Wu1-6/+9
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1255 For function ReadFile(): If the line Status = GetAedAdsData ( ... ); is reached multiple times during the 'for' loop, freeing the data pointed by variable 'Data' may potentially lead to variable 'Ad' referencing the already-freed data. After calling function GetAllocationDescriptor(), 'Data' and 'Ad' may point to the same memory (with some possible offset). Hence, this commit will move the FreePool() call backwards to ensure the data will no longer be used. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Add more check when getting PD from LongAdHao Wu1-4/+9
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1254 This commit will add an additional check within function GetPdFromLongAd() when getting a Partition Descriptor from given a Long Allocation Descriptor. According to UDF 2.60 Spec, Section 2.2.13: > The partition reference numbers used are determined by the order of the > Partition Maps in the LVD. (Also the picture comes before the above contents) And a more detailed explanation of the partition reference numbers is at https://sites.google.com/site/udfintro/ (seems not a formal documentation though), Section 5.3.6. Based on the above findings, the 'PartitionReferenceNumber' field in a Long Allocation Descriptor is used as an index to access the Partition Maps data within a Logical Volume Descriptor. Hence, the new check focuses on the validity of this 'PartitionReferenceNumber' field in a Long Allocation Descriptor. Since the current implementation of UdfDxe driver supports only one partition on a Logical Volume, so the value of 'PartitionReferenceNumber' should be 0. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Update GetInfo() for FS VolumeLabel info requestHao Wu4-63/+146
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1175 This commit will update the UdfGetInfo() function with the support of EFI_FILE_SYSTEM_VOLUME_LABEL data information request. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Fix a typo within SetFileInfo()Hao Wu1-1/+1
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1253 Within function SetFileInfo(): This commit will fix a typo where 'Minute' should be used instead of 'Second'. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Correct behavior for UdfSetPosition()Hao Wu1-1/+1
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1252 Calling the 'SetPosition' service of the EFI_FILE_PROTOCOL with 'Position' equals to 0xFFFFFFFFFFFFFFFF for a file is to set the current position to the end of the file. But the current implementation of function UdfSetPosition() is to set it to the last byte (not EOF). This commit will resolve this issue. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Add boundary check for getting volume (free) sizeHao Wu2-1/+23
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828 Within GetVolumeSize(): The boundary check will validate the 'NumberOfPartitions' field of a Logical Volume Integrity Descriptor matches the data within the relating Logical Volume Descriptor. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Add boundary check for ComponentIdentifier decodeHao Wu1-0/+4
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828 Within ResolveSymlink(): The boundary check will validate the 'LengthofComponentIdentifier' field of a Path Component matches the data within the relating (Extended) File Entry. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Add boundary check the read of FE/EFEHao Wu1-4/+50
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828 Within ReadFile(): Add checks to ensure that when getting the raw data or the Allocation Descriptors' data from a FE/EFE, it will not consume data beyond the size of a FE/EFE. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/UdfDxe: Refine boundary checks for file/path name stringHao Wu3-15/+110
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828 The commit refines the boundary checks for file/path name string to prevent possible buffer overrun. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-23MdeModulePkg/PartitionDxe: Add check for underlying device block sizeHao Wu1-0/+29
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=828 Within FindAnchorVolumeDescriptorPointer(): Add a check for the underlying device block size to ensure it is greater than the size of an Anchor Volume Descriptor Pointer. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Acked-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: Handle dead codes in FileSystemOperations.cHao Wu1-0/+8
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249 We found potential dead codes within File.c during the code coverage test. After manual review, we think the below ones are positive reports: A. For function GetAllocationDescriptor(): Due to the all the calling places for this function, the input parameter 'RecordingFlags' can only with value 'LongAdsSequence' or 'ShortAdsSequence'. Moreover, this is also mentioned in the function description comments for GetAllocationDescriptor(). So the below code will never be reached: return EFI_DEVICE_ERROR; This commit will add "ASSERT (FALSE);" before the above line to indicate this and thus matching the function description comments. B. For function GetAllocationDescriptorLsn(): Due to the all the calling places for this function, the input parameter 'RecordingFlags' can only with value 'LongAdsSequence' or 'ShortAdsSequence'. Moreover, this is also mentioned in the function description comments for GetAllocationDescriptorLsn(). So the below code will never be reached: return EFI_UNSUPPORTED; This commit will add "ASSERT (FALSE);" before the above line to indicate this and thus matching the function description comments. Cc: Paulo Alcantara <palcantara@suse.de> Cc: Paulo Alcantara <paulo@paulo.ac> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: Handle dead codes in File.cHao Wu1-0/+4
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1249 We found potential dead codes within File.c during the code coverage test. After manual review, we think the below ones are positive reports: A. In function UdfRead(): else if (IS_FID_DELETED_FILE (Parent->FileIdentifierDesc)) { Status = EFI_DEVICE_ERROR; } A File Identifier Descriptor will be get from the UDF media only by function ReadDirectoryEntry(). And within this function, all the File Identifier Descriptor with 'DELETED_FILE' characteristics will be skipped and will not be returned. Hence, the above codes in function UdfRead() will never be hit. This commit will add "ASSERT (FALSE);" before the above line to indicate this. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: Use debug msg instead of ASSERT in UdfOpen()Hao Wu1-1/+5
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248 Within function UdfOpen(): This commit will use debug messages instead of using ASSERT when an error occurs after calling GetFileSize(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: Use error handling when fail to return LSNHao Wu1-32/+69
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1248 This commit will refine the ASSERTs in function GetLongAdLsn() and GetAllocationDescriptorLsn() when the logical sector number cannot be returned due to unrecognized media format. Error handling logic will be used for those ASSERTs. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: ASSERT for false positives of NULL ptr derefHao Wu2-0/+18
This commit adds ASSERTs to address false positive reports of NULL pointer dereference issues raised from static analysis with regard to function ReadDirectoryEntry(). Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-10-18MdeModulePkg/UdfDxe: Use error handling for memory allocation failureHao Wu1-6/+34
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1247 For functions DuplicateFid() and DuplicateFe(), this commit will use error handling logic instead of ASSERTs for memory allocation failure. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-09-06MdeModulePkg: Removing ipf which is no longer supported from edk2.Chen A Chen5-5/+6
Removing rules for Ipf sources file: * Remove the source file which path with "ipf" and also listed in [Sources.IPF] section of INF file. * Remove the source file which listed in [Components.IPF] section of DSC file and not listed in any other [Components] section. * Remove the embedded Ipf code for MDE_CPU_IPF. Removing rules for Inf file: * Remove IPF from VALID_ARCHITECTURES comments. * Remove DXE_SAL_DRIVER from LIBRARY_CLASS in [Defines] section. * Remove the INF which only listed in [Components.IPF] section in DSC. * Remove statements from [BuildOptions] that provide IPF specific flags. * Remove any IPF sepcific sections. Removing rules for Dec file: * Remove [Includes.IPF] section from Dec. Removing rules for Dsc file: * Remove IPF from SUPPORTED_ARCHITECTURES in [Defines] section of DSC. * Remove any IPF specific sections. * Remove statements from [BuildOptions] that provide IPF specific flags. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chen A Chen <chen.a.chen@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-08-16MdeModulePkg/RamDiskDxe: replace OpenFileByDevicePath() with UefiLib APILaszlo Ersek4-181/+1
Replace the OpenFileByDevicePath() function with EfiOpenFileByDevicePath() from UefiLib, correcting the following issues: - imprecise comments on OpenFileByDevicePath(), - code duplication between this module and other modules, - local variable name "EfiSimpleFileSystemProtocol" starting with "Efi" prefix, - bogus "FileHandle = NULL" assignments, - passing a potentially unaligned "FILEPATH_DEVICE_PATH.PathName" field to a protocol member function (forbidden by the UEFI spec), - leaking "Handle1" when the device path type/subtype check fails in the loop, - stale SHELL_FILE_HANDLE reference in a comment. Cc: Eric Dong <eric.dong@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Cc: Star Zeng <star.zeng@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1008 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2018-06-28MdeModulePkg: Clean up source filesLiming Gao22-167/+167
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-05-03MdeModulePkg/RamDiskDxe: Update RouteConfig functionThomas Palmer1-1/+3
According to UEFI spec, the RouteConfig protocol function should populate the Progress pointer with an address inside Configuration. This patch ensures that these functions are compliant when EFI_NOT_FOUND is returned. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-03-29MdeModulePkg/PartitionDxe: Add partition type guid to installed handleJeff Brasen6-18/+38
Add the partition type GUID for every partition to the installed handle, this is required per the UEFI specification. "The firmware must add the PartitionTypeGuid to the handle of every active GPT partition using EFI_BOOT_SERVICES.InstallProtocolInterface()." Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jeff Brasen <jbrasen.qdt@qualcommdatacenter.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-02-26MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo servicesHao Wu1-15/+15
The commit places the check for MediaId at the beginning of Block IO services: RamDiskBlkIoReadBlocks and RamDiskBlkIoWriteBlocks This aligns with the Block IO protocol implementations for other devices. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-01-26MdeModulePkg/Partition: Fix media probeRuiyu Ni1-3/+7
The call in ProbeMediaStatusEx() to the ReadDisk() function of the EFI_DISK_IO_PROTOCOL interface implemented in DiskIoDxe/DiskIo.c crashed in DiskIo2ReadWriteDisk() because of the NULL value of the destination buffer pointer. Pass the address of a buffer in the stack instead of a NULL pointer. The similar fix was applied to ProbeMediaStatus in commit df473cc1fc9acd1a623ec7e05276f2f0635c19d2 * MdeModulePkg/PartitionDxe: Fix media probe Somehow ProbeMediaStatusEx() wasn't changed together. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Tested-by: Jian J Wang <jian.j.wang@intel.com>
2017-12-06MdeModulePkg/PartitionDxe: Remove unnecessary parentheses in 'if'Hao Wu1-1/+1
This commit removes unnecessary parentheses in 'if' statements to resolve the build failures by the XCODE5 tool chain. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-20MdeModulePkg/UdfDxe: Avoid possible loss track of allocated bufferHao Wu1-5/+7
In function FindFileEntry(): Instead of using the function parameter 'FileEntry', use a local variable to store the buffer allocated for disk read operation. For the below calling stack: UdfOpenVolume() -> FindRootDirectory() -> FindFileEntry() In FindFileEntry(), the call to 'DiskIo->ReadDisk()' is possible (e.g. media change for a CD/DVD ROM device) to trigger a re-install of the BlockIO(2) protocol which will further lead to a call of the BindingStop() & BingdingStart() of the UdfDxe driver. Meanwhile, for the above listed calling stack, the '**FileEntry' parameter passed into FindFileEntry() is '&PrivFsData->Root'. 'PrivFsData' is a driver-managed private data, it will be freed in BindingStop() and re-allocate in BingdingStart(). In such case, if '*FileEntry' is used to store the allocated buffer, the information will be lost if 'DiskIo->ReadDisk()' triggers a re-install of the BlockIO(2) protocol. The subsequent call of the FreePool API: FreePool (*FileEntry); will cause issues. This commit uses a local variable to store the allocated buffer. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Paulo Alcantara <pcacjr@zytor.com>