btrfs-progs: Do extra chunk check before processing chunk item
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Mon, 29 Aug 2016 08:09:02 +0000 (16:09 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Sep 2016 08:04:16 +0000 (10:04 +0200)
commit2f242115d1c3a395158d5b6d6d31ad4ae9a2c991
tree307c9d3bd2b2d00162bde510ab34a7b1301d5f9e
parentf1934f4c7832efd362a177641c5409179555169e
btrfs-progs: Do extra chunk check before processing chunk item

Current we only do chunk validation check at mount time.

It's good for most case, but for fuzzed or manually crafted images, we
can insert a CHUNK_ITEM key into root tree.

Since mount time check will only check chunk tree, it will not check
CHUNK_ITEM in root tree.

Even with previous key type check against leaf owner, it is still
possible to modify the leaf owner to by-pass it.

So we still need to check chunk validation before processing it.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-check.c
volumes.c
volumes.h