From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by mx.groups.io with SMTP id smtpd.web08.8711.1659828080735106536 for ; Sat, 06 Aug 2022 16:21:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jbsWbNMj; spf=pass (domain: gmail.com, ip: 209.85.217.47, mailfrom: pedro.falcato@gmail.com) Received: by mail-vs1-f47.google.com with SMTP id d126so1501791vsd.13 for ; Sat, 06 Aug 2022 16:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=WZ9XvE5TXeptN4Ka6M3g42lr0cuVaQikOf0jIwlqaKg=; b=jbsWbNMj+0n4Nl4scgzr7XpYFwjUPWODKoQZdxLj169fRkVMysnBXwVUdzhxKw9h9i OF2a2n4Tl5zq76SxYFSHi6pfj6hvWDRu2U0TdCm88WJnvN2gPwJFF0n3x1DHb0U6czRa nJNdv6ouaBB4D+OmRw3tzI+dWptkHTmoAjsmYXBFzhOtlIjCtWpq1fwRSuuRpRXMqKz6 O1vmsuzNfk2kc0kwkTRNWQ6/4ArJgroAu9mbZBQLl2W5K6m+s4G1SXTkzZ93VvJcTXUU L6i258HE16awJikzXy3/+jv0qSgfYoxj8xtdu1AOqsjaszHlXGO8OmAt7ZJPVr5ksNEO 0lPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=WZ9XvE5TXeptN4Ka6M3g42lr0cuVaQikOf0jIwlqaKg=; b=hnHol3GQVrgSh+03S1TmRM3skDIBGGTduQK6K8YI5aedZ8lU4KDUXc9WNmYd9OkiU2 5PeTH8Y7D3y1C5XvWkEei8tnGzjlxLsUBwXzC8G17scpYWNusmGk7wlXEHsjnSQNl58k 2/pBPj+5fYSEz0A8erpgkyv2OrLRWo0Hou1pXGrZBq8M6HKGtm7goXvc/5EfPOdpc21M 01jN+EX1ZQy58EAWnU4qfh9r2JXTRq6ioh/SoHdRVMuC5+OEg+z4txvRZAH0b/CUSISM I//OlWRq2eksuA9N08qcFVVvkFRXk1RwZyVtHpQH4exKn9SXjWEgR+WNMZK22n5aD/Du o00w== X-Gm-Message-State: ACgBeo1iMK4kddye3DM4f/CUT+WB4WnX8sRASXbbNaS+y6kUj3Bf6Tf+ XwuDRO4JSwz68tUalidzs+OAzAH2T4KVZVI+pRE= X-Google-Smtp-Source: AA6agR4DQrhms8oGhXuvVLDHPd5UbW1GFw4yG2xN+FmULMTxXFlZ2SoTeBH25l8W8n6QEBTUlM5h7ayqKCGRjfbSYig= X-Received: by 2002:a67:fc06:0:b0:388:955d:2535 with SMTP id o6-20020a67fc06000000b00388955d2535mr2754965vsq.6.1659828079694; Sat, 06 Aug 2022 16:21:19 -0700 (PDT) MIME-Version: 1.0 References: <20220729155417.17255-1-savvamtr@gmail.com> <20220729155417.17255-2-savvamtr@gmail.com> In-Reply-To: <20220729155417.17255-2-savvamtr@gmail.com> From: "Pedro Falcato" Date: Sun, 7 Aug 2022 00:21:08 +0100 Message-ID: Subject: Re: [edk2-platforms][PATCH v3 1/1] Ext4Pkg: Code correctness and security improvements To: Savva Mitrofanov Cc: edk2-devel-groups-io , =?UTF-8?Q?Marvin_H=C3=A4user?= , Vitaly Cheptsov Content-Type: multipart/alternative; boundary="00000000000014183205e59ad7e4" --00000000000014183205e59ad7e4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 29, 2022 at 4:54 PM Savva Mitrofanov wrote= : > 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=C3=A4user > Cc: Pedro Falcato > Cc: Vitaly Cheptsov > Signed-off-by: Savva Mitrofanov > --- > Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 3 +- > Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 2 +- > Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 4 +-- > Features/Ext4Pkg/Ext4Dxe/BlockMap.c | 18 ++++++++---- > Features/Ext4Pkg/Ext4Dxe/Directory.c | 29 ++------------------ > Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 10 ++++--- > Features/Ext4Pkg/Ext4Dxe/Extents.c | 8 ++++-- > Features/Ext4Pkg/Ext4Dxe/Inode.c | 10 +++---- > Features/Ext4Pkg/Ext4Dxe/Superblock.c | 15 +++++----- > 9 files changed, 44 insertions(+), 55 deletions(-) > > diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > index a55cd2fa68ad..7a19d2f79d53 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > @@ -338,7 +338,7 @@ STATIC_ASSERT ( > #define EXT4_TIND_BLOCK 14 > #define EXT4_NR_BLOCKS 15 > > -#define EXT4_GOOD_OLD_INODE_SIZE 128 > +#define EXT4_GOOD_OLD_INODE_SIZE 128U > > typedef struct _Ext4_I_OSD2_Linux { > UINT16 l_i_blocks_high; > @@ -463,6 +463,7 @@ typedef struct { > #define EXT4_EXTENT_MAX_INITIALIZED (1 << 15) > > typedef UINT64 EXT4_BLOCK_NR; > +typedef UINT32 EXT2_BLOCK_NR; > typedef UINT32 EXT4_INO_NR; > > // 2 is always the root inode number in ext4 > diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > index b1508482b0a7..b446488b2112 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > @@ -1165,7 +1165,7 @@ EFI_STATUS > Ext4GetBlocks ( > IN EXT4_PARTITION *Partition, > IN EXT4_FILE *File, > - IN EXT4_BLOCK_NR LogicalBlock, > + IN EXT2_BLOCK_NR LogicalBlock, > OUT EXT4_EXTENT *Extent > ); > > diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c > b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c > index 9a1a41901f36..572e8f60ab92 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c > +++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c > @@ -218,9 +218,9 @@ Ext4CalculateBlockGroupDescChecksum ( > IN UINT32 BlockGroupNum > ) > { > - if (Partition->FeaturesRoCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM= ) > { > + if ((Partition->FeaturesRoCompat & > EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) !=3D 0) { > return Ext4CalculateBlockGroupDescChecksumMetadataCsum (Partition, > BlockGroupDesc, BlockGroupNum); > - } else if (Partition->FeaturesRoCompat & > EXT4_FEATURE_RO_COMPAT_GDT_CSUM) { > + } else if ((Partition->FeaturesRoCompat & > EXT4_FEATURE_RO_COMPAT_GDT_CSUM) !=3D 0) { > return Ext4CalculateBlockGroupDescChecksumGdtCsum (Partition, > BlockGroupDesc, BlockGroupNum); > } > > diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c > b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c > index 1a06ac9fbf86..2bc629fe9d38 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c > +++ b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c > @@ -70,7 +70,7 @@ UINTN > Ext4GetBlockPath ( > IN CONST EXT4_PARTITION *Partition, > IN UINT32 LogicalBlock, > - OUT EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH] > + OUT EXT2_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH] > ) > { > // The logic behind the block map is very much like a page table > @@ -123,7 +123,7 @@ Ext4GetBlockPath ( > break; > default: > // EXT4_TYPE_BAD_BLOCK > - return -1; > + break; > } > > return Type + 1; > @@ -213,12 +213,12 @@ EFI_STATUS > Ext4GetBlocks ( > IN EXT4_PARTITION *Partition, > IN EXT4_FILE *File, > - IN EXT4_BLOCK_NR LogicalBlock, > + IN EXT2_BLOCK_NR LogicalBlock, > OUT EXT4_EXTENT *Extent > ) > { > EXT4_INODE *Inode; > - EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH]; > + EXT2_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH]; > UINTN BlockPathLength; > UINTN Index; > UINT32 *Buffer; > @@ -230,7 +230,7 @@ Ext4GetBlocks ( > > BlockPathLength =3D Ext4GetBlockPath (Partition, LogicalBlock, BlockPa= th); > > - if (BlockPathLength =3D=3D (UINTN)-1) { > + if (BlockPathLength - 1 =3D=3D EXT4_TYPE_BAD_BLOCK) { > // Bad logical block (out of range) > return EFI_NO_MAPPING; > } > @@ -272,7 +272,13 @@ Ext4GetBlocks ( > } > } > > - Ext4GetExtentInBlockMap (Buffer, Partition->BlockSize / sizeof > (UINT32), BlockPath[BlockPathLength - 1], Extent); > + Ext4GetExtentInBlockMap ( > + Buffer, > + Partition->BlockSize / sizeof (UINT32), > + BlockPath[BlockPathLength - 1], > + Extent > + ); > + > FreePool (Buffer); > > return EFI_SUCCESS; > diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c > b/Features/Ext4Pkg/Ext4Dxe/Directory.c > index 682f66ad5525..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) !=3D 0) { > return FALSE; > } > > @@ -160,17 +160,6 @@ Ext4RetrieveDirent ( > return EFI_VOLUME_CORRUPTED; > } > > - // Ignore names bigger than our limit. > - > - /* Note: I think having a limit is sane because: > - 1) It's nicer to work with. > - 2) Linux and a number of BSDs also have a filename limit of 255. > - */ > - if (Entry->name_len > EXT4_NAME_MAX) { > - BlockOffset +=3D Entry->rec_len; > - continue; > - } > - > // Unused entry > if (Entry->inode =3D=3D 0) { > BlockOffset +=3D Entry->rec_len; > @@ -548,20 +537,8 @@ Ext4RemoveDentry ( > IN OUT EXT4_DENTRY *ToBeRemoved > ) > { > - EXT4_DENTRY *D; > - LIST_ENTRY *Entry; > - LIST_ENTRY *NextEntry; > - > - BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Parent->Children) { > - D =3D EXT4_DENTRY_FROM_DENTRY_LIST (Entry); > - > - if (D =3D=3D ToBeRemoved) { > - RemoveEntryList (Entry); > - return; > - } > - } > - > - DEBUG ((DEBUG_ERROR, "[ext4] Ext4RemoveDentry did not find the > asked-for dentry\n")); > + ASSERT (IsNodeInList (&ToBeRemoved->ListNode, &Parent->Children)); > + RemoveEntryList (&ToBeRemoved->ListNode); > } > > /** > diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c > b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c > index 43b9340d3956..2a4f5a7bd0ef 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c > @@ -260,10 +260,12 @@ Ext4Stop ( > > EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol =3D > { > - Ext4IsBindingSupported, > - Ext4Bind, > - Ext4Stop, > - EXT4_DRIVER_VERSION > + .Supported =3D Ext4IsBindingSupported, > + .Start =3D Ext4Bind, > + .Stop =3D Ext4Stop, > + .Version =3D EXT4_DRIVER_VERSION, > + .ImageHandle =3D NULL, > + .DriverBindingHandle =3D NULL > }; > > /** > diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c > b/Features/Ext4Pkg/Ext4Dxe/Extents.c > index c3874df71751..369879e07fe7 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Extents.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c > @@ -257,9 +257,11 @@ Ext4GetExtent ( > return EFI_SUCCESS; > } > > - if (!(Inode->i_flags & EXT4_EXTENTS_FL)) { > + if ((Inode->i_flags & EXT4_EXTENTS_FL) =3D=3D 0) { > // If this is an older ext2/ext3 filesystem, emulate Ext4GetExtent > using the block map > - Status =3D Ext4GetBlocks (Partition, File, LogicalBlock, Extent); > + // By specification files using block maps must be placed within the > first 2^32 blocks > + // of a filesystem, so we can safely cast LogicalBlock to uint32 > + Status =3D Ext4GetBlocks (Partition, File, (UINT32)LogicalBlock, > Extent); > This comment is wrong. It should read something like "Files using block maps are limited to 2^32 blocks, so we can safely...". I'll fix this up myself since this is minor and the rest LGTM. > > if (!EFI_ERROR (Status)) { > Ext4CacheExtents (File, Extent, 1); > @@ -420,7 +422,7 @@ Ext4ExtentsMapKeyCompare ( > Extent =3D UserStruct; > Block =3D (UINT32)(UINTN)StandaloneKey; > > - if ((Block >=3D Extent->ee_block) && (Block < Extent->ee_block + > Ext4GetExtentLength (Extent))) { > + if ((Block >=3D Extent->ee_block) && (Block - Extent->ee_block < > Ext4GetExtentLength (Extent))) { > return 0; > } > > diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c > b/Features/Ext4Pkg/Ext4Dxe/Inode.c > index 831f5946e870..7f8be2f02643 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c > @@ -100,7 +100,7 @@ Ext4Read ( > EFI_STATUS Status; > BOOLEAN HasBackingExtent; > UINT32 HoleOff; > - UINTN HoleLen; > + UINT64 HoleLen; > UINT64 ExtentStartBytes; > UINT64 ExtentLengthBytes; > UINT64 ExtentLogicalBytes; > @@ -155,10 +155,10 @@ Ext4Read ( > HoleLen =3D (Ext4GetExtentLength (&Extent) * Partition->BlockSiz= e) > - HoleOff; > } > > - WasRead =3D HoleLen > RemainingRead ? RemainingRead : HoleLen; > + WasRead =3D HoleLen > RemainingRead ? RemainingRead : (UINTN)HoleL= en; > // Potential improvement: In the future, we could get the file > hole's total > // size and memset all that > - SetMem (Buffer, WasRead, 0); > + ZeroMem (Buffer, WasRead); > } else { > ExtentStartBytes =3D MultU64x32 ( > LShiftU64 (Extent.ee_start_hi, 32) | > @@ -291,7 +291,7 @@ Ext4FilePhysicalSpace ( > > // If HUGE_FILE is enabled and EXT4_HUGE_FILE_FL is set in the > inode's flags, each unit > // in i_blocks corresponds to an actual filesystem block > - if (File->Inode->i_flags & EXT4_HUGE_FILE_FL) { > + if ((File->Inode->i_flags & EXT4_HUGE_FILE_FL) !=3D 0) { > return MultU64x32 (Blocks, File->Partition->BlockSize); > } > } > @@ -431,7 +431,7 @@ Ext4FileCreateTime ( > Inode =3D File->Inode; > > if (!EXT4_INODE_HAS_FIELD (Inode, i_crtime)) { > - SetMem (Time, sizeof (EFI_TIME), 0); > + ZeroMem (Time, sizeof (EFI_TIME)); > return; > } > > diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c > b/Features/Ext4Pkg/Ext4Dxe/Superblock.c > index 47fc3a65507a..c22155ba11b4 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c > @@ -220,7 +220,7 @@ Ext4OpenSuperblock ( > return EFI_UNSUPPORTED; > } > > - if (Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM_SEED) { > + if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM_SEED) != =3D > 0) { > Partition->InitialSeed =3D Sb->s_checksum_seed; > } else { > Partition->InitialSeed =3D Ext4CalculateChecksum (Partition, > Sb->s_uuid, 16, ~0U); > @@ -257,16 +257,17 @@ 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) !=3D 0) || (Sb->s_desc_size < > EXT4_64BIT_BLOCK_DESC_SIZE)) { > + return EFI_VOLUME_CORRUPTED; > + } > + > Partition->DescSize =3D Sb->s_desc_size; > } else { > Partition->DescSize =3D 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; > @@ -342,7 +343,7 @@ Ext4CalculateChecksum ( > // For some reason, EXT4 really likes non-inverted CRC32C > checksums, so we stick to that here. > return ~CalculateCrc32c(Buffer, Length, ~InitialValue); > default: > - UNREACHABLE (); > + ASSERT (FALSE); > return 0; > } > } > -- > 2.37.1 > > Overall, LGTM. Reviewed-by: Pedro Falcato --=20 Pedro Falcato --00000000000014183205e59ad7e4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Jul 29, 2022 at 4:54 PM Savva= Mitrofanov <savvamtr@gmail.com> wrote:
Thi= s 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=C3=A4user <
mhaeuser@posteo.de>
Cc: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
---
=C2=A0Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h=C2=A0 =C2=A0|=C2=A0 3 +-
=C2=A0Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h=C2=A0 =C2=A0 |=C2=A0 2 +-
=C2=A0Features/Ext4Pkg/Ext4Dxe/BlockGroup.c |=C2=A0 4 +--
=C2=A0Features/Ext4Pkg/Ext4Dxe/BlockMap.c=C2=A0 =C2=A0| 18 ++++++++----
=C2=A0Features/Ext4Pkg/Ext4Dxe/Directory.c=C2=A0 | 29 ++------------------<= br> =C2=A0Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c=C2=A0 =C2=A0 | 10 ++++---
=C2=A0Features/Ext4Pkg/Ext4Dxe/Extents.c=C2=A0 =C2=A0 |=C2=A0 8 ++++--
=C2=A0Features/Ext4Pkg/Ext4Dxe/Inode.c=C2=A0 =C2=A0 =C2=A0 | 10 +++----
=C2=A0Features/Ext4Pkg/Ext4Dxe/Superblock.c | 15 +++++-----
=C2=A09 files changed, 44 insertions(+), 55 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h
index a55cd2fa68ad..7a19d2f79d53 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h
@@ -338,7 +338,7 @@ STATIC_ASSERT (
=C2=A0#define EXT4_TIND_BLOCK=C2=A0 14
=C2=A0#define EXT4_NR_BLOCKS=C2=A0 =C2=A015

-#define EXT4_GOOD_OLD_INODE_SIZE=C2=A0 128
+#define EXT4_GOOD_OLD_INODE_SIZE=C2=A0 128U

=C2=A0typedef struct _Ext4_I_OSD2_Linux {
=C2=A0 =C2=A0UINT16=C2=A0 =C2=A0 l_i_blocks_high;
@@ -463,6 +463,7 @@ typedef struct {
=C2=A0#define EXT4_EXTENT_MAX_INITIALIZED=C2=A0 (1 << 15)

=C2=A0typedef UINT64=C2=A0 EXT4_BLOCK_NR;
+typedef UINT32=C2=A0 EXT2_BLOCK_NR;
=C2=A0typedef UINT32=C2=A0 EXT4_INO_NR;

=C2=A0// 2 is always the root inode number in ext4
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h
index b1508482b0a7..b446488b2112 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1165,7 +1165,7 @@ EFI_STATUS
=C2=A0Ext4GetBlocks (
=C2=A0 =C2=A0IN=C2=A0 EXT4_PARTITION=C2=A0 *Partition,
=C2=A0 =C2=A0IN=C2=A0 EXT4_FILE=C2=A0 =C2=A0 =C2=A0 =C2=A0*File,
-=C2=A0 IN=C2=A0 EXT4_BLOCK_NR=C2=A0 =C2=A0LogicalBlock,
+=C2=A0 IN=C2=A0 EXT2_BLOCK_NR=C2=A0 =C2=A0LogicalBlock,
=C2=A0 =C2=A0OUT EXT4_EXTENT=C2=A0 =C2=A0 =C2=A0*Extent
=C2=A0 =C2=A0);

diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c b/Features/Ext4Pkg/Ext4D= xe/BlockGroup.c
index 9a1a41901f36..572e8f60ab92 100644
--- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
+++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
@@ -218,9 +218,9 @@ Ext4CalculateBlockGroupDescChecksum (
=C2=A0 =C2=A0IN UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BlockGroupNum
=C2=A0 =C2=A0)
=C2=A0{
-=C2=A0 if (Partition->FeaturesRoCompat & EXT4_FEATURE_RO_COMPAT_MET= ADATA_CSUM) {
+=C2=A0 if ((Partition->FeaturesRoCompat & EXT4_FEATURE_RO_COMPAT_ME= TADATA_CSUM) !=3D 0) {
=C2=A0 =C2=A0 =C2=A0return Ext4CalculateBlockGroupDescChecksumMetadataCsum = (Partition, BlockGroupDesc, BlockGroupNum);
-=C2=A0 } else if (Partition->FeaturesRoCompat & EXT4_FEATURE_RO_COM= PAT_GDT_CSUM) {
+=C2=A0 } else if ((Partition->FeaturesRoCompat & EXT4_FEATURE_RO_CO= MPAT_GDT_CSUM) !=3D 0) {
=C2=A0 =C2=A0 =C2=A0return Ext4CalculateBlockGroupDescChecksumGdtCsum (Part= ition, BlockGroupDesc, BlockGroupNum);
=C2=A0 =C2=A0}

diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c b/Features/Ext4Pkg/Ext4Dxe= /BlockMap.c
index 1a06ac9fbf86..2bc629fe9d38 100644
--- a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c
+++ b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c
@@ -70,7 +70,7 @@ UINTN
=C2=A0Ext4GetBlockPath (
=C2=A0 =C2=A0IN=C2=A0 CONST EXT4_PARTITION=C2=A0 *Partition,
=C2=A0 =C2=A0IN=C2=A0 UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 LogicalBlock,
-=C2=A0 OUT EXT4_BLOCK_NR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BlockPath[EXT4_M= AX_BLOCK_PATH]
+=C2=A0 OUT EXT2_BLOCK_NR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BlockPath[EXT4_M= AX_BLOCK_PATH]
=C2=A0 =C2=A0)
=C2=A0{
=C2=A0 =C2=A0// The logic behind the block map is very much like a page tab= le
@@ -123,7 +123,7 @@ Ext4GetBlockPath (
=C2=A0 =C2=A0 =C2=A0 =C2=A0break;
=C2=A0 =C2=A0 =C2=A0default:
=C2=A0 =C2=A0 =C2=A0 =C2=A0// EXT4_TYPE_BAD_BLOCK
-=C2=A0 =C2=A0 =C2=A0 return -1;
+=C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0}

=C2=A0 =C2=A0return Type + 1;
@@ -213,12 +213,12 @@ EFI_STATUS
=C2=A0Ext4GetBlocks (
=C2=A0 =C2=A0IN=C2=A0 EXT4_PARTITION=C2=A0 *Partition,
=C2=A0 =C2=A0IN=C2=A0 EXT4_FILE=C2=A0 =C2=A0 =C2=A0 =C2=A0*File,
-=C2=A0 IN=C2=A0 EXT4_BLOCK_NR=C2=A0 =C2=A0LogicalBlock,
+=C2=A0 IN=C2=A0 EXT2_BLOCK_NR=C2=A0 =C2=A0LogicalBlock,
=C2=A0 =C2=A0OUT EXT4_EXTENT=C2=A0 =C2=A0 =C2=A0*Extent
=C2=A0 =C2=A0)
=C2=A0{
=C2=A0 =C2=A0EXT4_INODE=C2=A0 =C2=A0 =C2=A0*Inode;
-=C2=A0 EXT4_BLOCK_NR=C2=A0 BlockPath[EXT4_MAX_BLOCK_PATH];
+=C2=A0 EXT2_BLOCK_NR=C2=A0 BlockPath[EXT4_MAX_BLOCK_PATH];
=C2=A0 =C2=A0UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BlockPathLength;
=C2=A0 =C2=A0UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Index;
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*Buffer;
@@ -230,7 +230,7 @@ Ext4GetBlocks (

=C2=A0 =C2=A0BlockPathLength =3D Ext4GetBlockPath (Partition, LogicalBlock,= BlockPath);

-=C2=A0 if (BlockPathLength =3D=3D (UINTN)-1) {
+=C2=A0 if (BlockPathLength - 1 =3D=3D EXT4_TYPE_BAD_BLOCK) {
=C2=A0 =C2=A0 =C2=A0// Bad logical block (out of range)
=C2=A0 =C2=A0 =C2=A0return EFI_NO_MAPPING;
=C2=A0 =C2=A0}
@@ -272,7 +272,13 @@ Ext4GetBlocks (
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0}

-=C2=A0 Ext4GetExtentInBlockMap (Buffer, Partition->BlockSize / sizeof (= UINT32), BlockPath[BlockPathLength - 1], Extent);
+=C2=A0 Ext4GetExtentInBlockMap (
+=C2=A0 =C2=A0 Buffer,
+=C2=A0 =C2=A0 Partition->BlockSize / sizeof (UINT32),
+=C2=A0 =C2=A0 BlockPath[BlockPathLength - 1],
+=C2=A0 =C2=A0 Extent
+=C2=A0 =C2=A0 );
+
=C2=A0 =C2=A0FreePool (Buffer);

=C2=A0 =C2=A0return EFI_SUCCESS;
diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c
index 682f66ad5525..4441e6d192b6 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Directory.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c
@@ -74,7 +74,7 @@ Ext4ValidDirent (
=C2=A0 =C2=A0}

=C2=A0 =C2=A0// Dirent sizes need to be 4 byte aligned
-=C2=A0 if (Dirent->rec_len % 4) {
+=C2=A0 if ((Dirent->rec_len % 4) !=3D 0) {
=C2=A0 =C2=A0 =C2=A0return FALSE;
=C2=A0 =C2=A0}

@@ -160,17 +160,6 @@ Ext4RetrieveDirent (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return EFI_VOLUME_CORRUPTED;
=C2=A0 =C2=A0 =C2=A0 =C2=A0}

-=C2=A0 =C2=A0 =C2=A0 // Ignore names bigger than our limit.
-
-=C2=A0 =C2=A0 =C2=A0 /* Note: I think having a limit is sane because:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 1) It's nicer to work with.
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 2) Linux and a number of BSDs also have a file= name limit of 255.
-=C2=A0 =C2=A0 =C2=A0 */
-=C2=A0 =C2=A0 =C2=A0 if (Entry->name_len > EXT4_NAME_MAX) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 BlockOffset +=3D Entry->rec_len;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 continue;
-=C2=A0 =C2=A0 =C2=A0 }
-
=C2=A0 =C2=A0 =C2=A0 =C2=A0// Unused entry
=C2=A0 =C2=A0 =C2=A0 =C2=A0if (Entry->inode =3D=3D 0) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BlockOffset +=3D Entry->rec_len;
@@ -548,20 +537,8 @@ Ext4RemoveDentry (
=C2=A0 =C2=A0IN OUT EXT4_DENTRY=C2=A0 *ToBeRemoved
=C2=A0 =C2=A0)
=C2=A0{
-=C2=A0 EXT4_DENTRY=C2=A0 *D;
-=C2=A0 LIST_ENTRY=C2=A0 =C2=A0*Entry;
-=C2=A0 LIST_ENTRY=C2=A0 =C2=A0*NextEntry;
-
-=C2=A0 BASE_LIST_FOR_EACH_SAFE (Entry, NextEntry, &Parent->Children= ) {
-=C2=A0 =C2=A0 D =3D EXT4_DENTRY_FROM_DENTRY_LIST (Entry);
-
-=C2=A0 =C2=A0 if (D =3D=3D ToBeRemoved) {
-=C2=A0 =C2=A0 =C2=A0 RemoveEntryList (Entry);
-=C2=A0 =C2=A0 =C2=A0 return;
-=C2=A0 =C2=A0 }
-=C2=A0 }
-
-=C2=A0 DEBUG ((DEBUG_ERROR, "[ext4] Ext4RemoveDentry did not find the= asked-for dentry\n"));
+=C2=A0 ASSERT (IsNodeInList (&ToBeRemoved->ListNode, &Parent-&g= t;Children));
+=C2=A0 RemoveEntryList (&ToBeRemoved->ListNode);
=C2=A0}

=C2=A0/**
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.c
index 43b9340d3956..2a4f5a7bd0ef 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
@@ -260,10 +260,12 @@ Ext4Stop (

=C2=A0EFI_DRIVER_BINDING_PROTOCOL=C2=A0 gExt4BindingProtocol =3D
=C2=A0{
-=C2=A0 Ext4IsBindingSupported,
-=C2=A0 Ext4Bind,
-=C2=A0 Ext4Stop,
-=C2=A0 EXT4_DRIVER_VERSION
+=C2=A0 .Supported=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D Ext4IsBindin= gSupported,
+=C2=A0 .Start=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D Ex= t4Bind,
+=C2=A0 .Stop=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D Ex= t4Stop,
+=C2=A0 .Version=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D EXT4_DR= IVER_VERSION,
+=C2=A0 .ImageHandle=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D NULL,
+=C2=A0 .DriverBindingHandle =3D NULL
=C2=A0};

=C2=A0/**
diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c b/Features/Ext4Pkg/Ext4Dxe/= Extents.c
index c3874df71751..369879e07fe7 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Extents.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c
@@ -257,9 +257,11 @@ Ext4GetExtent (
=C2=A0 =C2=A0 =C2=A0return EFI_SUCCESS;
=C2=A0 =C2=A0}

-=C2=A0 if (!(Inode->i_flags & EXT4_EXTENTS_FL)) {
+=C2=A0 if ((Inode->i_flags & EXT4_EXTENTS_FL) =3D=3D 0) {
=C2=A0 =C2=A0 =C2=A0// If this is an older ext2/ext3 filesystem, emulate Ex= t4GetExtent using the block map
-=C2=A0 =C2=A0 Status =3D Ext4GetBlocks (Partition, File, LogicalBlock, Ext= ent);
+=C2=A0 =C2=A0 // By specification files using block maps must be placed wi= thin the first 2^32 blocks
+=C2=A0 =C2=A0 // of a filesystem, so we can safely cast LogicalBlock to ui= nt32
+=C2=A0 =C2=A0 Status =3D Ext4GetBlocks (Partition, File, (UINT32)LogicalBl= ock, Extent);
This comment is wrong. It should read so= mething like "Files using block maps are limited to 2^32 blocks, so we= can safely...". I'll fix this up myself since this is minor and t= he rest LGTM.

=C2=A0 =C2=A0 =C2=A0if (!EFI_ERROR (Status)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0Ext4CacheExtents (File, Extent, 1);
@@ -420,7 +422,7 @@ Ext4ExtentsMapKeyCompare (
=C2=A0 =C2=A0Extent =3D UserStruct;
=C2=A0 =C2=A0Block=C2=A0 =3D (UINT32)(UINTN)StandaloneKey;

-=C2=A0 if ((Block >=3D Extent->ee_block) && (Block < Exte= nt->ee_block + Ext4GetExtentLength (Extent))) {
+=C2=A0 if ((Block >=3D Extent->ee_block) && (Block - Extent-= >ee_block < Ext4GetExtentLength (Extent))) {
=C2=A0 =C2=A0 =C2=A0return 0;
=C2=A0 =C2=A0}

diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/In= ode.c
index 831f5946e870..7f8be2f02643 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Inode.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c
@@ -100,7 +100,7 @@ Ext4Read (
=C2=A0 =C2=A0EFI_STATUS=C2=A0 =C2=A0Status;
=C2=A0 =C2=A0BOOLEAN=C2=A0 =C2=A0 =C2=A0 HasBackingExtent;
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0HoleOff;
-=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 HoleLen;
+=C2=A0 UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0HoleLen;
=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0ExtentStartBytes;
=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0ExtentLengthBytes;
=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0ExtentLogicalBytes;
@@ -155,10 +155,10 @@ Ext4Read (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0HoleLen =3D (Ext4GetExtentLength (&Ex= tent) * Partition->BlockSize) - HoleOff;
=C2=A0 =C2=A0 =C2=A0 =C2=A0}

-=C2=A0 =C2=A0 =C2=A0 WasRead =3D HoleLen > RemainingRead ? RemainingRea= d : HoleLen;
+=C2=A0 =C2=A0 =C2=A0 WasRead =3D HoleLen > RemainingRead ? RemainingRea= d : (UINTN)HoleLen;
=C2=A0 =C2=A0 =C2=A0 =C2=A0// Potential improvement: In the future, we coul= d get the file hole's total
=C2=A0 =C2=A0 =C2=A0 =C2=A0// size and memset all that
-=C2=A0 =C2=A0 =C2=A0 SetMem (Buffer, WasRead, 0);
+=C2=A0 =C2=A0 =C2=A0 ZeroMem (Buffer, WasRead);
=C2=A0 =C2=A0 =C2=A0} else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0ExtentStartBytes =3D MultU64x32 (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 LShiftU64 (Extent.ee_start_hi, 32) |
@@ -291,7 +291,7 @@ Ext4FilePhysicalSpace (

=C2=A0 =C2=A0 =C2=A0// If HUGE_FILE is enabled and EXT4_HUGE_FILE_FL is set= in the inode's flags, each unit
=C2=A0 =C2=A0 =C2=A0// in i_blocks corresponds to an actual filesystem bloc= k
-=C2=A0 =C2=A0 if (File->Inode->i_flags & EXT4_HUGE_FILE_FL) { +=C2=A0 =C2=A0 if ((File->Inode->i_flags & EXT4_HUGE_FILE_FL) != =3D 0) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0return MultU64x32 (Blocks, File->Partition-&g= t;BlockSize);
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0}
@@ -431,7 +431,7 @@ Ext4FileCreateTime (
=C2=A0 =C2=A0Inode =3D File->Inode;

=C2=A0 =C2=A0if (!EXT4_INODE_HAS_FIELD (Inode, i_crtime)) {
-=C2=A0 =C2=A0 SetMem (Time, sizeof (EFI_TIME), 0);
+=C2=A0 =C2=A0 ZeroMem (Time, sizeof (EFI_TIME));
=C2=A0 =C2=A0 =C2=A0return;
=C2=A0 =C2=A0}

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c
index 47fc3a65507a..c22155ba11b4 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -220,7 +220,7 @@ Ext4OpenSuperblock (
=C2=A0 =C2=A0 =C2=A0return EFI_UNSUPPORTED;
=C2=A0 =C2=A0}

-=C2=A0 if (Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM= _SEED) {
+=C2=A0 if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSU= M_SEED) !=3D 0) {
=C2=A0 =C2=A0 =C2=A0Partition->InitialSeed =3D Sb->s_checksum_seed; =C2=A0 =C2=A0} else {
=C2=A0 =C2=A0 =C2=A0Partition->InitialSeed =3D Ext4CalculateChecksum (Pa= rtition, Sb->s_uuid, 16, ~0U);
@@ -257,16 +257,17 @@ Ext4OpenSuperblock (
=C2=A0 =C2=A0 =C2=A0));

=C2=A0 =C2=A0if (EXT4_IS_64_BIT (Partition)) {
+=C2=A0 =C2=A0 // s_desc_size should be 4 byte aligned and
+=C2=A0 =C2=A0 // 64 bit filesystems need DescSize to be 64 bytes
+=C2=A0 =C2=A0 if (((Sb->s_desc_size % 4) !=3D 0) || (Sb->s_desc_size= < EXT4_64BIT_BLOCK_DESC_SIZE)) {
+=C2=A0 =C2=A0 =C2=A0 return EFI_VOLUME_CORRUPTED;
+=C2=A0 =C2=A0 }
+
=C2=A0 =C2=A0 =C2=A0Partition->DescSize =3D Sb->s_desc_size;
=C2=A0 =C2=A0} else {
=C2=A0 =C2=A0 =C2=A0Partition->DescSize =3D EXT4_OLD_BLOCK_DESC_SIZE; =C2=A0 =C2=A0}

-=C2=A0 if ((Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE) &&= amp; EXT4_IS_64_BIT (Partition)) {
-=C2=A0 =C2=A0 // 64 bit filesystems need DescSize to be 64 bytes
-=C2=A0 =C2=A0 return EFI_VOLUME_CORRUPTED;
-=C2=A0 }
-
=C2=A0 =C2=A0if (!Ext4VerifySuperblockChecksum (Partition, Sb)) {
=C2=A0 =C2=A0 =C2=A0DEBUG ((DEBUG_ERROR, "[ext4] Bad superblock checks= um %lx\n", Ext4CalculateSuperblockChecksum (Partition, Sb)));
=C2=A0 =C2=A0 =C2=A0return EFI_VOLUME_CORRUPTED;
@@ -342,7 +343,7 @@ Ext4CalculateChecksum (
=C2=A0 =C2=A0 =C2=A0 =C2=A0// For some reason, EXT4 really likes non-invert= ed CRC32C checksums, so we stick to that here.
=C2=A0 =C2=A0 =C2=A0 =C2=A0return ~CalculateCrc32c(Buffer, Length, ~Initial= Value);
=C2=A0 =C2=A0 =C2=A0default:
-=C2=A0 =C2=A0 =C2=A0 UNREACHABLE ();
+=C2=A0 =C2=A0 =C2=A0 ASSERT (FALSE);
=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
=C2=A0 =C2=A0}
=C2=A0}
--
2.37.1

Overall, LGTM.

Reviewed-by= : Pedro Falcato <pedro.falcat= o@gmail.com>

--
Pedro Falcato
--00000000000014183205e59ad7e4--