From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Lizhi Xu <lizhi.xu@windriver.com>
Cc: clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+3030e17bd57a73d39bd7@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_reconstruct_alloc
Date: Fri, 25 Oct 2024 15:14:24 +1030 [thread overview]
Message-ID: <f5eb3203-62c1-4bdd-9607-122f13eacf70@gmx.com> (raw)
In-Reply-To: <20241025043848.1981317-1-lizhi.xu@windriver.com>
在 2024/10/25 15:08, Lizhi Xu 写道:
> On Fri, 25 Oct 2024 14:49:48 +1030, Qu Wenruo wrote:
>>> 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()?
> Yes, judging in btrfs_search_slot can fix the current issue while also
> avoiding similar problems.
>
Can't wait for your formal fix on this.
Thanks,
Qu
> #syz test
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 0cc919d15b14..9c05cab473f5 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -2010,7 +2010,7 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
> const struct btrfs_key *key, struct btrfs_path *p,
> int ins_len, int cow)
> {
> - struct btrfs_fs_info *fs_info = root->fs_info;
> + struct btrfs_fs_info *fs_info;
> struct extent_buffer *b;
> int slot;
> int ret;
> @@ -2023,6 +2023,10 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
> int min_write_lock_level;
> int prev_cmp;
>
> + if (!root)
> + return -EINVAL;
> +
> + fs_info = root->fs_info;
> might_sleep();
>
> lowest_level = p->lowest_level;
next prev parent reply other threads:[~2024-10-25 4:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 3:50 [syzbot] [btrfs?] general protection fault in btrfs_search_slot syzbot
2024-10-25 2:23 ` Lizhi Xu
2024-10-25 2:44 ` syzbot
2024-10-25 4:19 ` Qu Wenruo
2024-10-25 4:38 ` [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_reconstruct_alloc Lizhi Xu
2024-10-25 4:44 ` Qu Wenruo [this message]
2024-10-25 4:59 ` [syzbot] [btrfs?] general protection fault in btrfs_search_slot syzbot
2024-10-25 4:55 ` [PATCH] btrfs: add a sanity check for btrfs root Lizhi Xu
2024-10-25 9:53 ` Qu Wenruo
2024-10-25 18:03 ` David Sterba
2024-10-25 21:03 ` Qu Wenruo
2024-10-25 22:22 ` David Sterba
2024-11-03 21:44 ` [syzbot] [btrfs?] general protection fault in btrfs_search_slot syzbot
-- strict thread matches above, loose matches on Subject: below --
2024-10-26 4:19 [PATCH] bcachefs: Retrieve ext again after sb is reallocated Lizhi Xu
2024-10-26 4:21 ` [syzbot] [bcachefs?] KASAN: slab-use-after-free Read in bch2_reconstruct_alloc syzbot
[not found] <20241024064539.2963555-1-lizhi.xu@windriver.com>
2024-10-24 7:49 ` syzbot
[not found] <20241024011358.918019-1-lizhi.xu@windriver.com>
2024-10-24 1:33 ` syzbot
[not found] <20241024010924.908879-1-lizhi.xu@windriver.com>
2024-10-24 1:09 ` syzbot
2024-10-23 14:27 syzbot
2024-10-25 10:02 ` Lizhi Xu
2024-10-25 10:31 ` syzbot
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=f5eb3203-62c1-4bdd-9607-122f13eacf70@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhi.xu@windriver.com \
--cc=syzbot+3030e17bd57a73d39bd7@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/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
all inboxes | Powered by JetHome®