mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>,
	linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me,
	sgogte@purestorage.com, hare@kernel.org, wagi@kernel.org,
	linux-kernel@vger.kernel.org,
	Guixin Liu <kanie@linux.alibaba.com>
Subject: Re: [PATCH] nvme-rdma: fix NULL queue->ctrl dereference on reconnect
Date: Fri, 30 Oct 2026 15:34:12 +0530	[thread overview]
Message-ID: <1408da28-a55e-448b-b493-d60fd5d20524@linux.ibm.com> (raw)
In-Reply-To: <20261029141843.2066616-1-christian.aurichzm@gmail.com>

On 10/29/26 7:48 PM, Christian Aurich Zanettini Martins wrote:
> On Thu, Oct 29, 2026 at 03:05:21AM -0300, Christian Aurich Zanettini Martins wrote:
>>   static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl)
>>   {
>>   	struct nvme_rdma_ctrl *ctrl = to_rdma_ctrl(nctrl);
>> +	int i, nr_queues = NVME_RDMA_OPT_NR_QUEUES(nctrl->opts);
> 
> Please drop this one, I'll send a v2. Thanks for the reviews, Nilay
> and Christoph.
> 
> When creating the controller fails, nvmf_create_ctrl() frees opts right
> after nvme_put_ctrl(), but that put is not always the last one. With
> CONFIG_DEBUG_KOBJECT_RELEASE, KASAN reports a use-after-free here on
> every failed connect.
> 
> v2 only moves queue->ctrl and leaves queue_lock where it is.

Ah, so in v2, we would only move the initialization of queue->ctrl while
leaving queue->queue_lock unchanged. This avoids tying the lifetime of
queue->queue_lock to the rdma controller and looks correct.

However, I think a similar issue could arise in the NVMe/TCP implementation
due to the recent changes in commit 2eeeaa9c1ff0 ("nvme-tcp: Validate the
queue state under the queue lock in the address attribute"). We should
probably address those changes as well.

Unlike NVMe/RDMA, NVMe/TCP needs to tie the lifetime of queue->queue_lock
to that of the tcp controller. Therefore, we may need to introduce a separate
ctrl->allocated_queue_count, initialized with the number of queues allocated
at connect time. We could then use ctrl->allocated_queue_count in
nvme_tcp_free_ctrl() to destroy the controller-owned queue objects, rather
than accessing nctrl->opts to determine nr_queues.

Thanks,
--Nilay

      reply	other threads:[~2026-10-30 10:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  6:05 Christian Aurich Zanettini Martins
2026-10-29 10:41 ` Nilay Shroff
2026-10-29 12:16 ` Christoph Hellwig
2026-10-29 14:18 ` Christian Aurich Zanettini Martins
2026-10-30 10:04   ` Nilay Shroff [this message]

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=1408da28-a55e-448b-b493-d60fd5d20524@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=christian.aurichzm@gmail.com \
    --cc=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kanie@linux.alibaba.com \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=sgogte@purestorage.com \
    --cc=wagi@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

all inboxes | Powered by JetHome®