Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Weiss <thnkslprpt@gmail.com>
To: Keith Busch <kbusch@kernel.org>, linux-nvme@lists.infradead.org
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>, Hannes Reinecke <hare@suse.de>
Subject: [PATCH] nvme-tcp: wait for in-flight TLS handshake callback
Date: Thu, 22 Oct 2026 10:19:34 +0300	[thread overview]
Message-ID: <20261022071934.3818224-1-thnkslprpt@gmail.com> (raw)

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



             reply	other threads:[~2026-10-22  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  7:19 Avi Weiss [this message]
2026-10-22  7:35 ` [PATCH] nvme-tcp: wait for in-flight TLS handshake callback 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

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=20261022071934.3818224-1-thnkslprpt@gmail.com \
    --to=thnkslprpt@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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