public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <brauner@kernel.org>
Cc: hch@lst.de, clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	syzbot <syzbot+26860029a4d562566231@syzkaller.appspotmail.com>
Subject: Re: [syzbot] [btrfs?] KASAN: slab-use-after-free Read in btrfs_open_devices
Date: Tue, 8 Aug 2023 18:01:41 +0200	[thread overview]
Message-ID: <20230808160141.GA15875@lst.de> (raw)
In-Reply-To: <20230808-zentimeter-kappen-5da1e70c5535@brauner>

Yes, probably.  The lifetimes looked fishy to me to start with, but
this might have made things worse.

On Tue, Aug 08, 2023 at 05:50:02PM +0200, Christian Brauner wrote:
> On Mon, Aug 07, 2023 at 08:24:36PM -0700, syzbot wrote:
> > syzbot has bisected this issue to:
> > 
> > commit 066d64b26a21a5b5c500a30f27f3e4b1959aac9e
> > Author: Christoph Hellwig <hch@lst.de>
> > Date:   Wed Aug 2 15:41:23 2023 +0000
> > 
> >     btrfs: open block devices after superblock creation
> > 
> > bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15493371a80000
> > start commit:   f7dc24b34138 Add linux-next specific files for 20230807
> > git tree:       linux-next
> > final oops:     https://syzkaller.appspot.com/x/report.txt?x=17493371a80000
> > console output: https://syzkaller.appspot.com/x/log.txt?x=13493371a80000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=d7847c9dca13d6c5
> > dashboard link: https://syzkaller.appspot.com/bug?extid=26860029a4d562566231
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=179704c9a80000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17868ba9a80000
> > 
> > Reported-by: syzbot+26860029a4d562566231@syzkaller.appspotmail.com
> > Fixes: 066d64b26a21 ("btrfs: open block devices after superblock creation")
> > 
> > For information about bisection process see: https://goo.gl/tpsmEJ#bisection
> 
> I think the issue might be that before your patch the lifetime of:
> @device was aligned with @device->s_fs_info but now that you're dropping
> the uuid mutex after btrfs_scan_one_device() that isn't true anymore. So
> it feels like:
> 
> P1                                       P2
> lock_uuid_mutex;
> device = btrfs_scan_one_device();
> fs_devices = device->fs_devices;
> unlock_uuid_mutex;
>                                          // earlier mount that gets cleaned up
>                                          lock_uuid_mutex; 
> 					 btrfs_close_devices(fs_devices);
>                                          unlock_uuid_mutex;
> 
> lock_uuid_mutex;
> btrfs_open_devices(fs_devices); // UAF
> unlock_uuid_mutex;
> 
> But I'm not entirely sure.
---end quoted text---

  reply	other threads:[~2023-08-08 17:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 20:51 [syzbot] [btrfs?] KASAN: slab-use-after-free Read in btrfs_open_devices syzbot
2023-08-08  3:24 ` syzbot
2023-08-08 15:50   ` Christian Brauner
2023-08-08 16:01     ` Christoph Hellwig [this message]
2023-08-08 16:35       ` Christian Brauner
2023-08-08 17:22         ` Christoph Hellwig
2023-08-08 17:38       ` David Sterba
     [not found] <20230808140807.1967-1-hdanton@sina.com>
2023-08-08 14:30 ` syzbot
     [not found] <20230808232313.2035-1-hdanton@sina.com>
2023-08-08 23:38 ` syzbot
     [not found] <20230809110318.2110-1-hdanton@sina.com>
2023-08-09 14:22 ` syzbot
     [not found] <20230810104550.2217-1-hdanton@sina.com>
2023-08-10 11:05 ` syzbot
     [not found] <20230810124552.2335-1-hdanton@sina.com>
2023-08-10 13:05 ` syzbot
     [not found] <20230810141207.2398-1-hdanton@sina.com>
2023-08-10 15:03 ` 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=20230808160141.GA15875@lst.de \
    --to=hch@lst.de \
    --cc=brauner@kernel.org \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+26860029a4d562566231@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