All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Casey Chen <cachen@purestorage.com>
Cc: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org,
	yzhong@purestorage.com, sconnor@purestorage.com, axboe@kernel.dk,
	mkhalfella@purestorage.com
Subject: Re: [PATCH 1/1] nvme: fix use-after-free of admin queue via stale pointer
Date: Wed, 29 Oct 2025 18:39:34 -0600	[thread overview]
Message-ID: <aQKzxpJp98Po_pch@kbusch-mbp> (raw)
In-Reply-To: <20251029210853.20768-2-cachen@purestorage.com>

On Wed, Oct 29, 2025 at 03:08:53PM -0600, Casey Chen wrote:
> 
> Fix this by taking an additional reference on the admin queue during
> namespace allocation and releasing it during namespace cleanup.

Since the namespaces already hold references on the controller, would it
be simpler to move the controller's final blk_put_queue to the final
ctrl free? This should have the same lifetime as your patch, but with
simpler ref counting:

---
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index fa4181d7de736..0b83d82f67e75 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4901,7 +4901,6 @@ void nvme_remove_admin_tag_set(struct nvme_ctrl *ctrl)
         */
        nvme_stop_keep_alive(ctrl);
        blk_mq_destroy_queue(ctrl->admin_q);
-       blk_put_queue(ctrl->admin_q);
        if (ctrl->ops->flags & NVME_F_FABRICS) {
                blk_mq_destroy_queue(ctrl->fabrics_q);
                blk_put_queue(ctrl->fabrics_q);
@@ -5045,6 +5044,7 @@ static void nvme_free_ctrl(struct device *dev)
                container_of(dev, struct nvme_ctrl, ctrl_device);
        struct nvme_subsystem *subsys = ctrl->subsys;

+       blk_put_queue(ctrl->admin_q);
        if (!subsys || ctrl->instance != subsys->instance)
                ida_free(&nvme_instance_ida, ctrl->instance);
        nvme_free_cels(ctrl);
--

  parent reply	other threads:[~2025-10-30  0:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29 21:08 [PATCH 0/1] cover letter Casey Chen
2025-10-29 21:08 ` [PATCH 1/1] nvme: fix use-after-free of admin queue via stale pointer Casey Chen
2025-10-29 23:00   ` Chaitanya Kulkarni
2025-10-29 23:33     ` Ming Lei
2025-10-30  0:39   ` Keith Busch [this message]
2025-10-30  8:12     ` Chaitanya Kulkarni
2025-10-31  2:54       ` Keith Busch
2025-10-31  8:16         ` Chaitanya Kulkarni
2025-10-31 19:19       ` Casey Chen
2025-10-31 19:31         ` Chaitanya Kulkarni
2025-11-04 22:39           ` Casey Chen
2025-11-04 23:00             ` Keith Busch

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=aQKzxpJp98Po_pch@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=cachen@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=mkhalfella@purestorage.com \
    --cc=sconnor@purestorage.com \
    --cc=yzhong@purestorage.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.