From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387201; b=xcp7vsZJohpDBwUtyDLlDGfT/sS1pOHWu+krqrfrFLJK+RuaBpG/VDcl7QBvKFofU9bK +O30gJAWcPfSsaN+/gy83tkqQKnsPPilk3zwvvB+MyHPVdf2hEzhfpz5DW3n1ChRtG2Hc e7qCzC/4HS3XYqr1CsI/GVXy7D0nAEiyKgGEX9VIYR7RlBkW6wRUtOfzMgdYrxgu3PLzA UJJfXviOjfmEAiGHdvkDV1Sp0qKf/Qzi0G8EYXS8PapdV+YqIw9iEroCRvJi4e/jHM3Kt U6xu8wyvs+JMheGdKeawcTizint8hGdi3o26dF5jB5xcBeOy/QJfyp/AupkszsbePfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387201; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=uFu7orLdgkMPvD7q06rJ1LW1dn4NqvGTkeFZD5pZRbQ=; b=3H8hQFSlJf2VGkJkAJ17Q5KApwdiMefG2EL771NzRWnrpeR05nrjV1NZCeUFh4wBbTyI qvsn+El6MPl0hrKDzhUAmPx0VkoCGa9LW1mw8D7fdZ3iEzpXJvVSqB9JwRY7xAfU90sy9 PBFCwnWfbUGpRF2ePZROxF2ALcnIX7Z7rJ6Sih7B2G9qexs/1QH5yQ3B1IT335kKVQxGJ nVSB3LQYJ6OtdFWDJ+lXgUzM6b3ubECJSaJQC60rQOZEz2bQXXhy5Mt751qY899LGULAm 7NBuN0YbfgoMze/hpvszDile/gOLL0Xnsxcnkf2umpk7Ff/ZM/YQ8CRTr+PzLBnzSig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HZmzQz6N; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0D53606A322; Fri, 4 Dec 2026 12:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HZmzQz6N Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E4371F00897; Fri, 4 Dec 2026 12:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387201; bh=uFu7orLdgkMPvD7q06rJ1LW1dn4NqvGTkeFZD5pZRbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HZmzQz6NVOb1xOWvakIxS/yw+KZKtggQ0zXVbZNrYrCUmwPRp0mzRQI2LPRl6c0o4 QIZmmAGu+nW/e/ekj16wzc99o974PtXvIJuc+Dc6bATRRHWJPTcVkCYUqzNGk/7Eh0 b4rVJsaKWfGFy596bwmY15NeQI0jOdXVAAoYee9o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Chris Mason , Jens Axboe , Keith Busch , Sasha Levin Subject: [PATCH 6.1 0105/1059] nvmet-rdma: disconnect only established queues Date: Fri, 4 Dec 2026 18:53:56 +0900 Message-ID: <20261204100646.920960238@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit 000a9f4492abad6008682b55571ddc31941963e3 ] Over iWARP, rdma_disconnect() sleeps in iw_cm_disconnect() until the ESTABLISHED event of the connection has been handled, and iw_cm handles all events of all connections one at a time on iw_cm_wq. nvmet_rdma_destroy_port_queues(), nvmet_rdma_remove_one() and nvmet_rdma_delete_ctrl() walk the queue list with nvmet_rdma_queue_mutex held and call rdma_disconnect() for each, while nvmet_rdma_cm_handler() takes the same mutex. If the walk sleeps on a queue whose ESTABLISHED is queued behind another queue's event, both are stuck and iWARP connection handling is dead until reboot. A peer sets that up by connecting in a loop, or over siw by asking for MPA peer-to-peer mode and then staying silent, which delays ESTABLISHED indefinitely. Only call rdma_disconnect() for a queue in NVMET_RDMA_Q_LIVE, which the handler sets when it gets ESTABLISHED. A queue that never got there is left to the release work: ib_drain_qp() moves the QP to the error state, which ends the connection, and rdma_destroy_id() tells the peer. Over IB and RoCE the skipped call did nothing more than that. Fixes: f1d4ef7d8883 ("nvmet-rdma: register ib_client to not deadlock in device removal") Fixes: fcf73a804c7d ("nvmet-rdma: fix use-after-free when a port is removed") Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Signed-off-by: Chris Mason Signed-off-by: Jens Axboe Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/rdma.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index 87f1a4b6f4b9e..7e595b8dcdc75 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c @@ -1691,7 +1691,7 @@ static void nvmet_rdma_queue_established(struct nvmet_rdma_queue *queue) static void __nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue) { - bool disconnect = false; + bool disconnect = false, live = false; unsigned long flags; pr_debug("cm_id= %p queue->state= %d\n", queue->cm_id, queue->state); @@ -1710,6 +1710,7 @@ static void __nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue) } fallthrough; case NVMET_RDMA_Q_LIVE: + live = queue->state == NVMET_RDMA_Q_LIVE; queue->state = NVMET_RDMA_Q_DISCONNECTING; disconnect = true; break; @@ -1719,7 +1720,17 @@ static void __nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue) spin_unlock_irqrestore(&queue->state_lock, flags); if (disconnect) { - rdma_disconnect(queue->cm_id); + /* + * Over iWARP rdma_disconnect() sleeps until the CM has handled + * the ESTABLISHED event of this connection. The CM handles the + * events of all connections one at a time, and our handler + * takes nvmet_rdma_queue_mutex, which callers of this function + * hold. So a queue that has not seen the event is left to the + * release work: ib_drain_qp() moves the queue pair to the error + * state, which ends the connection. + */ + if (live) + rdma_disconnect(queue->cm_id); queue_work(nvmet_wq, &queue->release_work); } } -- 2.53.0