The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Lizhi Xu <lizhi.xu@windriver.com>,
	syzbot+3030e17bd57a73d39bd7@syzkaller.appspotmail.com,
	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:03:15 +0200	[thread overview]
Message-ID: <20241025180315.GI31418@twin.jikos.cz> (raw)
In-Reply-To: <03bcaafe-4a15-487a-af2b-b23970162bbb@gmx.com>

On Fri, Oct 25, 2024 at 08:23:07PM +1030, Qu Wenruo wrote:
> 
> 
> 在 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>

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

The function returns errors indirectly so it's not clear which could be
ultimately returned. I did a quick search over the calls starting in
btrfs_search_slot() and it seems that EINVAL is not used so we'd know if
it ends up in some error report. The ones I found: EAGAIN, EIO, EUCLEAN,
ENOMEM.

  reply	other threads:[~2024-10-25 18:03 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
2024-10-25 18:03     ` David Sterba [this message]
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=20241025180315.GI31418@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --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=quwenruo.btrfs@gmx.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