Re: [syzbot] [btrfs?] general protection fault in btrfs_search_slot

From: Qu Wenruo
Date: Fri Oct 25 2024 - 00:20:13 EST




在 2024/10/25 12:53, Lizhi Xu 写道:
use the input logical can't find the extent root, so add sanity check for
extent root before search slot.

#syz test

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index f8e1d5b2c512..87eaf5dd2d5d 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -2213,6 +2213,9 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
key.objectid = logical;
key.offset = (u64)-1;

+ if (!extent_root)
+ return -ENOENT;

Considering we have a lot of such btrfs_search_slot() without checking
if the csum/extent root is NULL, can we move the check into
btrfs_search_slot()?

Thanks,
Qu
+
ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
if (ret < 0)
return ret;