btrfs: disk-io: Allow 0 as tree block bytenr
diff mbox

Message ID
State New
Headers show

Commit Message

Qu Wenruo Dec. 10, 2017, 1:14 a.m. UTC
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 <>
Fixes: 6cca2ea9bea9 ("btrfs-progs: more sanity checks in read_tree_block_fs_info")
Signed-off-by: Qu Wenruo <>
 disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff mbox

diff --git a/disk-io.c b/disk-io.c
index f5edc4796619..7f13f05ac600 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -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);