diff options
| -rw-r--r-- | fs/btrfs/disk-io.c | 19 |
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 | */ |
