From: Martin Belanger via B4 Relay <devnull+martin.nvme.dev.gmail.com@kernel.org>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Hannes Reinecke <hare@kernel.org>
Cc: Martin Belanger <martin.nvme.dev@gmail.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Martin Belanger <martin.belanger@dell.com>,
stable@vger.kernel.org
Subject: [PATCH v2 0/3] nvme-tcp: consume TLS records without application data on a live queue
Date: Wed, 11 Nov 2026 15:42:38 -0500 [thread overview]
Message-ID: <20261111-nvme-tcp-live-ctrlrec-v2-0-6295202b84de@gmail.com> (raw)
After the TLS handshake, a peer may send records that carry no
application data: a NewSessionTicket, a KeyUpdate or an alert.
tls_sw_read_sock() cannot pass such a record to nvme_tcp_recv_skb().
It returns -EINVAL and leaves the record at the head of the receive
queue. Since commit 288cfa187208 ("nvme-tcp: start error recovery when
read_sock fails"), nvme-tcp then starts error recovery, and the
controller reconnects.
TLS 1.3 allows a server to send a NewSessionTicket at any time after
the handshake (RFC 8446, section 4.6.1). Alerts can also arrive at any
time.
Patch 1 aligns the control message buffer that receives the record
type.
Patch 2 moves the TLS record read loop into a helper. No functional
change.
Patch 3 reads the record with recvmsg() when read_sock() returns
-EINVAL, and handles it by type. Handshake messages other than
KeyUpdate are discarded and alerts are logged. A fatal alert, a
KeyUpdate or another record type fails the queue.
Patch 3 detects a KeyUpdate only when it is the first handshake
message of the record. A KeyUpdate that follows another message in the
same record is discarded with it. The next record then fails to
decrypt, and the queue fails as it does today.
All patches are tagged for stable, because 288cfa187208 is in 6.12.117,
6.18.63 and 7.3.4.
Tool use
========
I developed this series with the help of an LLM coding assistant. It
drafted code, tests and changelogs, and helped with analysis of the
kTLS and sunrpc sources. I reviewed, edited and tested all of it, and
I am responsible for the content.
Testing
=======
Host and target in one VM (virtme-ng), on 7.4-rc2. A test-only change
to net/tls makes the target send records on a live I/O queue during
I/O. Each case writes data and reads it back with O_DIRECT.
Records sent by the target 7.4-rc2 With this series
--------------------------- ---------- --------------------------
NewSessionTicket, 64 bytes reconnect queue stays live
2 x 300, 2 x 1000, 6 x 64 reconnect queue stays live
close_notify alert reconnect queue stays live
warning alert (90) reconnect queue stays live, logged
fatal alert (40) reconnect reconnect, logged
KeyUpdate reconnect reconnect, logged
Data was correct in all cases. Also built with W=1, with and without
CONFIG_NVME_TCP_TLS.
Poll queues are not tested. Polled I/O hangs in my test VM, also on
7.4-rc2 without this series.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
---
Changes in v2:
- New patch 1: use a union with struct cmsghdr for the record type
buffer, as sunrpc does. (Sashiko)
- Patch 3: on a poll queue, nvme_tcp_poll() and nvme_tcp_io_work()
could both read the same record. A queue flag lets only one of them
read it. (Sashiko)
- Patch 3: drop a log line that repeated the error of
nvme_tcp_try_recv().
- Link to v1: https://patch.msgid.link/20261109-nvme-tcp-live-ctrlrec-v1-0-47ba61670e65@gmail.com
---
Martin Belanger (3):
nvme-tcp: use an aligned buffer for the TLS record type
nvme-tcp: move the TLS record read loop into a helper
nvme-tcp: consume TLS records without application data
drivers/nvme/host/tcp.c | 175 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 144 insertions(+), 31 deletions(-)
---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261109-nvme-tcp-live-ctrlrec-4539b9390301
Best regards,
--
Martin Belanger <martin.nvme.dev@gmail.com>
next reply other threads:[~2026-11-11 20:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 20:42 Martin Belanger via B4 Relay [this message]
2026-11-11 20:42 ` [PATCH v2 1/3] nvme-tcp: use an aligned buffer for the TLS record type Martin Belanger via B4 Relay
2026-11-11 20:42 ` [PATCH v2 2/3] nvme-tcp: move the TLS record read loop into a helper Martin Belanger via B4 Relay
2026-11-11 20:42 ` [PATCH v2 3/3] nvme-tcp: consume TLS records without application data Martin Belanger via B4 Relay
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=20261111-nvme-tcp-live-ctrlrec-v2-0-6295202b84de@gmail.com \
--to=devnull+martin.nvme.dev.gmail.com@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.belanger@dell.com \
--cc=martin.nvme.dev@gmail.com \
--cc=sagi@grimberg.me \
--cc=stable@vger.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®