From: Darrick J. Wong Date: Thu, 11 Sep 2014 15:44:36 +0000 (-0400) Subject: ext4: validate external journal superblock checksum X-Git-Tag: firefly_0821_release~176^2~2990^2~25 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=df4763bea5b04d8eed941cfe3df51f22cfe95570;p=firefly-linux-kernel-4.4.55.git ext4: validate external journal superblock checksum If the external journal device has metadata_csum enabled, verify that the superblock checksum matches the block before we try to mount. Signed-off-by: Darrick J. Wong Reviewed-by: Jan Kara Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb219b95f8d2..263201793c65 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4414,6 +4414,15 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, goto out_bdev; } + if ((le32_to_cpu(es->s_feature_ro_compat) & + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) && + es->s_checksum != ext4_superblock_csum(sb, es)) { + ext4_msg(sb, KERN_ERR, "external journal has " + "corrupt superblock"); + brelse(bh); + goto out_bdev; + } + if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) { ext4_msg(sb, KERN_ERR, "journal UUID does not match"); brelse(bh);