Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Martin Belanger <martin.nvme.dev@gmail.com>
Cc: John Fastabend <john.fastabend@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Hannes Reinecke <hare@kernel.org>, Chuck Lever <cel@kernel.org>,
	kernel-tls-handshake@lists.linux.dev,
	linux-nvme@lists.infradead.org,
	Alistair Francis <alistair.francis@wdc.com>,
	Martin Belanger <martin.belanger@dell.com>,
	Daniel Pereira <danielmaraboo@gmail.com>
Subject: Re: [PATCH net-next v6 0/6] tls: perform TLS 1.3 KeyUpdate in the kernel
Date: Tue, 1 Dec 2026 13:31:14 +0100	[thread overview]
Message-ID: <aw6-EhjhIh5TuHIt@krikkit> (raw)
In-Reply-To: <7f9b7ab9-9728-42be-a5c1-9e8e62c23ab9@gmail.com>

2026-11-09, 07:14:01 -0500, Martin Belanger wrote:
> Hi Sabrina,
> 
> On 11/6/26 16:40, Sabrina Dubroca wrote:
> > I'm on a medical break so I won't be able to give this a proper review
> > for another week or two, but since it keeps landing in my inbox, I
> > want to make a comment.
> [...]
> > So this is kind of a "can we slow down until we agree that we
> > really want that?"
> 
> I am sorry to hear that. I hope you feel better soon. There is no
> hurry. I will not send a new version before we agree on the
> direction.

Thanks. I'm back now, I'm not fully caught up on everything but
getting there.


> >> kTLS does not currently handle TLS 1.3 KeyUpdate. It never sends a
> >> KeyUpdate.
> >
> > Because it isn't meant to handle any part of the handshake at all,
> > just the record layer.
> [...]
> > So what you're proposing is a very fundamental change to how kTLS
> > works, I'm not convinced we want to go this way.
> 
> KeyUpdate is a handshake message, but it changes only record layer
> state: the traffic key and the record sequence number. The new
> secret is one HKDF-Expand-Label of the current one. Nothing else from
> the handshake is needed.

"nothing else but change the keys" is already significant IMO, even if
recomputing them is quite simple.

> > If userspace libraries don't do the right thing, we can fix the
> > libraries.
> 
> I agree. The main users of this series are kernel consumers:
> NVMe/TCP (host and target) and sunrpc (client and nfsd). They have
> no user-space process above the socket. tlshd does the handshake,
> hands the keys to the kernel and exits.

Not a TLS expert (beyond what's in the kernel), but that feels wrong.

> > And that can't be handled with the existing handshake subsystem?
> 
> Not without new problems:
> 
> - A handshake daemon cannot write the KeyUpdate record to a kernel
>   socket. It has no file descriptor for it.

That sounds like something is missing in net/handshake.

> - NVMe/TCP sets sk_set_memalloc() on its sockets so that it can
>   write out pages under memory pressure. A daemon has no such
>   guarantee. With root or swap on NVMe/TCP, the daemon can wait for
>   a page-in from the queue that waits for the daemon. An upcall or a
>   reconnect every few minutes makes this deadlock possible every few
>   minutes.

Is swap on NVMe/TCP really a thing? This whole paragraph sounds
bonkers to me.

> - The traffic secrets must reach the kernel in any design. If each
>   consumer does the KeyUpdate itself, NVMe/TCP, nvmet-tcp, sunrpc,
>   nfsd and every future kTLS consumer need the same state machine.
>   In kTLS it is one implementation, which user-space applications
>   can use too.

I think almost all of it could be in net/handshake.

> >> the 2^24 limit can be reached in less than 10 minutes in many cases.
> >
> > My math says that's 28k records/second, it's a lot.
> 
> Storage traffic is different from HTTPS. The NVMe/TCP host sends one
> TLS record per command, and a 4 KiB read is a 72-byte record. The
> record count follows I/O operations, not bytes. 28k operations per
> second on one queue is normal for NVMe. I measured one queue reaching
> 2^24 records in about 80 seconds. Connections stay up as long as the

I know rekeys in 1.3 are pretty lightweight, but this feels kind of
silly.

> host does, so even at 1000 records per second the limit comes after
> about 4.7 hours.
> 
> Without KeyUpdate, the consumer must reconnect at the limit. For
> NVMe/TCP this tears down all queues of the controller, stops the I/O
> in flight and repeats every handshake. NVMe/TCP is storage for
> critical systems: databases for banking and stock trading, AI
> training data, and systems that hold personal data. These systems
> cannot reset their storage every few minutes.
> 
> > I'm not yet convinced this is a strong enough argument to justify
> > changing the model under which ktls operates
> 
> RFC 9846 4.7.3: after a KeyUpdate with update_requested, the receiver
> MUST send its own KeyUpdate "prior to sending its next Application
> Data record". If a sendmsg() or sendfile() is in progress on another
> thread, nothing above kTLS can stop it before its next record. kTLS
> checks before each record.

And the next paragraph says "oh well there may be some messages in
flight", so I don't understand what difference it makes to stop a few
records earlier.
"rekey ASAP" sure, anything else makes no sense to me.


[answering your new message here, since it arrived as I was finishing this:]
> The series is not only for kernel consumers. User-space libraries
> benefit as well.

Not much, since they can't rely on the new feature being present. So
they will still have to implement everything needed to handle rekeys
in userspace.

> A library above kTLS cannot count records
> precisely, because the kernel splits and merges the bytes it writes.

Yeah, you're not meant to do that, but you get getsockopt() and get
the recseq back.

> It also cannot place a KeyUpdate at an exact point in the record
> stream.

Why not?

> With the series, GnuTLS or OpenSSL can register the traffic
> secrets when they install the kTLS keys. The kernel then handles
> KeyUpdate in both directions, also for sendfile() and splice().
> Without the secrets, nothing changes.

Stealing handshake messages under a full TLS implementation's feet
doesn't seem right.

> If the direction is acceptable, I would like to post v7 before
> net-next closes for the 7.5 merge window. v7 drops TLS_TX_KEY_UPDATE
> and addresses the Sashiko findings on v6. If you still have doubts,
> I will wait for your review and not post v7.

I'm not convinced right now.

If we end up going further with this approach, please CC some crypto
folks on at least the first patch, so they can comment on that bit. At
least the maintainers of lib/crypto, maybe also Herbert Xu (crypto/).

-- 
Sabrina


      parent reply	other threads:[~2026-12-01 12:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 16:30 [PATCH net-next v6 0/6] tls: perform TLS 1.3 KeyUpdate in the kernel Martin Belanger via B4 Relay
2026-11-05 16:30 ` [PATCH net-next v6 1/6] tls: add HKDF-Expand-Label for the TLS 1.3 key schedule Martin Belanger via B4 Relay
2026-11-05 16:30 ` [PATCH net-next v6 2/6] tls: add socket options to register the traffic secrets Martin Belanger via B4 Relay
2026-11-05 16:30 ` [PATCH net-next v6 3/6] tls: loop in tls_sw_splice_read() until it has a record Martin Belanger via B4 Relay
2026-11-05 16:30 ` [PATCH net-next v6 4/6] tls: update the RX key when a KeyUpdate is received Martin Belanger via B4 Relay
2026-11-05 16:30 ` [PATCH net-next v6 5/6] tls: send a KeyUpdate at the record limit and on request Martin Belanger via B4 Relay
2026-11-06 16:30   ` sashiko-bot
2026-11-05 16:30 ` [PATCH net-next v6 6/6] selftests/tls: add KeyUpdate tests Martin Belanger via B4 Relay
2026-11-06 21:40 ` [PATCH net-next v6 0/6] tls: perform TLS 1.3 KeyUpdate in the kernel Sabrina Dubroca
2026-11-09 12:14   ` Martin Belanger
2026-12-01 11:48     ` Martin Belanger
2026-12-01 12:31     ` Sabrina Dubroca [this message]

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=aw6-EhjhIh5TuHIt@krikkit \
    --to=sd@queasysnail.net \
    --cc=alistair.francis@wdc.com \
    --cc=cel@kernel.org \
    --cc=corbet@lwn.net \
    --cc=danielmaraboo@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hare@kernel.org \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-tls-handshake@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.belanger@dell.com \
    --cc=martin.nvme.dev@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.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