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=1796384429; b=Lp+CtKFoyFxm2SmW7wDJBynS/wxgUnIA6DpNyB6pwXVLCO+/3SBp+VoNV2qKTfB5+sVp mMXxO/VB3Ln2E9Jc/jm/XGHKMDl/eRQt71KCNyueKqeAQ/JErIe2jyMKSUljajGGmr+pE YwxxT+2cEnDy/iAOa4YJnwnH63xDw6G6LBS0lApVO6bQ1VMFEW8d6wqDk+6hhBKePjSFe SOJ+8X+/jwx8ovtRH4yhYf8AgnBvFN6/za339OGvi0HP7zlH/lDpHVjiGTPMVpwEALRlj PmzCyutyQf7c/YytQOaYS1q1d2k8C3npYNYi7g1C0FdXah0Qn1M4wb47Z5+c2zFFWEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384429; 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=Zi426EnSefAf5u6hLXFDFjcg7iUAPs3nUrSQqXDUADY=; b=oj8coozPExk8/Ws49/nalLwa49SkP97D4ln1qSrMdFcswuFK2XmbXdwUt2tPGzZLer4d a+IHEZ997kIOL0uNkXD+aSda9tjrw7clK/y2m9VLeLg7a8gRNRQiW7SM6WihkBsO8fuQD 1jtzfsHk8UglE3axnFsoAp8MCRPkz1rOlEjm9StfCGk4hgC4rnrCvPAyYp3hLpec01tQi BM49Qjm1ykf8La70pjd3okVCOS2cnt4rgurUoChNsVok1ofwJaYDYn3pHbMVKxIzbRoYE szjpH6OnjUFDj7lAikJABsuUA0B9qmghPjE57k+otFiDYibS2OJwums3TezzuyoyyNg== 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=SxQJihzt; 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 4EA94606A322; Fri, 4 Dec 2026 11:40:29 +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=SxQJihzt Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDFA71F000C2; Fri, 4 Dec 2026 11:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384429; bh=Zi426EnSefAf5u6hLXFDFjcg7iUAPs3nUrSQqXDUADY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SxQJihztyg2VzP2wFvajR/RRkDM4eJ7fR8dC5fAH62+ivNKBsC7IsYOwe/3ap2v10 F88WyvvfR4TQXXARcvfdecjp1I1m4X7ylsc1HrYtj+nk10QRoK+7Qp/QK1ZlEh9I1c /rTvH4uw+dJIygPmpVxbquBmm4t3YUae8Qg3/KnQ= 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.6 0144/1167] nvmet-rdma: disconnect only established queues Date: Fri, 4 Dec 2026 18:52:51 +0900 Message-ID: <20261204100705.836271854@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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