[PATCH v3 3/3] nvme-tcp: consume TLS records without application data
Hannes Reinecke
hare at suse.de
Thu Nov 12 23:50:37 PST 2026
On 11/12/26 10:13 PM, Martin Belanger via B4 Relay wrote:
> From: Martin Belanger <martin.belanger at dell.com>
>
> A peer may send a TLS record without application data at any time
> after the handshake: 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. nvme_tcp_try_recv() 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.
>
> On -EINVAL, read the record with recvmsg(), which reports the record
> type. Discard handshake messages other than KeyUpdate. Log alerts, and
> fail the queue on a fatal alert. Fail the queue on a KeyUpdate, which
> nvme-tcp cannot answer, and on any other record type. recvmsg() takes
> the socket lock, so release it around the read.
>
> Handle these records in one helper, also for the records that arrive
> ahead of the ICResp. A warning alert ahead of the ICResp no longer fails
> the connection.
>
> On a poll queue, nvme_tcp_poll() and nvme_tcp_io_work() can both see
> the record while the socket lock is released. A queue flag makes sure
> that only one of them reads it.
>
> svc_tcp_recvfrom() in sunrpc handles -EINVAL from read_sock() the same
> way.
>
> Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
> Cc: stable at vger.kernel.org
> Signed-off-by: Martin Belanger <martin.belanger at dell.com>
> ---
> drivers/nvme/host/tcp.c | 113 +++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 97 insertions(+), 16 deletions(-)
>
Far better.
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list