From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796131646; b=XEkR1bpB3AW9rfYJpxLSMpjNiekdv4DpIoXVJNt3Ewa+TkH8hxI/xSR0Fhw3o4r36Rzk WwKefiH02cRUIxhu41d4LYfbaxdahXUmTO+twIje8ZEgnBkjT/NgxmGSl2TyW1bJKoBYj nU0cH2zIQaWqTELbgLjzt1uSNE2Lk6cYIoT5JsU1hs1K9qwmnyA5vRMwdAj2XtPnkFhtb BRKKXfFOu095AUE3fHWCFnTZcguTO9O8iZJYVIMbV6CBMVRi3ROROR8pcYN9mL1NMrWx2 dek7Nq9OJQ8xdRB8/Z1rHt/nkV26Babi5J8ifZDiu4pXoyfP5aNk0F/M1SzNPaj8wJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131646; h=DMARC-Filter:Received:DKIM-Signature:DKIM-Signature:DKIM-Signature: DKIM-Signature:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Spam-Flag:X-Spam-Level: X-Spamd-Result:X-Spam-Score; bh=ULio8gjqpLFnwQ4gNDfhfIrxS57ohOurSyiJ/BOGM0M=; b=KV0RPxt6NsYjLemqo/U4cM6SngQuT7u6iuy5ss/iv8I+15TXa/FsnlUyuhKw+OygB+7+ p2LqX+wMW68ZDVLR9OjcfBkiwzmuQDy4C7PKm4kM//Wv75nan9Y/+r80fDWYZjCstXhW1 E6N4Hcz//HfzV+zZMWLYV6r3IuYMgE/K7s8NXMGWFqgujxvby2DFExrPDqgfIP0AaQy1g UqYy6xMvBAM3jaKoNixwc98nIH4bT5v1OGKbs7YV4iP4HQIvHTX8CBOOHuY2hcxFOOQAQ jb5VH1vXddLFgSSK/3WpIMCoEFQ9HR+RtsXdVGKhGwcwbOMXUbXC7FIZ8lbn5LHZILg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ynyDDNtG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b="/UtRF3v6"; dkim=pass header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ym5UI58c; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5qjpEdi4; arc=none smtp.remote-ip=195.135.223.130 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45412606A31A; Tue, 1 Dec 2026 13:27:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45412606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ynyDDNtG; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/UtRF3v6; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ym5UI58c; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5qjpEdi4 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C67E22201; Tue, 1 Dec 2026 13:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796131643; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ULio8gjqpLFnwQ4gNDfhfIrxS57ohOurSyiJ/BOGM0M=; b=ynyDDNtGHYwKmUNSxIb/z3TwqX1APo0tjH7yTnGiybohci5qJIAUNDjU3oNbqCYl/HtlNK c+CVNe2N+FJ9YgWC9vkI8ZIU+EjKnIV+xWYO2YSM4ga9xY6FiIUJy9+5FyQlkFqHEkZisN L/xDf98U7iXsrbsyuHn+satbe9TcFFI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796131643; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ULio8gjqpLFnwQ4gNDfhfIrxS57ohOurSyiJ/BOGM0M=; b=/UtRF3v6zi1GtjpNhLP1lZ7S7sCi0Qfr2eJWUV/9gVhiq9ngkHlemTMSkm65nXYUJDDBro 5AwqOecKGdpZK7DQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1796131642; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ULio8gjqpLFnwQ4gNDfhfIrxS57ohOurSyiJ/BOGM0M=; b=ym5UI58cFn8zfHS8G5qnjAHztntCcJTX5HljmNUYUy3twc6JHJVObyhtPzDtQeEfv6X78Z OVAo6ssabHgSjs+Up3Se/SiUUuQoB+eXIWRp/OBFUzyPyqPSgv+GvD5m6MozYFpB2SQgj7 uQJMy91lxtc2Yt5xfv2T7XjxBTf5lhU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1796131642; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ULio8gjqpLFnwQ4gNDfhfIrxS57ohOurSyiJ/BOGM0M=; b=5qjpEdi4HDLbI7JdO+CTQ+lyAsZ4b7bTyflqEcXRWlG34N/nWcUhfkNVotFweNAmYC+wiX msx3HdVitdrFFSCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BFE8E133F6; Tue, 1 Dec 2026 13:27:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id loMnJTnLDmuhDQAAD6G6ig (envelope-from ); Tue, 01 Dec 2026 13:27:21 +0000 Message-ID: Date: Tue, 1 Dec 2026 14:27:21 +0100 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v6 0/6] tls: perform TLS 1.3 KeyUpdate in the kernel To: Sabrina Dubroca , Martin Belanger Cc: John Fastabend , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Shuah Khan , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Hannes Reinecke , Chuck Lever , kernel-tls-handshake@lists.linux.dev, linux-nvme@lists.infradead.org, Alistair Francis , Martin Belanger , Daniel Pereira References: <20261105-keyupdate-rfc-v6-0-99b695f9eb4f@gmail.com> <7f9b7ab9-9728-42be-a5c1-9e8e62c23ab9@gmail.com> Content-Language: en-US From: Hannes Reinecke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Flag: NO X-Spam-Level: X-Spamd-Result: default: False [-11.79 / 50.00]; SUSE_INTERNAL_BYPASS(-9.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TAGGED_RCPT(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[23]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[queasysnail.net,gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,kernel.org,davemloft.net,redhat.com,lwn.net,linuxfoundation.org,infradead.org,vger.kernel.org,lists.linux.dev,lists.infradead.org,wdc.com,dell.com]; MID_RHS_MATCH_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email] X-Spam-Score: -11.79 Hey Sabrina, (hope you've recovered now; good to hear that you are back) On 12/1/26 1:31 PM, Sabrina Dubroca wrote: > 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. > This 'nothing else' probably refers to the fact that one does _not_ have to do the full TLS handshake, but can derive the new traffic keys directly. >>> 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. > Ah, how so? This is basically the core design of tls handshake, so if someone has objections we'd be most interested in having them ... >>> 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. > We could, but it doesn't change the issue. >> - 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. > Swap is not the problem. root on NVMe/TCP is the problem. If we get the KeyUpdate message the root fs is not directly accessible (we cannot load the daemon from disk if it's swapped out, as this would require I/O on the connection which we need to reset). So we would need to mlock() the daemon to avoid that from happening. And mlock() all libraries. And hope like hell none of these are using pthreads, as the linux pthreads implementation _cannot_ be mlocked. (Which we learned the hard way from years of debugging multipathd.) >> - 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. > Yep. Hence the patchset :-) >>>> 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. > Not with 100GigE. You're reaching the limit pretty fast there. And storage arrays (or fast NVMe SSDs) can easily do 100k IOPs nowadays. >> 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. > Because stopping would be a hard stop, ie we have to stop RX/TX while doing the upcall. > > [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. > But that's the thing; we can't. Rekey is transparent by virtue of being asynchronous; you get a rekey message on the RX side, recompute traffic secret for the TX side, update keys, and RX is flowing again. _Then_ you send a rekey message on the RX side, recompute the traffic secret, and encrypt the following messages with the new traffic secret. This has to be _strictly_ timed, ie there is zero leeway once you receive an rekey or send a rekey; the very next record is using the new traffic secret. If you are using upcalls to recompute traffic secrets you _have_ to stop RX once you receive the rekey message, wait for the upcall to complete, and start the RX side again. That is inserting stalls in the RX flow (in a regular basis, mind ...) and is kinda defeating the purpose of rekeying. The same goes for the TX side, obviously. (And my suspicion is that most of the latency is the upcall itself, not in the TLS handshake, so we'll be better off by just dropping the connection entirely and let it reconnect. Which, incidentally, is what we're doing now...) But most annoyingly we would have to do the upcall from the ULP (as that is where we're doing the upcall nowadays). So if we were going with that model we either - do the upcall from the in-kernel TLS code, resulting in two independent instances (TLS and ULP code) doing upcalls. With all the race conditions that entails. Bah. - do the upcall from the ULP code. But that would require the ULP code to suddenly have to be aware of protocol-specific corner case (are we using TLS? Does the upcall support Rekey?). Equally, bah. >> 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? > See above. Timing is the key. In order to do that you'll have to stop RX/TX. >> 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. > I do agree it's putting quite some protocol bits into the TLS code. But at the same time TLS KeyUpdate is _meant_ to be handled in-line; unfortunately it's at odds with the current kernel TLS concept of moving the TLS handshake to userspace. But thanks for your comments. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@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