aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2016-06-03 15:05:14 -0400
committerDavid Sterba <dsterba@suse.com>2016-06-06 04:41:53 -0400
commit99e3ecfcb9f4ca35192d20a5bea158b81f600062 (patch)
tree41a481ff46b66e463f8824c66834c4402ea836e7 /fs/btrfs/disk-io.c
parentd865177a5e749827f248f6363f5100d3a2f66b0f (diff)
Btrfs: add more validation checks for superblock
This adds validation checks for super_total_bytes, super_bytes_used and super_stripesize, super_num_devices. Reported-by: Vegard Nossum <vegard.nossum@oracle.com> Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6628fca9f4ed..2bd5f5e975cc 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4130,6 +4130,17 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
4130 * Hint to catch really bogus numbers, bitflips or so, more exact checks are 4130 * Hint to catch really bogus numbers, bitflips or so, more exact checks are
4131 * done later 4131 * done later
4132 */ 4132 */
4133 if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) {
4134 btrfs_err(fs_info, "bytes_used is too small %llu",
4135 btrfs_super_bytes_used(sb));
4136 ret = -EINVAL;
4137 }
4138 if (!is_power_of_2(btrfs_super_stripesize(sb)) ||
4139 btrfs_super_stripesize(sb) != sectorsize) {
4140 btrfs_err(fs_info, "invalid stripesize %u",
4141 btrfs_super_stripesize(sb));
4142 ret = -EINVAL;
4143 }
4133 if (btrfs_super_num_devices(sb) > (1UL << 31)) 4144 if (btrfs_super_num_devices(sb) > (1UL << 31))
4134 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", 4145 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n",
4135 btrfs_super_num_devices(sb)); 4146 btrfs_super_num_devices(sb));