btrfs-progs: error out immediately if an unknown backref type is found

(cherry picked from commit 77c42223277a6b225d3a7ce0ded0a907688b0639)
This commit is contained in:
liuh 2024-07-17 18:15:48 +08:00 committed by openeuler-sync-bot
parent 7d25afa7b6
commit 06859ab854
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 0eeb12aef5ed18b3ecb5346440742971d5b11703 Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
Date: Tue, 4 Jun 2024 14:17:51 +0930
Subject: [PATCH] btrfs-progs: error out immediately if an unknown backref type
is found
There is a bug report that for fuzzed image
bko-155621-bad-block-group-offset.raw, "btrfs check --mode=lowmem
--repair" would lead to an endless loop.
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 an endless loop.
Issue: #788
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@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 d9e8d2f..6866d6d 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.43.0

View File

@ -1,6 +1,6 @@
Name: btrfs-progs
Version: 6.6.3
Release: 9
Release: 10
Summary: btrfs userspace programs
License: GPLv2 and GPL+ and LGPL-2.1+ and GPL-3.0+ and LGPL-2.1 and MIT
URL: https://btrfs.wiki.kernel.org/index.php/Main_Page
@ -14,6 +14,7 @@ Patch0005: 0005-btrfs-progs-fix-freeing-of-device-after-error-in-btr.patch
Patch0006: 0006-fix-double-free-on-error-in-read_raid56.patch
Patch0007: 0007-btrfs-progs-fi-show-canonicalize-path-when-using-blk.patch
Patch0008: 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch
Patch0009: 0009-btrfs-progs-error-out-immediately-if-an-unknown-back.patch
BuildRequires: python3-devel >= 3.4
BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel
@ -79,6 +80,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir
%{_mandir}/man8/*.gz
%changelog
* Wed Jul 17 2024 liuh <liuhuan01@kylinos.cn> - 6.6.3-10
- btrfs-progs: error out immediately if an unknown backref type is found
* Tue Jul 2 2024 cenhuilin <cenhuilin@kylinos.cn> - 6.6.3-9
- btrfs-progs: tune: fix the missing close() of filesystem fd