Skip to content

Commit

Permalink
btrfs: fix wrong max system array size check in kernel space
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gui Hecheng authored and Chris Mason committed Jun 10, 2014
1 parent 65d33fd commit 5f43f86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5f43f86

Please sign in to comment.