btrfs: disk-io: Allow 0 as tree block bytenr
PATCH 1/1 btrfs: disk-io: Allow 0 as tree block bytenr
Some btrfs created by old mkfs.btrfs can have tree block with 0 bytenr.
In fact, any aligned bytenr is allowed in btrfs, and in some case it can cause problem if the valid tree block at 0 bytenr can't be read.
Currently, the superblock checker and bytenr alignment checker can already handle the case so there is no need to check bytenr < sectorsize in read_tree_block().
Reported-by Benjamin Beichler <[email protected]>
Fixes 6cca2ea9bea9 ("btrfs-progs: more sanity checks in read_tree_block_fs_info")
Signed-off-by Qu Wenruo <[email protected]>
--- disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
disk-io.c +1 -1
@@ -318,7 +318,7 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,* Such unaligned tree block will free overlapping extent buffer, * causing use-after-free bugs for fuzzed images. */ -if (bytenr < sectorsize || !IS_ALIGNED (bytenr, sectorsize)) { +if (!IS_ALIGNED (bytenr, sectorsize)) {error ("tree block bytenr %llu is not aligned to sectorsize %u" , bytenr, sectorsize);return ERR_PTR (-EIO );
Signature · 1 line
2.15.1