The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Lizhi Xu <lizhi.xu@windriver.com>,
	syzbot+3030e17bd57a73d39bd7@syzkaller.appspotmail.com
Cc: clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] btrfs: add a sanity check for btrfs root
Date: Fri, 25 Oct 2024 20:23:07 +1030	[thread overview]
Message-ID: <03bcaafe-4a15-487a-af2b-b23970162bbb@gmx.com> (raw)
In-Reply-To: <20241025045553.2012160-1-lizhi.xu@windriver.com>



在 2024/10/25 15:25, Lizhi Xu 写道:
> Syzbot report a null-ptr-deref in btrfs_search_slot.
> It use the input logical can't find the extent root in extent_from_logical,
> and triger the null-ptr-deref in btrfs_search_slot.
> Add sanity check for btrfs root before using it in btrfs_search_slot.

Although I'd prefer to explain a little more about why the NULL root
pointer can happen (caused by the rescue=all mount option), which can
cause NULL root pointer for non-critical tree roots, like
uuid/csum/extent or even device trees.

You don't need to bother sending an update.
I can add such info when pushing to the maintainer's tree.

>
> Reported-by: syzbot+3030e17bd57a73d39bd7@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=3030e17bd57a73d39bd7
> Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/ctree.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> 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;


  reply	other threads:[~2024-10-25  9:53 UTC|newest]

Thread overview: 13+ 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
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 [this message]
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

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=03bcaafe-4a15-487a-af2b-b23970162bbb@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