Re: [PATCH net-next v6 0/6] tls: perform TLS 1.3 KeyUpdate in the kernel
From: Sabrina Dubroca
Date: Tue Dec 01 2026 - 07:31:23 EST
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