From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.65 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796413487; b=XFAXBXs6bNMEqOHsC06fh+I9jr//HBND5P1jQL/eDKkMLNZpBLQZeOyQSuSgveCQ7eVR QVs+m1b9H90zHyWeomOPS3gddowlhLpRUNqUhGJ1+LyvlHBQModtbO9ubk3+j9ywjSIOw 5QLo735RUXZuO7RLiJEDWPPhae8KI/iX1MJym9/+MMiriYnLfpAd5uHn8FoDqryGFY7pN OfJ9Xr/Vemq5bUiRDcgrC45et+aYkxq7X6UeuFSANRPCS2BafNbYO2YpVby2kh4l+vVfn 8VNOJJsTXG8ktRyZGbgB+Q5mYCeXBXy7lGzUMN/hGeI8ltkf7a7l6fkIcq7sbyH0zQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796413487; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=KEkPT6xXVGhR8PxKcN3aBi5ZfiLJiy8HcM5Obg64jE4=; b=hj04Cv5KN2TgIhgVTwuUkXWEFDgvVVbemcqmRV0tWNl6FbIDBzpJPEDc+8RuAO6K0S1r 3mfcbIu7fwa6F5bNa/orDys3Y1YtXEovvdCBLpVCAifyiz4edl1K/+GKosJEnkk1KhYxC xE9TWtxGg3e3EhZSunKq+OpD6itzzyjJbiCAoxKDxyGYA+RnUc85JfsV+lWnjoHnDRAww yqGls5KZDi2Q2NI85T9PA6q0CFpyjRg8hTDirrZd3ZL1EqN48P2DIh/PysA1YxStsxcqM V9iPdMk88JeNwcGKJQskLPHAXVsJWF2pfqS8qGhNGA9szqdivcJhh7uIY8BpvHp6Oig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IAOR3M1+; arc=none smtp.remote-ip=209.85.219.65 Received: from mail-qv1-f65.google.com (mail-qv1-f65.google.com [209.85.219.65]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC22B606A32D for ; Fri, 4 Dec 2026 19:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CC22B606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IAOR3M1+ Received: by mail-qv1-f65.google.com with SMTP id 6a1803df08f44-91c847584b8so15156466d6.0 for ; Fri, 04 Dec 2026 11:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796413486; x=1797018286; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KEkPT6xXVGhR8PxKcN3aBi5ZfiLJiy8HcM5Obg64jE4=; b=IAOR3M1+2NemHHuEEv1Rqb2WJBEOWZJiUktEsXJKOFf1W0pIMBQeWE7jnTjrrdCkgN zzW4QPbnuKxNEM6DRRdnZVeXIblTtnYEK1ODOGLTQjMCGDlRXwg3IDwd1pb0fOOOGaiG TG9K/O9erxnOK/tAMBx1qB+kRoyyCP2KdZe8vGx9te5Cp+cqb7Elzvv9PXTvi8deg9qn ldc0eun1mUKTyNTF1opswUB22B4OTV3/vyww7RRDMSrJOJSByCjXBnvUEK2+v6mQT69v mm20W7LIImy0f8PDbUPe+ETA3L6gokbfljxmYUp/ddOjloi8Z7OGnbXp3S0aEDcIL+dG H3GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796413486; x=1797018286; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KEkPT6xXVGhR8PxKcN3aBi5ZfiLJiy8HcM5Obg64jE4=; b=Ch4q3zOV6cQgMaILlNBzFydQgl0M3QZxBUg7YATJMJpWpHglgbvTfPeqjOja4G+yAL 7sUfWkaunfqowwYH8bdwqR71PErotg4t0qG4+NtiS4HOrErBMVQgB4BAxuyfvNrSC7gs nEC5LloLVWGHsIlbN+k54ejw30FVpl6ifk9+vKnU3pxCtR/uyAdPR+7FsJq/GUwx0pQi p97WkWvj8oZ+0d24oZLumutdeARVu5K6c8WbFehtaovOWxGFFqfS9anYtSbgIiw8z+pr 1141uEybaKg04+1FGmqTS1ONexd1FtDx7IL8Cv51S3njFW5WvuWor262RtkWWI87G6On qKCA== X-Forwarded-Encrypted: i=1; AL+hErEGRuB9VAYHUo7sCCc/DpV8jpV7TzFNFc15n5VsdOV8oIBS/frhdIDjehI/KvMZgsSqY59e+55pUk2O51g=@vger.kernel.org X-Gm-Message-State: AB4q+uH3GnUERy7Xma07eGISDbMSh55xPO4hOnDL1IfPKYx++XQht+NA nI9nm3kOQ0gG9PncsnCoGCMFHQI/vhCjxAVh22giZVgUOXm4esoBoi1L X-Gm-Gg: AZFdTZdBZx+vbRuUBh9cGZrC7QuDVPNYVwusuvRllidLIpGElIGZ8kEHMoqW2CEDpmM r+NpDUE5yA4JFFhzMJcz0dWrSOCuX+4jE0N1VoP08w3J575LTlO7HVskbmhhLs5OLCu6/Hxqze1 q4GWhutOjO5VUDQS+Vdz2cTw2DylVVH2OE+VNQfnDhDrdkjAQ73sTQ6ghn9D8tM+z7uwRB0QU/2 UUuF5jev8EWnkfWPhSLOt5lBhYtEUpplaJcJ8kPcUN2o17XZiiRFQeRPpcOwUN+265srx7qrCgq KMltNu9lqsHCOpE4d2uRGPIcAxuuGcAkn3XSjqWs8EHPKasdmQ8KfifW2CBXncqxQrY/zG7rQoG hYqXAVFgnEuC8pJ0JrKIjTyqabeKeLeEtwSNMppVbjQxf7U4iMCN5yAJjC8RL10v2qUccARsice U3c4Wbjz/XesPha1aMZjJN5vPYrO1fBqytQx+ii4jvKmr0fT5Aq3A/sz4BuBe01r62LKLHoDFui 33aQJdzn21eU65mKFH141d/l+v8Vs823bFfbt0Gz/FLUukdSGEhNvC9IWY6IEt1QPHrCgsBWyjU YYa5PCEmjNCDyg2ehnFkr1FK3U4s2wkx0TQ= X-Received: by 2002:a05:6214:2a49:b0:921:cac9:9bc4 with SMTP id 6a1803df08f44-921d4d927bfmr113284566d6.4.1796413485796; Fri, 04 Dec 2026 11:44:45 -0800 (PST) Received: from [10.0.0.48] ([71.69.222.122]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921e05934e1sm30568096d6.24.2026.12.04.11.44.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 11:44:45 -0800 (PST) Message-ID: <34853fe3-1c08-4d05-967b-cb43275532a4@gmail.com> Date: Fri, 4 Dec 2026 14:44:44 -0500 X-Mailing-List: linux-kernel@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 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: Martin Belanger In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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