aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>2014-04-21 20:13:11 +0800
committerChris Mason <clm@fb.com>2014-06-09 17:20:36 -0700
commit5f43f86e3f62734dfeeb36c4d940425a2c6789dc (patch)
tree472aad111676514efec607fd1279b5b17ac5bd80 /fs/btrfs/volumes.c
parentbtrfs: Add check to avoid cleanup roots already in fs_info->dead_roots. (diff)
downloadlinux-dev-5f43f86e3f62734dfeeb36c4d940425a2c6789dc.tar.xz
linux-dev-5f43f86e3f62734dfeeb36c4d940425a2c6789dc.zip
btrfs: fix wrong max system array size check in kernel space
For system chunk array, We copy a "disk_key" and an chunk item each time, so there should be enough space to hold both of them, not only the chunk item. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ad8e342c4b78..5864f05243c2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3921,7 +3921,8 @@ static int btrfs_add_system_chunk(struct btrfs_root *root,
u8 *ptr;
array_size = btrfs_super_sys_array_size(super_copy);
- if (array_size + item_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE)
+ if (array_size + item_size + sizeof(disk_key)
+ > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE)
return -EFBIG;
ptr = super_copy->sys_chunk_array + array_size;