Reviewed-by: Marvin Häuser <mhaeu...@posteo.de>

> On Dec 3, 2023, at 23:41, Pedro Falcato <pedro.falc...@gmail.com> wrote:
> 
> 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.falc...@gmail.com>
> Cc: Savva Mitrofanov <savva...@gmail.com>
> Cc: Marvin Häuser <mhaeu...@posteo.de>
> ---
> Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c 
> b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
> index f34cdc5dbad7..d5642a5f155c 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c
> @@ -169,14 +169,10 @@ Ext4CalculateBlockGroupDescChecksumGdtCsum (
>   )
> {
>   UINT16  Csum;
> -  UINT16  Dummy;
> 
> -  Dummy = 0;
> -
> -  Csum = CalculateCrc16Ansi (Partition->SuperBlock.s_uuid, 16, 0);
> +  Csum = CalculateCrc16Ansi (Partition->SuperBlock.s_uuid, 16, 
> CRC16ANSI_INIT);
>   Csum = CalculateCrc16Ansi (&BlockGroupNum, sizeof (BlockGroupNum), Csum);
>   Csum = CalculateCrc16Ansi (BlockGroupDesc, OFFSET_OF 
> (EXT4_BLOCK_GROUP_DESC, bg_checksum), Csum);
> -  Csum = CalculateCrc16Ansi (&Dummy, sizeof (Dummy), Csum);
>   Csum =
>     CalculateCrc16Ansi (
>       &BlockGroupDesc->bg_block_bitmap_hi,
> --
> 2.43.0
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111998): https://edk2.groups.io/g/devel/message/111998
Mute This Topic: https://groups.io/mt/102960519/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to