From: Darrick J. Wong Date: Tue, 4 Jun 2013 01:50:16 +0000 (-0400) Subject: e2fsck: fix journal block tag checksum verification X-Git-Tag: v1.43-WIP-2015-05-18~391 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=bd78b1dae99b0f0d3c5456478c320f5ac0a98584;p=tools%2Fe2fsprogs.git e2fsck: fix journal block tag checksum verification Al Viro complained of a ton of bogosity with regards to the jbd2 block tag header checksum. This one checksum is 16 bits, so cut off the upper 16 bits and treat it as a 16-bit value and don't mess around with be32* conversions. Fortunately metadata checksumming is still "experimental" and not in a shipping e2fsprogs, so there should be few users affected by this. This is the e2fsprogs version of the kernel patch. Reported-by: Al Viro Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c index b04a204..54579c2 100644 --- a/e2fsck/recovery.c +++ b/e2fsck/recovery.c @@ -397,7 +397,8 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf) static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, void *buf, __u32 sequence) { - __u32 provided, calculated; + __u32 calculated; + __u16 provided, crc; if (!JFS_HAS_INCOMPAT_FEATURE(j, JFS_FEATURE_INCOMPAT_CSUM_V2)) return 1; @@ -408,9 +409,10 @@ static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag, calculated = ext2fs_crc32c_le(calculated, (__u8 *)&sequence, sizeof(sequence)); calculated = ext2fs_crc32c_le(calculated, buf, j->j_blocksize) & 0xffff; + crc = calculated & 0xFFFF; provided = ext2fs_be16_to_cpu(tag->t_checksum); - return provided == ext2fs_cpu_to_be32(calculated); + return provided == crc; } static int do_one_pass(journal_t *journal,