summaryrefslogtreecommitdiff
path: root/Features/Ext4Pkg
AgeCommit message (Collapse)AuthorFilesLines
2026-04-04Features/Ext4Pkg: Fix integer overflow in Ext4ReadPhineas Su1-1/+1
The multiplication of Extent.ee_len (UINT16) and Partition->BlockSize (UINT32) was performed using 32-bit arithmetic, which can overflow before being assigned to the 64-bit ExtentLengthBytes variable. This overflow can lead to an incorrect ExtentMayRead value and subsequent out-of-bounds disk reads. Example: If Partition->BlockSize is 0x200000 (2MB) and Extent.ee_len is 0x800, the result of 0x200000 * 0x800 is 0x100000000. In 32-bit arithmetic, this overflows to 0x0. Consequently, ExtentLengthBytes becomes 0, causing ExtentMayRead to be calculated incorrectly (e.g., underflowing when subtracting ExtentOffset) and potentially leading to an out-of-bounds read in Ext4ReadDiskIo. Casting Extent.ee_len to UINT64 ensures the multiplication is performed using 64-bit arithmetic. Signed-off-by: Phineas Su <pohaosu@google.com>
2025-10-30Ext4Pkg: add LoongArch supportAriadne Conill1-1/+1
Validated on Loongson 3A6000-HV-7A2000-1w-V0.1-EVB evaluation board. Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-10-28Ext4Pkg: remove unused variable in collation codeAriadne Conill1-1/+0
Iso639Language is not used anywhere in the code, so GCC flags it as an unused variable. Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
2025-09-13Global: Remove ARM32 SupportOliver Smith-Denny1-1/+1
edk2 is removing support for ARM32, so drop all ARM32 code from edk2-platforms. This does not change code copied from edk2 as-is. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2025-09-08Etxt4Pkg/Ext4Dxe: Deprecate gEfiUnicodeCollationProtocolGuidGowtham M2-17/+3
gEfiUnicodeCollationProtocolGuid was deprecated in favor of a newer version gEfiUnicodeCollation2ProtocolGuid which provides improved language support and better extensibility. It was officially removed from UEFI specifications 2.10A and 2.11 and should no longer be used in current implementations. Cc: Sachin Ganesh <sachinganesh@ami.com> Signed-off-by: Gowtham M <gowthamm@ami.com>
2024-09-24Update to New StackCheckLibOliver Smith-Denny1-5/+0
edk2 PR https://github.com/tianocore/edk2/pull/5957 removed BaseStackCheckLib and added StackCheckLibNull (amongst others). This PR updates all dscs/dsc.incs to remove the old BaseStackCheckLib and if appropriate, add StackCheckLibNull to LibraryClasses.common.SEC or to specific SEC libs. For all other component types, MdeLibs.dsc.inc links them to StackCheckLibNull. This does all dscs at once as it is formulaic and fixes build breaks. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2023-12-04Ext4Pkg: Fix CRC16 checksumming on block groupsPedro Falcato1-5/+1
Old filesystems (around 2008 and older) do not use CRC32c but rather CRC16-ANSI. Previously, the CalculateCrc16Ansi function was broken and gave us wrong checksums. Adapt to the new interface. And while we're at it, fix the checksum algorithm itself - the crc16 algorithm just skips over the bg_checksum, and does not checksum it. This problem was found out-of-list when older ext4 filesystems (that use crc16 checksums) failed to mount with "corruption". BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4609 Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Cc: Savva Mitrofanov <savvamtr@gmail.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-05-09Ext4Pkg: Advertise CSUM_SEED as supportedPedro Falcato1-2/+2
We had added support for CSUM_SEED but accidentally forgot to advertise it in gSupportedIncompatFeat. This made it (erroneously) impossible to mount CSUM_SEED filesystems. Detected by attempting to mount a relatively new mkfs.ext4'd filesystem. Cc: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-05-09Ext4Pkg: Improve extent node validation on the number of entriesPedro Falcato1-4/+28
Improve the extent tree node validation by validating the number of entries the node advertises against the theoretical max (derived from the size of on-disk structs and the block size (or i_data, if inline extents). Previously, we did not validate the number of entries. This could be exploited for out-of-bounds reads and crashes. Cc: Marvin Häuser <mhaeuser@posteo.de> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Reported-by: Savva Mitrofanov <savvamtr@gmail.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-24Ext4Pkg: Move unicode collation initialization to Start()Pedro Falcato2-24/+49
There have been reports[1] of failures to boot due to unicode collation protocols not being available at Ext4Dxe load time. Therefore, attempt to initialize unicode collation at Start() time, like done previously in FatPkg/EnhancedFatDxe. By doing so, we move collation initialization to BDS, where the module responsible for protocol installation should have already been loaded and ran. [1]: https://edk2.groups.io/g/devel/message/100312 Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Marvin Häuser <mhaeuser@posteo.de> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-17Ext4Pkg: Fix double-free in Ext4ReadSymlinkSavva Mitrofanov1-1/+0
The SymlinkTmp was deallocated unconditionally, so we shouldn't free it again on EFI_ERROR Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: e81432fbacb7 ("Ext4Pkg: Add symbolic links support") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2023-02-08Ext4Pkg: Correct memory leak in Ext4ReadSlowSymlinkSavva Mitrofanov1-0/+1
We need to free SymlinkTmp before exiting if SymlinkSizeTmp != ReadSize condition is true. Reported-by: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: e81432fbacb7 ("Ext4Pkg: Add symbolic links support") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2023-02-08Ext4Pkg: Filter out directory entry names containing \0 as invalidSavva Mitrofanov1-1/+8
The directory entry name conventions forbid having null-terminator symbols in its body and can lead to undefined behavior conditions and crashes Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: 89b2bb0db263 ("Ext4Pkg: Fix and clarify handling regarding non-utf8 dir entries") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Fix build on MSVCSavva Mitrofanov2-8/+8
Accessing array using index of uint64 type makes MSVC compiler to include `__allmul` function in NOOPT which is not referenced in IA32. So we null-terminate the string using ReadSize, which should be equal to SymlinkSizeTmp after correct reading. Also add missing MultU64x32 in Ext4Read. Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: 7c46116b0e18 ("Ext4Pkg: Add ext2/3 support") Fixes: e81432fbacb7 ("Ext4Pkg: Add symbolic links support") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2023-02-08Ext4Pkg: Add missing exit status in Ext4OpenDirentSavva Mitrofanov1-1/+2
Missing EFI_OUT_OF_RESOURCES exit status on failed Ext4CreateDentry leads to NULL-pointer dereference in Ext4GetFileInfo (passing NULL buffer in Ext4ReadDir) Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: 21b1853880d5 ("Ext4Pkg: Add a directory entry tree.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeNameSavva Mitrofanov2-3/+9
Missing check in some cases leads to failed StrCpyS call in Ext4GetVolumeLabelInfo. Also correct condition that checks Inode pointer for being NULL in Ext4AllocateInode Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: cfbbae595eec ("Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL GetInfo().") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Check that source file is directory in Ext4OpenInternalSavva Mitrofanov1-4/+9
This check already present in the while loop below, but absent for cases when input file is nameless, so to handle assertion in Ext4ReadFile we need to add it at the top of function Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Correct integer overflow check logic in DiskUtilSavva Mitrofanov3-8/+28
Correct multiplication overflow check code and add additional check for emptiness of number of blocks and block number. Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2023-02-08Ext4Pkg: Fix shift out of bounds in Ext4OpenSuperblockSavva Mitrofanov2-0/+19
Missing check for wrong s_log_block_size exponent leads to shift out of bounds. Limit block size to 2 MiB Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Add inode number validity checkSavva Mitrofanov3-2/+26
We need to validate inode number to prevent reading non-existent and incorrect inodes so we checks that inode number valid across opened partition before we read it in Ext4ReadInode. Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Acked-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Fix division by zero by adding check for s_inodes_per_groupSavva Mitrofanov1-0/+5
Superblock s_inodes_per_group field can't be zero, it leads to division by zero in BlockGroup routine Ext4ReadInode Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Fix incorrect checksum metadata feature checkSavva Mitrofanov1-4/+2
We need to check EXT4_FEATURE_RO_COMPAT_METADATA_CSUM in the FeatureRoCompat field instead of FeaturesCompat. The proper way to do this is to use macro EXT4_HAS_METADATA_CSUM. Also, replace the EXT4_FEATURE_INCOMPAT_CSUM_SEED check with predefined macro EXT4_HAS_INCOMPAT Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-02-08Ext4Pkg: Fix memory leak in Ext4RetrieveDirentSavva Mitrofanov1-14/+16
We need to free buffer on return if BlockRemainder != 0. Also changed return logic from function to use use common exit to prevent code duplication. Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-01-30Ext4Pkg: Redirect internal Open("..", /) to the proper "/"Pedro Falcato1-1/+5
We have been hitting many issues with ".." ASSERTing on / in internal code, so make sure that we direct /.. to /. This is safe. Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Reported-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-01-26Ext4Pkg: Fix typos discovered by SpellCheckMarvin Häuser8-20/+20
Fix typos discovered by SpellCheck, which were discovered as part of the initial CI enablement effort. Cc: Pedro Falcato <pedro.falcato@gmail.com> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2023-01-26Ext4Pkg: Fix and clarify handling regarding non-utf8 dir entriesPedro Falcato2-11/+34
Previously, the handling was mixed and/or non-existent regarding non utf-8 dirent names. Clarify it. Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-01-26Ext4Pkg: Add documentation surrounding ext4 directory entriesPedro Falcato2-5/+21
Several questions have popped up regarding the ext4 directory entry layout and contents off-list. Attempt to clarify these issues by adding some explanatory comments. Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2023-01-26Ext4Pkg: Fix out-of-bounds read in Ext4ReadDirPedro Falcato1-6/+8
Fix an out-of-bounds read inside CompareMem() when checking for "." or ".." by explicitly bounding name_len to [0, 2] beforehand. Reported-by: Savva Mitrofanov <savvamtr@gmail.com> Fixes: 45e37d8533ca8 ("Ext4Pkg: Hide "." and ".." entries from Read() callers.") Cc: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2022-09-16Ext4Pkg: Fix broken stack protector-enabled buildsPedro Falcato1-0/+5
As reported by Rebecca Cran, there was some build breakage when compiling with stack-protector-on-by-default toolchains. Adding the proper library to the DSC should fix it. Cc: Rebecca Cran <rebecca@quicinc.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Rebecca Cran <rebecca@quicinc.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2022-09-15Ext4Pkg: Add base containing record macro for EXT4_FILESavva Mitrofanov2-8/+10
We shouldn't use direct casts, because in the future it could break the code, so using BASE_CR would be safe against possible structure changes and rearrangements Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2022-09-15Ext4Pkg: Add symbolic links supportSavva Mitrofanov6-39/+492
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3677 Provided support for symlink file type. Added routine which allows reading and following them through recursive open() call. As a security meausure implemented simple symlink loop check with nest level limit equal 8. Also this patch moves Ext4Open functionality to internal routine. Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2022-09-06Ext4Pkg: Fix bug in EXT4_HAS_GDT_CSUMPedro Falcato2-3/+3
Caught when running clang-tidy on this code. Also tidies up some logic in BlockGroup.c Cc: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2022-08-07Ext4Pkg: Sanity check the inode sizePedro Falcato1-0/+6
Check its alignment and value for possible bad values. Cc: Marvin Häuser <mhaeuser@posteo.de> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
2022-08-07Ext4Pkg: Code correctness and security improvementsSavva Mitrofanov9-55/+44
This changes tends to improve security of code sections by fixing integer overflows, missing alignment checks, unsafe casts, also simplified some routines, fixed compiler warnings and corrected some code mistakes. - Set HoleLen to UINT64 to prevent truncation in Ext4Read function - Replace EXT4_BLOCK_NR with 32-bit EXT2_BLOCK_NR in BlockMap, because by specification files using block maps must be placed within the first 2^32 blocks of a filesystem - Replace UNREACHABLE with ASSERT (FALSE) in case of new checksum algorithms, due to it is an invariant violation rather than unreachable path - Solve compiler warnings. Initialize all fields in gExt4BindingProtocol Fix comparison of integer expressions of different signedness - Field name_len has type CHAR8, while filename limit is 255 (EXT4_NAME_MAX), so because structure EXT4_DIR_ENTRY would be unchangeable in future, we could drop this check without any assertions - Simplify Ext4RemoveDentry logic by using IsNodeInList - Fix possible int overflow in Ext4ExtentsMapKeyCompare - Return bad block type in Ext4GetBlockpath - Adds 4-byte aligned check for superblock group descriptor size field Cc: Marvin Häuser <mhaeuser@posteo.de> Cc: Pedro Falcato <pedro.falcato@gmail.com> Cc: Vitaly Cheptsov <vit9696@protonmail.com> Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2022-06-14Ext4Pkg: Add ext2/3 supportPedro Falcato7-15/+318
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3745 Adds ext2/3 support by supporting (legacy) block maps. Also fixes a bug regarding uninitialised extents. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
2022-06-14Ext4Pkg: Format using uncrustifyPedro Falcato11-273/+316
Previously, Ext4Pkg was formatted using uncrustify with an older config file. Re-format it using the upstream edk2 uncrustify config file. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
2022-06-14Ext4Pkg: Replace the CRC implementations with BaseLibPedro Falcato5-199/+6
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3871 Since the existing CRC16/CRC32c implementations have been/will be a part of BaseLib, use BaseLib and remove the Crc16.c/Crc32c.c. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
2022-02-02Features/Ext4Pkg: Modularize Ext4 DSC/FDF filesJake Garver5-0/+66
This change modularizes the Ext4 DSC/FDF files following the model used in edk2/NetworkPkg. A platform DSC can include Ext4 using "!include Features/Ext4.dsc.inc". Ext.dsc.inc includes all the required information to enable Ext4 features. Similarly, "!include Features/Ext4.fdf.inc" would be used in the platform FDF. The Ext4 feature is enabled by default, but could be disabled at build time using: BLD_*_EXT4_ENABLE=FALSE Signed-off-by: Jake Garver <jake@nvidia.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2021-12-01Ext4Pkg: Add uninitialized extents supportPedro Falcato4-5/+62
Uninitialized extents are special extents that have blocks allocated, but are specified as uninitialized and therefore, reads behave the same as file holes (reads 0), while writes already have blocks allocated. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2021-09-11Ext4Pkg: Support uncleanly unmounted filesystemsJeff Brasen1-4/+7
Support for uncleanly mounted filesystems, if there is a recovery journal mark filesystem as read-only. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2021-09-11Ext4Pkg: Improve Ext4IsBindingSupported() behaviorJeff Brasen3-11/+92
A couple of improvements to improve performance. Add check to return ACCESS_DENIED if already connected Add check to verify superblock magic during supported to reduce start calls Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
2021-08-24Ext4Pkg: Sanity check more EXT4_DIR_ENTRY values.Pedro Falcato1-39/+51
This should close up some possible exploits using crafted filesystem images. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-24Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL GetInfo().Pedro Falcato3-35/+138
This commit adds support for EFI_FILE_SYSTEM_VOLUME_LABEL requests in GetInfo(). Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-24Ext4Pkg: Add a directory entry tree.Pedro Falcato7-64/+301
This helps us track directories and directory entries, which helps us getting a general idea of how the filesystem looks. In the future, it might serve as a directory cache. Right now, it only lets us know which name "." and ".." may refer to, which fixes a EFI_FILE_PROTOCOL::GetInfo() bug that got triggered by ShellPkg, in some MdePkg code. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-24Ext4Pkg: Hide "." and ".." entries from Read() callers.Pedro Falcato3-10/+41
This makes it so callers that may expect FAT32 filesystems (most do) have more normal looking ReadDir() results. This commit also presents a better filename for files opened through Open("."). Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-24Ext4Pkg: Fix incorrect usage of Ext4InitExtentsMap.Pedro Falcato1-7/+22
Fixes bug triggered by ShellPkg code, in usage of EFI_FILE_PROTOCOL's Open(). Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-19Ext4Pkg: Add .DSC file.Pedro Falcato1-0/+70
This file is required to build Ext4Pkg. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-19Ext4Pkg: Add Ext4Dxe driver.Pedro Falcato16-0/+5904
Adds a UEFI EXT4 filesystem driver that implements the EFI_FILE_PROTOCOL and EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-19Ext4Pkg: Add Ext4Pkg.dec and Ext4Pkg.uni.Pedro Falcato2-0/+31
These files are needed to build Ext4Pkg. Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-19Revert "Ext4Pkg: Add Ext4Pkg.dec and Ext4Pkg.uni." to correct AuthorMichael D Kinney2-31/+0
This reverts commit a282136c45237a07227bd8c9717f16baa767e9a4. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>