Adds 4-byte aligned check for superblock group descriptor size field Cc: Marvin Häuser <mhaeu...@posteo.de> Cc: Pedro Falcato <pedro.falc...@gmail.com> Cc: Vitaly Cheptsov <vit9...@protonmail.com> Signed-off-by: Savva Mitrofanov <savva...@gmail.com> --- Features/Ext4Pkg/Ext4Dxe/Directory.c | 2 +- Features/Ext4Pkg/Ext4Dxe/Superblock.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dxe/Directory.c index d1038c04926e..4441e6d192b6 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -74,7 +74,7 @@ Ext4ValidDirent ( } // Dirent sizes need to be 4 byte aligned - if (Dirent->rec_len % 4) { + if ((Dirent->rec_len % 4) != 0) { return FALSE; } diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c index 42762b6aa780..3bf2e3001f26 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -257,16 +257,16 @@ Ext4OpenSuperblock ( )); if (EXT4_IS_64_BIT (Partition)) { + // s_desc_size should be 4 byte aligned and + // 64 bit filesystems need DescSize to be 64 bytes + if (((Sb->s_desc_size % 4) != 0) || (Sb->s_desc_size < EXT4_64BIT_BLOCK_DESC_SIZE)) { + return EFI_VOLUME_CORRUPTED; + } Partition->DescSize = Sb->s_desc_size; } else { Partition->DescSize = EXT4_OLD_BLOCK_DESC_SIZE; } - if ((Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE) && EXT4_IS_64_BIT (Partition)) { - // 64 bit filesystems need DescSize to be 64 bytes - return EFI_VOLUME_CORRUPTED; - } - if (!Ext4VerifySuperblockChecksum (Partition, Sb)) { DEBUG ((DEBUG_ERROR, "[ext4] Bad superblock checksum %lx\n", Ext4CalculateSuperblockChecksum (Partition, Sb))); return EFI_VOLUME_CORRUPTED; -- 2.37.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91656): https://edk2.groups.io/g/devel/message/91656 Mute This Topic: https://groups.io/mt/92531472/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-