From: Christoph Hellwig <hch@infradead.org>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: Richard Weinberger <richard@nod.at>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
kernel@axis.com
Subject: Re: [PATCH 1/2] ubi: block: Fix use-after-free of gendisk
Date: Tue, 23 May 2023 22:58:09 -0700 [thread overview]
Message-ID: <ZG2ncaTjxCnRWcUZ@infradead.org> (raw)
In-Reply-To: <20230523-ubiblock-remove-v1-1-240bed75849b@axis.com>
On Tue, May 23, 2023 at 03:12:16PM +0200, Vincent Whitchurch wrote:
> static void ubiblock_cleanup(struct ubiblock *dev)
> {
> + int first_minor = dev->gd->first_minor;
> +
> /* Stop new requests to arrive */
> del_gendisk(dev->gd);
> /* Finally destroy the blk queue */
> dev_info(disk_to_dev(dev->gd), "released");
> put_disk(dev->gd);
> blk_mq_free_tag_set(&dev->tag_set);
> - idr_remove(&ubiblock_minor_idr, dev->gd->first_minor);
> + idr_remove(&ubiblock_minor_idr, first_minor);
I think the real fix here is to implement the free_disk method
and free the idr there. That ensures the ID can't be reused until
the disk is entirely freed as well.
next prev parent reply other threads:[~2023-05-24 5:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 13:12 [PATCH 0/2] ubi: block: fix use-after-free and deadlock Vincent Whitchurch
2023-05-23 13:12 ` [PATCH 1/2] ubi: block: Fix use-after-free of gendisk Vincent Whitchurch
2023-05-24 5:58 ` Christoph Hellwig [this message]
2023-05-23 13:12 ` [PATCH 2/2] ubi: block: Fix deadlock on remove Vincent Whitchurch
2023-05-24 6:04 ` Christoph Hellwig
2023-05-24 13:36 ` Vincent Whitchurch
2023-05-25 9:50 ` hch
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=ZG2ncaTjxCnRWcUZ@infradead.org \
--to=hch@infradead.org \
--cc=kernel@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
--cc=vincent.whitchurch@axis.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