From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, chris@colorremedies.com
Subject: [PATCH 2/4] btrfs-progs: lowmem check: Fix function call stack overflow caused by wrong tree reloc tree detection
Date: Mon, 13 Nov 2017 15:34:51 +0800 [thread overview]
Message-ID: <20171113073453.29198-3-wqu@suse.com> (raw)
In-Reply-To: <20171113073453.29198-1-wqu@suse.com>
For tree reloc tree root, its backref points to it self.
So for such case, we should finish the lookup.
Previous end condition is to ensure it's tree reloc tree *and* needs its
root bytenr to match the bytenr passed in.
However the @root passed in can be other tree, e.g. other tree reloc
tree which shares the node/leaf.
This makes any check based on @root passed in invalid.
The patch removes the unreliable root objectid detection, and only use
root->bytenr check.
For the possibility of invalid self-pointing backref, extent tree
checker should have already handled it, so we don't need to bother in
fs tree checker.
Fixes: 54c8f9152fd9 ("btrfs-progs: check: Fix lowmem mode stack overflow caused by fsck/023")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds-check.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/cmds-check.c b/cmds-check.c
index b9943a0d3a0f..36e4a91b7e17 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -10251,15 +10251,10 @@ static int check_tree_block_ref(struct btrfs_root *root,
u32 nodesize = root->fs_info->nodesize;
u32 item_size;
u64 offset;
- int tree_reloc_root = 0;
int found_ref = 0;
int err = 0;
int ret;
- if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID &&
- btrfs_header_bytenr(root->node) == bytenr)
- tree_reloc_root = 1;
-
btrfs_init_path(&path);
key.objectid = bytenr;
if (btrfs_fs_incompat(root->fs_info, SKINNY_METADATA))
@@ -10350,8 +10345,12 @@ static int check_tree_block_ref(struct btrfs_root *root,
/*
* Backref of tree reloc root points to itself, no need
* to check backref any more.
+ *
+ * This may be an error of loop backref, but extent tree
+ * checker should have already handled it.
+ * Here we only need to avoid infinite iteration.
*/
- if (tree_reloc_root)
+ if (offset == bytenr)
found_ref = 1;
else
/* Check if the backref points to valid referencer */
--
2.15.0
next prev parent reply other threads:[~2017-11-13 7:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 7:34 [PATCH 0/4] Lowmem mode btrfs fixes exposed by complex tree Qu Wenruo
2017-11-13 7:34 ` [PATCH 1/4] btrfs-progs: backref: Allow backref walk to handle direct parent ref Qu Wenruo
2017-11-13 7:34 ` Qu Wenruo [this message]
2017-11-13 7:34 ` [PATCH 3/4] btrfs-progs: lowmem check: Fix false alerts for image with shared block ref only backref Qu Wenruo
2017-11-13 9:04 ` [PATCH 0/4] Lowmem mode btrfs fixes exposed by complex tree Qu Wenruo
2017-11-14 7:57 ` Qu Wenruo
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=20171113073453.29198-3-wqu@suse.com \
--to=wqu@suse.com \
--cc=chris@colorremedies.com \
--cc=dsterba@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).