btrfs-progs: check: do early check for read_tree_block
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Tue, 30 Aug 2016 03:29:32 +0000 (11:29 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Sep 2016 08:04:24 +0000 (10:04 +0200)
commit245cf06dfaec144fac3423e91d0bbb2b686b5ed1
tree479723a45d39649cd06aaf7953f9ad44d2d7f220
parent767ae9e348a667fa4e05e3b1a01630ecaff1f27d
btrfs-progs: check: do early check for read_tree_block

Although we have enhanced read_tree_block() from a lot of different
aspects, it lacks the early bytenr/blocksize alignment check.

And the lack of such check can lead to strange use-after-free bugs, due
to the fact that alloc_extent_buffer() will free overlapping extent
buffers, and allocate new eb for the usage.

So we should not allow invalid bytenr/blocksize even passed to
btrfs_find_create_tree_block().

This patch will add such check so we won't trigger use-after-free bug
then.

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>
disk-io.c