Fix missing static function declaration
[ext4-patch-queue.git] / validate-external-journal-superblock-checksum
blob23a36aa15b7823a1071b733fce30b8f569889665
1 ext4: validate external journal superblock checksum
3 From: "Darrick J. Wong" <darrick.wong@oracle.com>
5 If the external journal device has metadata_csum enabled, verify
6 that the superblock checksum matches the block before we try to
7 mount.
9 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
10 Reviewed-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 ---
13  fs/ext4/super.c | 9 +++++++++
14  1 file changed, 9 insertions(+)
16 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
17 index fb219b9..2632017 100644
18 --- a/fs/ext4/super.c
19 +++ b/fs/ext4/super.c
20 @@ -4414,6 +4414,15 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
21                 goto out_bdev;
22         }
24 +       if ((le32_to_cpu(es->s_feature_ro_compat) &
25 +            EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
26 +           es->s_checksum != ext4_superblock_csum(sb, es)) {
27 +               ext4_msg(sb, KERN_ERR, "external journal has "
28 +                                      "corrupt superblock");
29 +               brelse(bh);
30 +               goto out_bdev;
31 +       }
33         if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
34                 ext4_msg(sb, KERN_ERR, "journal UUID does not match");
35                 brelse(bh);