From 9050a9c9a2c0cfe61c164cacb016aaf7d0acb433 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Sun, 29 Apr 2012 18:25:10 -0400 Subject: [PATCH] --- yaml --- r: 309932 b: refs/heads/master c: d25425f8e0ed01fc0167c043aee7e619fc3f6ab2 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ext4/super.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 1e82518e87cf..1560d0b86b8a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e615391896064eb5a0c760d086b8e1c6ecfffeab +refs/heads/master: d25425f8e0ed01fc0167c043aee7e619fc3f6ab2 diff --git a/trunk/fs/ext4/super.c b/trunk/fs/ext4/super.c index e1fb1d5de58e..f489ffb3605d 100644 --- a/trunk/fs/ext4/super.c +++ b/trunk/fs/ext4/super.c @@ -112,6 +112,16 @@ static struct file_system_type ext3_fs_type = { #define IS_EXT3_SB(sb) (0) #endif +static int ext4_verify_csum_type(struct super_block *sb, + struct ext4_super_block *es) +{ + if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) + return 1; + + return es->s_checksum_type == EXT4_CRC32C_CHKSUM; +} + void *ext4_kvmalloc(size_t size, gfp_t flags) { void *ret; @@ -3025,6 +3035,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto cantfind_ext4; sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written); + /* Check for a known checksum algorithm */ + if (!ext4_verify_csum_type(sb, es)) { + ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " + "unknown checksum algorithm."); + silent = 1; + goto cantfind_ext4; + } + /* Set defaults before we parse the mount options */ def_mount_opts = le32_to_cpu(es->s_default_mount_opts); set_opt(sb, INIT_INODE_TABLE);