All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, hadrian2002@googlemail.com
Subject: [PATCH] btrfs: disk-io: Allow 0 as tree block bytenr
Date: Sun, 10 Dec 2017 09:14:03 +0800	[thread overview]
Message-ID: <20171210011403.14452-1-wqu@suse.com> (raw)

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 <hadrian2002@googlemail.com>
Fixes: 6cca2ea9bea9 ("btrfs-progs: more sanity checks in read_tree_block_fs_info")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 disk-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
-- 
2.15.1


                 reply	other threads:[~2017-12-10  1:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171210011403.14452-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.cz \
    --cc=hadrian2002@googlemail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.