From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 02/11] btrfs-progs: lowmem check: Fix NULL pointer access caused by large tree reloc tree
Date: Wed, 22 Nov 2017 17:03:16 +0800 [thread overview]
Message-ID: <20171122090325.29458-3-wqu@suse.com> (raw)
In-Reply-To: <20171122090325.29458-1-wqu@suse.com>
[BUG]
v4.14 btrfs-progs can't pass new self test image with large tree reloc
trees.
It will fail with later "shared_block_ref_only.raw.xz" test image with
NULL pointer access.
[CAUSE]
For image with higher (level >= 2) tree reloc tree, for function
need_check() its ulist will be empty as tree reloc tree won't be
accounted in btrfs_find_all_roots().
Then accessing ulist->roots with rb_first() will return NULL pointer.
[FIX]
For need_check() function, if @roots is empty, meaning it's a tree reloc
tree, always check them.
Although this can be slow, but at least it's safe that we won't skip any
possible wrong tree block.
Fixes: 5e2dc770471b ("btrfs-progs: check: skip shared node or leaf check for low_memory mode")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds-check.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cmds-check.c b/cmds-check.c
index 644ee084cb8e..03ff89a4221c 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2149,7 +2149,12 @@ static int need_check(struct btrfs_root *root, struct ulist *roots)
struct rb_node *node;
struct ulist_node *u;
- if (roots->nnodes == 1)
+ /*
+ * @roots can be empty if it belongs to tree reloc tree
+ * In that case, we should always check the leaf, as we can't use
+ * the tree owner to ensure some other root will check it.
+ */
+ if (roots->nnodes == 1 || roots->nnodes == 0)
return 1;
node = rb_first(&roots->root);
--
2.15.0
next prev parent reply other threads:[~2017-11-22 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 9:03 [PATCH 00/11] Lowmem mode btrfs fixes exposed by complex tree Qu Wenruo
2017-11-22 9:03 ` [PATCH 01/11] btrfs-progs: lowmem check: Fix regression which screws up extent allocator Qu Wenruo
2017-11-22 9:03 ` Qu Wenruo [this message]
2017-11-22 9:03 ` [PATCH 03/11] btrfs-progs: lowmem check: Fix inlined data extent ref lookup Qu Wenruo
2017-11-22 9:03 ` [PATCH 04/11] btrfs-progs: lowmem check: Fix false backref lost warning for keyed extent data ref Qu Wenruo
2017-11-22 9:03 ` [PATCH 05/11] btrfs-progs: fsck-test: Introduce test case for false data extent backref lost Qu Wenruo
2017-11-22 9:03 ` [PATCH 06/11] btrfs-progs: backref: Allow backref walk to handle direct parent ref Qu Wenruo
2017-11-22 9:03 ` [PATCH 07/11] btrfs-progs: lowmem check: Fix function call stack overflow caused by wrong tree reloc tree detection Qu Wenruo
2017-11-22 9:03 ` [PATCH 08/11] btrfs-progs: lowmem check: Fix false alerts for image with shared block ref only backref Qu Wenruo
2017-11-22 9:03 ` [PATCH 10/11] btrfs-progs: lowmem check: Fix false alerts of referencer count mismatch for snapshot Qu Wenruo
2017-11-22 9:03 ` [PATCH 11/11] btrfs-progs: fsck-tests: Introduce test case with keyed data backref with shared tree blocks Qu Wenruo
2017-11-24 14:46 ` [PATCH 00/11] Lowmem mode btrfs fixes exposed by complex tree David Sterba
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=20171122090325.29458-3-wqu@suse.com \
--to=wqu@suse.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).