btrfs-progs: Fix one-byte overlap bug in free_block_group_cache
authorQu Wenruo <quwenruo.btrfs@gmx.com>
Mon, 11 Sep 2017 06:36:07 +0000 (15:36 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Sep 2017 13:17:52 +0000 (15:17 +0200)
commita7e555d706c85b9d80160640ca338e85c9056a06
treee9370189c25e630466a0cf1856373de82bf729b1
parent02b58051e60658abb0387bec7063e77d2941923b
btrfs-progs: Fix one-byte overlap bug in free_block_group_cache

free_block_group_cache() calls clear_extent_bits() with wrong end, which
is one byte larger than the correct range.

This will cause the next adjacent cache state to be split.  And due to
the split, private pointer (which points to block group cache) will be
reset to NULL.

This is very hard to detect as this function only gets called in
cleanup_temp_chunks() which is just before mkfs finishes.  This bug only
gets exposed when reworking --rootdir option.

Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
extent-tree.c