From: Christoph Hellwig <hch@lst.de>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Luis Chamberlain <mcgrof@kernel.org>,
linux-block <linux-block@vger.kernel.org>
Subject: Re: [PATCH] block: fix error handling for device_add_disk
Date: Thu, 16 Dec 2021 17:18:06 +0100 [thread overview]
Message-ID: <20211216161806.GA31879@lst.de> (raw)
In-Reply-To: <c614deb3-ce75-635e-a311-4f4fc7aa26e3@i-love.sakura.ne.jp>
On Fri, Dec 17, 2021 at 01:00:00AM +0900, Tetsuo Handa wrote:
> syzbot is reporting double kfree() bug in disk_release_events() [1], for
> commit 9be68dd7ac0e13be ("md: add error handling support for add_disk()")
> is calling blk_cleanup_disk() which will call disk_release_events() from
> regular kobject_release() path when device_add_disk() from add_disk()
> failed.
>
> Since kobject_release() will be always called regardless of whether
> device_add_disk() from add_disk() succeeds, we should leave
> disk_release_events() to regular kobject_release() path.
>
> Link: https://syzkaller.appspot.com/bug?extid=28a66a9fbc621c939000 [1]
> Reported-by: syzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
> Tested-by: syzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
> Fixes: 83cbce9574462c6b ("block: add error handling for device_add_disk / add_disk")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> block/genhd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 30362aeacac4..47bb34ab967b 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -540,7 +540,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
> out_device_del:
> device_del(ddev);
> out_disk_release_events:
> - disk_release_events(disk);
> + /* disk_release() will call disk_release_events(). */
> out_free_ext_minor:
> if (disk->major == BLOCK_EXT_MAJOR)
> blk_free_ext_minor(disk->first_minor);
.. actually while you're at it - blk_free_ext_minor is also done
by bdev_free_inode called from disk_release.
So we can just remove the out_disk_release_events and out_free_ext_minor
labels entirely.
> --
> 2.32.0
---end quoted text---
next prev parent reply other threads:[~2021-12-16 16:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 16:00 [PATCH] block: fix error handling for device_add_disk Tetsuo Handa
2021-12-16 16:18 ` Christoph Hellwig [this message]
2021-12-16 16:19 ` Christoph Hellwig
2021-12-17 10:37 ` Tetsuo Handa
2021-12-19 20:00 ` Luis Chamberlain
2021-12-20 8:23 ` Tetsuo Handa
2021-12-20 19:16 ` Luis Chamberlain
2021-12-21 11:41 ` Tetsuo Handa
2021-12-21 21:50 ` Luis Chamberlain
2021-12-21 10:08 ` Christoph Hellwig
2021-12-21 10:15 ` Christoph Hellwig
2021-12-21 10:21 ` Tetsuo Handa
2021-12-21 13:46 ` Tetsuo Handa
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=20211216161806.GA31879@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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