aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-10-31 13:42:05 -0400
committerChris Mason <clm@fb.com>2015-02-02 22:23:43 -0500
commitce7fca5f57ed0fcd7e7b3d7b1a3e1791f8e56fa3 (patch)
tree5b3886f01a02eccdf2927cd195a17f7995fbe6e2 /fs/btrfs/disk-io.c
parent75d6ad382bb91f363452119d34238e156589ca2d (diff)
btrfs: add checks for sys_chunk_array sizes
Verify that possible minimum and maximum size is set, validity of contents is checked in btrfs_read_sys_array. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 11171362bd33..263d1471d01a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3911,6 +3911,25 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3911 } 3911 }
3912 3912
3913 /* 3913 /*
3914 * Obvious sys_chunk_array corruptions, it must hold at least one key
3915 * and one chunk
3916 */
3917 if (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) {
3918 printk(KERN_ERR "BTRFS: system chunk array too big %u > %u\n",
3919 btrfs_super_sys_array_size(sb),
3920 BTRFS_SYSTEM_CHUNK_ARRAY_SIZE);
3921 ret = -EINVAL;
3922 }
3923 if (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key)
3924 + sizeof(struct btrfs_chunk)) {
3925 printk(KERN_ERR "BTRFS: system chunk array too small %u < %lu\n",
3926 btrfs_super_sys_array_size(sb),
3927 sizeof(struct btrfs_disk_key)
3928 + sizeof(struct btrfs_chunk));
3929 ret = -EINVAL;
3930 }
3931
3932 /*
3914 * The generation is a global counter, we'll trust it more than the others 3933 * The generation is a global counter, we'll trust it more than the others
3915 * but it's still possible that it's the one that's wrong. 3934 * but it's still possible that it's the one that's wrong.
3916 */ 3935 */