Skip to content

Commit ed4e6b5

Browse files
committed
btrfs: ref-verify: handle damaged extent root tree
Syzbot hits a problem with enabled ref-verify, ignorebadroots and a fuzzed/damaged extent tree. There's no fallback option like in other places that can deal with it so disable the whole ref-verify as it is just a debugging feature. Reported-by: [email protected] Link: https://lore.kernel.org/all/[email protected]/ Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 96fa515 commit ed4e6b5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/btrfs/ref-verify.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,11 +980,18 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
980980
if (!btrfs_test_opt(fs_info, REF_VERIFY))
981981
return 0;
982982

983+
extent_root = btrfs_extent_root(fs_info, 0);
984+
/* If the extent tree is damaged we cannot ignore it (IGNOREBADROOTS). */
985+
if (IS_ERR(extent_root)) {
986+
btrfs_warn(fs_info, "ref-verify: extent tree not available, disabling");
987+
btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
988+
return 0;
989+
}
990+
983991
path = btrfs_alloc_path();
984992
if (!path)
985993
return -ENOMEM;
986994

987-
extent_root = btrfs_extent_root(fs_info, 0);
988995
eb = btrfs_read_lock_root_node(extent_root);
989996
level = btrfs_header_level(eb);
990997
path->nodes[level] = eb;

0 commit comments

Comments
 (0)