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>
This commit is contained in:
Qu Wenruo 2024-06-04 14:17:51 +09:30 committed by David Sterba
parent cef75dde63
commit 0eeb12aef5

View file

@ -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;