Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-tcp: wait for in-flight TLS handshake callback
@ 2026-10-22  7:19 Avi Weiss
  2026-10-22  7:35 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Avi Weiss @ 2026-10-22  7:19 UTC (permalink / raw)
  To: Keith Busch, linux-nvme
  Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, Hannes Reinecke

When nvme_tcp_start_tls() times out or is interrupted,
tls_handshake_cancel() can return false after handshake_complete()
marks the request completed, but before nvme_tcp_tls_done()
finishes. Error cleanup can then release the queue while the
callback still accesses it.

Wait for queue->tls_complete when cancellation loses, before
continuing cleanup. Preserve the original timeout or signal error.

This follows the cancellation/completion synchronization used
in SunRPC for:
- commit d00e32f84ca1 ("sunrpc: wait for in-flight TLS handshake
  callback when cancel loses race")
- commit a89dd5974588 ("SUNRPC: wait for in-flight client TLS
  handshake callback")

Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 drivers/nvme/host/tcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 7eec983c0ead..26a626abef7b 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1816,7 +1816,8 @@ static int nvme_tcp_start_tls(struct nvme_ctrl *nctrl,
 		dev_err(nctrl->device,
 			"queue %d: TLS handshake failed, error %d\n",
 			qid, ret);
-		tls_handshake_cancel(queue->sock->sk);
+		if (!tls_handshake_cancel(queue->sock->sk))
+			wait_for_completion(&queue->tls_complete);
 	} else {
 		if (queue->tls_err) {
 			dev_err(nctrl->device,

base-commit: 7be4bc52fd9e0e55dc9a2e0232b89427d2c4b614
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-28 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22  7:19 [PATCH] nvme-tcp: wait for in-flight TLS handshake callback Avi Weiss
2026-10-22  7:35 ` sashiko-bot
2026-10-23  6:38 ` Hannes Reinecke
2026-10-28 14:57 ` Christoph Hellwig
2026-10-28 15:27   ` Avi Weiss
2026-10-28 15:35     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox