Netdev List
 help / color / mirror / Atom feed
From: Martin Belanger <martin.nvme.dev@gmail.com>
To: Sabrina Dubroca <sd@queasysnail.net>
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: Fri, 4 Dec 2026 14:44:44 -0500	[thread overview]
Message-ID: <34853fe3-1c08-4d05-967b-cb43275532a4@gmail.com> (raw)
In-Reply-To: <axL2DV43klkpbqiY@krikkit>



On 12/4/26 12:19, Sabrina Dubroca wrote:
> I'm struggling to parse this and see what hooks into what.

Sorry, here it is in terms of functions.

When the handshake completes, net/handshake calls one inline helper
from include/net/tls.h:

  tls_set_handshake_ops(sk, ops, priv, tx_rec_limit);

It stores ops, priv and the limit in the tls_context. ops has three
callbacks into net/handshake. From then on only kTLS calls; it calls
them with the socket locked.

RX: tls_check_pending_rekey() already finds received handshake
records. If ops are set, it passes the record to ops->rx_record().
net/handshake parses the KeyUpdate and returns flags: "consumed",
"install the next RX key", "send a KeyUpdate". For the RX key, kTLS
calls ops->next_key() and installs the result with
tls_set_sw_offload(), as your user space rekey does. The record does
not reach the consumer.

TX: in tls_sw_sendmsg_locked(), before a new data record, kTLS checks
two values inline: the "send a KeyUpdate" flag from above, and
rec_seq >= tx_rec_limit. A normal record costs these two comparisons
and no call. If either is true, kTLS calls ops->tx_record() for the
KeyUpdate message, sends it as a handshake record with the current
key, waits for the encryption, then calls ops->next_key() and
installs the next TX key.

> I wonder how you still get 200 lines in net/tls

Counting C code only (no comments, no blank lines), it is 212 lines.
What remains is record layer work that has to run inside kTLS, with
tx_lock and the socket lock held:

- TX: the KeyUpdate must go out at a record boundary, after the
  pending data record is closed, and the key switch must follow with
  no other record in between. This uses tls_sw_sendmsg_locked() and
  tls_encrypt_async_wait().
- RX: the KeyUpdate record must be taken out of the receive path
  (recvmsg, read_sock, splice_read) and the RX key installed before
  the next record is decrypted.
- the ops struct, the context fields and the inline setter.

net/handshake decides and computes: when to send, the message, HKDF,
the next secrets. It cannot do the sending or the key switch itself.
Those steps need kTLS's static functions and kTLS's locks. Also,
net/handshake is built in and TLS can be a module, so net/handshake
can only reach kTLS through inline helpers or callbacks.

If code is easier to review, I can post the prototype as an RFC.

Martin

      reply	other threads:[~2026-12-04 19:44 UTC|newest]

Thread overview: 26+ 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-09 17:18   ` netdev-bot+sashiko
2026-11-10 16:49     ` Martin Belanger
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-09 17:18   ` netdev-bot+sashiko
2026-11-10 16:55     ` Martin Belanger
2026-11-05 16:30 ` [PATCH net-next v6 6/6] selftests/tls: add KeyUpdate tests Martin Belanger via B4 Relay
2026-11-09 17:18   ` netdev-bot+sashiko
2026-11-10 16:59     ` Martin Belanger
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
2026-12-01 13:27       ` Hannes Reinecke
2026-12-02 15:37       ` Martin Belanger
2026-12-02 18:51         ` Chuck Lever
2026-12-02 19:12           ` Martin Belanger
2026-12-04 17:21             ` Sabrina Dubroca
2026-12-04 19:47               ` Martin Belanger
2026-12-03  9:34           ` Hannes Reinecke
2026-12-04 17:19         ` Sabrina Dubroca
2026-12-04 19:44           ` Martin Belanger [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=34853fe3-1c08-4d05-967b-cb43275532a4@gmail.com \
    --to=martin.nvme.dev@gmail.com \
    --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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=sd@queasysnail.net \
    --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