linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: Christoph Hellwig <hch@lst.de>
Cc: syzbot <syzbot+8fede7e30c7cee0de139@syzkaller.appspotmail.com>,
	Jens Axboe <axboe@kernel.dk>,
	linux-block <linux-block@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [syzbot] KASAN: use-after-free Read in disk_part_iter_next (2)
Date: Mon, 22 Mar 2021 08:49:45 +0100	[thread overview]
Message-ID: <CACT4Y+bDdmUH4eJV0P7OwT_z1pSi3CWs9fFrtiO89obtK6mpcw@mail.gmail.com> (raw)
In-Reply-To: <20210322071801.GE3440@lst.de>

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

On Mon, Mar 22, 2021 at 8:18 AM Christoph Hellwig <hch@lst.de> wrote:
>
> I've been running the reproducer on a KASAN enable VM for about
> 15 minutes now, but haven't been able to reproduce it.
>
> Is there a way to inject this proposed fix into the syzbot queue?

Hi Christoph,

Yes, since this bug has a reproducer, syzbot can test patches. See:

http://bit.do/syzbot#testing-patches

It would be, for example:

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
master


> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index 1a7558917c47d6..f5d5872b89d57e 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -288,15 +288,12 @@ struct device_type part_type = {
>  void delete_partition(struct block_device *part)
>  {
>         xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
> -       kobject_put(part->bd_holder_dir);
> -       device_del(&part->bd_device);
> -
> -       /*
> -        * Remove the block device from the inode hash, so that it cannot be
> -        * looked up any more even when openers still hold references.
> -        */
>         remove_inode_hash(part->bd_inode);
>
> +       synchronize_rcu();
> +
> +       kobject_put(part->bd_holder_dir);
> +       device_del(&part->bd_device);
>         put_device(&part->bd_device);
>  }

[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 712 bytes --]

diff --git a/block/partitions/core.c b/block/partitions/core.c
index 1a7558917c47d6..f5d5872b89d57e 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -288,15 +288,12 @@ struct device_type part_type = {
 void delete_partition(struct block_device *part)
 {
 	xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
-	kobject_put(part->bd_holder_dir);
-	device_del(&part->bd_device);
-
-	/*
-	 * Remove the block device from the inode hash, so that it cannot be
-	 * looked up any more even when openers still hold references.
-	 */
 	remove_inode_hash(part->bd_inode);
 
+	synchronize_rcu();
+
+	kobject_put(part->bd_holder_dir);
+	device_del(&part->bd_device);
 	put_device(&part->bd_device);
 }

  reply	other threads:[~2021-03-22  7:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14 11:08 [syzbot] KASAN: use-after-free Read in disk_part_iter_next (2) syzbot
2021-03-20 20:53 ` syzbot
2021-03-21 12:40 ` syzbot
2021-03-22  7:18   ` Christoph Hellwig
2021-03-22  7:49     ` Dmitry Vyukov [this message]
2021-03-22  8:01       ` syzbot
2021-03-22 22:21     ` Bart Van Assche
2021-03-24  9:49   ` Christoph Hellwig
2021-03-24 10:01     ` syzbot
2021-03-21 21:26 ` Bart Van Assche
2021-03-21 21:39   ` syzbot
2021-03-22  2:35   ` Ming Lei
2021-03-22  4:15     ` Bart Van Assche
2021-03-22  8:51 ` Ming Lei
2021-03-22 10:09   ` syzbot
2021-03-26  8:35 ` Ming Lei
2021-03-26 17:01   ` syzbot
2021-03-27  6:50     ` Ming Lei

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=CACT4Y+bDdmUH4eJV0P7OwT_z1pSi3CWs9fFrtiO89obtK6mpcw@mail.gmail.com \
    --to=dvyukov@google.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+8fede7e30c7cee0de139@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tj@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).