jbd2: fix block tag checksum verification brokenness
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. Reported-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:

committed by
Theodore Ts'o

parent
5d9cf9c625
commit
eee06c5678
@@ -399,18 +399,17 @@ 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 csum32;
|
||||
|
||||
if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
|
||||
return 1;
|
||||
|
||||
sequence = cpu_to_be32(sequence);
|
||||
calculated = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&sequence,
|
||||
sizeof(sequence));
|
||||
calculated = jbd2_chksum(j, calculated, buf, j->j_blocksize);
|
||||
provided = be32_to_cpu(tag->t_checksum);
|
||||
csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&sequence,
|
||||
sizeof(sequence));
|
||||
csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
|
||||
|
||||
return provided == cpu_to_be32(calculated);
|
||||
return tag->t_checksum == cpu_to_be16(csum32);
|
||||
}
|
||||
|
||||
static int do_one_pass(journal_t *journal,
|
||||
|
Reference in New Issue
Block a user