Skip to contentSkip to conversation

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

PATCH New Qu Wenruo 1 participant 1 message Dec 10, 2017 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

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().

Fixes 6cca2ea9bea9 ("btrfs-progs: more sanity checks in read_tree_block_fs_info")
---
 disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disk-io.c +1 -1
index f5edc4796619..7f13f05ac600 100644
@@ -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