From: "Savva Mitrofanov" <savvamtr@gmail.com>
To: devel@edk2.groups.io
Cc: "Marvin Häuser" <mhaeuser@posteo.de>,
"Pedro Falcato" <pedro.falcato@gmail.com>,
"Vitaly Cheptsov" <vit9696@protonmail.com>
Subject: [edk2-platforms][PATCH 10/10] Ext4Pkg: Group descriptor size must be 4-byte aligned
Date: Tue, 19 Jul 2022 18:10:16 +0600 [thread overview]
Message-ID: <20220719121016.29380-11-savvamtr@gmail.com> (raw)
In-Reply-To: <20220719121016.29380-1-savvamtr@gmail.com>
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>
---
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
next prev parent reply other threads:[~2022-07-19 12:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 12:10 [edk2-platforms][PATCH 00/10] Ext4Pkg: Code security and correctness improvements Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 01/10] Ext4Pkg: Replace SetMem(,,0) with ZeroMem Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 02/10] Ext4Pkg: Change HoleLen type to UINT64 Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 03/10] Ext4Pkg: Use 32-bit block number in BlockMap Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 04/10] Ext4Pkg: Use assertion in Ext4CalculateChecksum Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 05/10] Ext4Pkg: Fix compiler warnings Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 06/10] Ext4Pkg: Drop dir entry name_len limit extra check Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 07/10] Ext4Pkg: Simplify Ext4RemoveDentry logic Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 08/10] Ext4Pkg: Fix possible int overflow in Ext4ExtentsMapKeyCompare Savva Mitrofanov
2022-07-19 12:10 ` [edk2-platforms][PATCH 09/10] Ext4Pkg: Return bad block type in Ext4GetBlockpath Savva Mitrofanov
2022-07-19 12:10 ` Savva Mitrofanov [this message]
2022-07-19 16:19 ` [edk2-platforms][PATCH 00/10] Ext4Pkg: Code security and correctness improvements Pedro Falcato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220719121016.29380-11-savvamtr@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox