btrfs: Verify that every chunk has corresponding block group at mount time
authorQu Wenruo <wqu@suse.com>
Wed, 1 Aug 2018 02:37:17 +0000 (10:37 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 6 Aug 2018 11:13:03 +0000 (13:13 +0200)
commit7ef49515fa6727cb4b6f2f5b0ffbc5fc20a9f8c6
tree2013a3d439113c58479b799561e07dfb5d072b02
parent514c7dca85a0bf40be984dab0b477403a6db901f
btrfs: Verify that every chunk has corresponding block group at mount time

If a crafted image has missing block group items, it could cause
unexpected behavior and breaks the assumption of 1:1 chunk<->block group
mapping.

Although we have the block group -> chunk mapping check, we still need
chunk -> block group mapping check.

This patch will do extra check to ensure each chunk has its
corresponding block group.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=199847
Reported-by: Xu Wen <wen.xu@gatech.edu>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c