]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
fs/ext4: Fix group descriptor checksum calculation
authorTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Mon, 25 Sep 2017 19:06:31 +0000 (22:06 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 6 Oct 2017 15:28:18 +0000 (11:28 -0400)
The current code doesn't compute the group descriptor checksum correctly
for the filesystems that e2fsprogs 1.43.4 creates (they have
'Group descriptor size: 64' as reported by tune2fs). Extend the checksum
calculation to be done as ext4_group_desc_csum() does in Linux.

This fixes these errors in dmesg from running fs-test.sh and makes it
succeed again:

[1671902.620699] EXT4-fs (loop1): ext4_check_descriptors: Checksum for group 0 failed (35782!=10965)
[1671902.620706] EXT4-fs (loop1): group descriptors corrupted!

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
fs/ext4/ext4_common.c

index 621c61e5c7915529cf0bc92a7ab7d3fc31adc1c1..31952f48b90d50b3af6c119540247a486b596a99 100644 (file)
@@ -432,6 +432,10 @@ uint16_t ext4fs_checksum_update(uint32_t i)
                crc = ext2fs_crc16(crc, desc, offset);
                offset += sizeof(desc->bg_checksum);    /* skip checksum */
                assert(offset == sizeof(*desc));
+               if (offset < fs->gdsize) {
+                       crc = ext2fs_crc16(crc, (__u8 *)desc + offset,
+                                          fs->gdsize - offset);
+               }
        }
 
        return crc;