Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH v2 3/4] btrfs-progs: error out immediately if an unknown backref type is hit
Date: Wed,  5 Jun 2024 09:13:43 +0930	[thread overview]
Message-ID: <d5c1a2d6eaec18c818df3f0c9ba568761aa993d8.1717544015.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1717544015.git.wqu@suse.com>

There is a bug report that for fuzzed image
bko-155621-bad-block-group-offset.raw, "btrfs check --mode=lowmem
--repair" would lead to a deadloop.

Unlike original mode, lowmem mode relies on the backref walk to properly
go through each root, but unfortunately inside __add_inline_refs() we
doesn't handle unknown backref types correctly, causing it never moving
forward thus deadloop.

Fix it by erroring out to prevent deadloop.

Issue: #788
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 kernel-shared/backref.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel-shared/backref.c b/kernel-shared/backref.c
index 89ccf073fca7..f46f3267e144 100644
--- a/kernel-shared/backref.c
+++ b/kernel-shared/backref.c
@@ -650,7 +650,8 @@ static int __add_inline_refs(struct btrfs_fs_info *fs_info,
 			break;
 		}
 		default:
-			WARN_ON(1);
+			error("invalid backref type: %u", type);
+			ret = -EUCLEAN;
 		}
 		if (ret)
 			return ret;
-- 
2.45.2


  parent reply	other threads:[~2024-06-04 23:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04 23:43 [PATCH v2 0/4] btrfs-progs: small bug fixes Qu Wenruo
2024-06-04 23:43 ` [PATCH v2 1/4] btrfs-progs: corrupt-block: fix memory leak in debug_corrupt_sector() Qu Wenruo
2024-06-04 23:43 ` [PATCH v2 2/4] btrfs-progs: print-tree: do sanity checks for dir items Qu Wenruo
2024-06-04 23:43 ` Qu Wenruo [this message]
2024-06-04 23:43 ` [PATCH v2 4/4] btrfs-progs: fix misc/038 test cases Qu Wenruo
2024-06-05 17:57 ` [PATCH v2 0/4] btrfs-progs: small bug fixes 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=d5c1a2d6eaec18c818df3f0c9ba568761aa993d8.1717544015.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=josef@toxicpanda.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox