From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CA5E1AC1B5C for ; Sun, 3 Dec 2023 22:41:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=z0v1S37dNjIDR5wIINo3A+ti5egbNRZdzuVGT+qTdqk=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1701643264; v=1; b=lvgjPeuIr7+WbNqVmeT8QPdi/rijT+/HSBv6mhbb6Zs+7wQlh0rmTx0WfzpdvzqHgu0SsIuI klr5JTBAJlU5bEuFvGWz/Hj/SvVsufalcHJU21I6eycwG4J3dsHp25XrDiWmlf3xOJsjjz0yU4S j6UPEq6hFnB6ZwfmTJQyC1Pg= X-Received: by 127.0.0.2 with SMTP id mmL7YY7687511xSs99RzyTQV; Sun, 03 Dec 2023 14:41:04 -0800 X-Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web10.50794.1701643263562259723 for ; Sun, 03 Dec 2023 14:41:03 -0800 X-Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40c09f5a7cfso6773275e9.0 for ; Sun, 03 Dec 2023 14:41:03 -0800 (PST) X-Gm-Message-State: D87R6oKXu3x8wvQL27VrGrBwx7686176AA= X-Google-Smtp-Source: AGHT+IFUHYORKPcTlUXIJU8RVKlvy4U+hzh7CN4b5h2u6wetE5olEWimFOHu6vZkq6AgYlNkHtSnDA== X-Received: by 2002:a05:600c:2282:b0:40b:5e59:ea07 with SMTP id 2-20020a05600c228200b0040b5e59ea07mr1928684wmf.166.1701643261485; Sun, 03 Dec 2023 14:41:01 -0800 (PST) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id o17-20020a5d58d1000000b003333af25cb2sm4697685wrf.66.2023.12.03.14.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 14:41:01 -0800 (PST) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Pedro Falcato , Savva Mitrofanov , =?UTF-8?q?Marvin=20H=C3=A4user?= Subject: [edk2-devel] [PATCH] Ext4Pkg: Fix CRC16 checksumming on block groups Date: Sun, 3 Dec 2023 22:40:59 +0000 Message-ID: <20231203224059.23277-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=lvgjPeuI; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 Cc: Savva Mitrofanov Cc: Marvin Häuser --- 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 (#111997): https://edk2.groups.io/g/devel/message/111997 Mute This Topic: https://groups.io/mt/102960519/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-