Commit 5f43f86e authored by Gui Hecheng's avatar Gui Hecheng Committed by Chris Mason

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: default avatarGui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 65d33fd7
...@@ -3921,7 +3921,8 @@ static int btrfs_add_system_chunk(struct btrfs_root *root, ...@@ -3921,7 +3921,8 @@ static int btrfs_add_system_chunk(struct btrfs_root *root,
u8 *ptr; u8 *ptr;
array_size = btrfs_super_sys_array_size(super_copy); 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; return -EFBIG;
ptr = super_copy->sys_chunk_array + array_size; ptr = super_copy->sys_chunk_array + array_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment