diff options
author | Qu Wenruo <wqu@suse.com> | 2018-04-19 19:02:11 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-04-19 17:33:01 +0200 |
commit | bae1f0f0ee01b6a39efa136652eec09faf19d8ad (patch) | |
tree | 87ff421b43df3c199aae001cd27053d1d4b8b1ba /fs/btrfs | |
parent | 49c5eda0f4dc44ea85d0ec24688dbe16bc5998c1 (diff) | |
download | linux-next-bae1f0f0ee01b6a39efa136652eec09faf19d8ad.tar.gz |
btrfs: Add csum type check for btrfs_check_super_valid()
Just like incompat flags check, although we have already done super csum
type check before calling btrfs_check_super_valid(), we can still add
such check for later write time check.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/disk-io.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6531f07d6ca7..e9c84c5800ed 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3984,6 +3984,16 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info) btrfs_err(fs_info, "no valid FS found"); ret = -EINVAL; } + + /* + * For write time check, as for mount time we have checked csum before + * calling btrfs_check_super_valid(), so it must be a corruption + */ + if (btrfs_super_csum_type(sb) >= ARRAY_SIZE(btrfs_csum_sizes)) { + btrfs_err(fs_info, "corrupted csum type %u", + btrfs_super_csum_type(sb)); + ret = -EINVAL; + } if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) { btrfs_err(fs_info, "unrecognized or unsupported super flag: %llu", btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); |