From: David Sterba <dsterba@suse.cz>
To: Anand Jain <anand.jain@oracle.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, Nikolay Borisov <nborisov@suse.com>,
syzbot+582e66e5edf36a22c7b0@syzkaller.appspotmail.com
Subject: Re: [PATCH v3] btrfs: don't access possibly stale fs_info data for printing duplicate device
Date: Fri, 20 Nov 2020 17:21:31 +0100 [thread overview]
Message-ID: <20201120162131.GT20563@twin.jikos.cz> (raw)
In-Reply-To: <64eb0192-1997-89ee-25d0-94cc0ec93bfb@oracle.com>
On Wed, Nov 18, 2020 at 05:28:57PM +0800, Anand Jain wrote:
> On 18/11/20 5:03 pm, Johannes Thumshirn wrote:
> > --- a/fs/btrfs/volumes.c
> > +++ b/fs/btrfs/volumes.c
> > @@ -940,7 +940,13 @@ static noinline struct btrfs_device *device_list_add(const char *path,
> > if (device->bdev != path_bdev) {
> > bdput(path_bdev);
> > mutex_unlock(&fs_devices->device_list_mutex);
> > - btrfs_warn_in_rcu(device->fs_info,
> > + /*
> > + * device->fs_info may not be reliable here, so
> > + * pass in a NULL fs_info. This avoids a
> > + * possible use-after-free when the fs_info and
> > + * fs_info->sb are already torn down.
> > + */
> > + btrfs_warn_in_rcu(NULL,
> > "duplicate device %s devid %llu generation %llu scanned by %s (%d)",
> > path, devid, found_transid,
> > current->comm,
> >
>
> Few lines below, there is btrfs_info_in_rcu() and, we won't have
> reliable device->fs_info even there. But we have seen those info
> quite a lot of times. And so far, it's been ok. So
Right, this also looks like potentially unsafe use but given that the
2nd print is still under device_list_mutex it think it will be harder
to hit.
next prev parent reply other threads:[~2020-11-20 16:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 9:03 [PATCH v3] btrfs: don't access possibly stale fs_info data for printing duplicate device Johannes Thumshirn
2020-11-18 9:28 ` Anand Jain
2020-11-20 16:21 ` David Sterba [this message]
2020-11-20 16:36 ` David Sterba
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=20201120162131.GT20563@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=syzbot+582e66e5edf36a22c7b0@syzkaller.appspotmail.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