From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.66 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796413487; b=Qoz8wDZuO+enM+FT4JG4GfSb0eLAMzWwtD9AsSdu/lYouozr2xFu9N+maPInBGuiq39H 6ClQSzV5GLbUIuW0CoI4epn2RoeN7yUiHJ3SRCowj9kYazKKKMSltawAqGk9aI1wSEky/ hjKcb9r5saeJ0OEQj+pemYfGZDL43wWKlITRJ450QIzr/XH1IvB8eJywa33QUvj48+/E9 U/oob37+HoMkOBUyN72XdNeOSfjtmY998rJdkcpeDRHlOw+J79o2B9Z0iX4PUJVhWFcRq BjJXBkn34GYXx4qtwo9M3/vzL8RI1pI/R/+vY4L+lMTG4Ix9cNuUxMmo6pEDltpHspg== 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=SUj9Y8j4j90Gtd84xVa7qDn8Il0F3+/L14e8B7uZsLPX9WyXikrP70jroTfbjCmE6z3+ 8u07aZ6LyU7dyFxzVjMVCupguFEz53UmGF/D4oUA1ff+kFTqPhfPlZ+vSMtaPlS7myeYL mXoyAcIdfPdGrm4IqC56ZbYrY8beycY3hNpHxlalcXE/8+1MGx5OXMXD4zGyKbAjnRwbb QjsTgE7IV4VVlRbLv7a2FeAiyvtowEfUv+Fo2HuRGnCZBfkcyi3CWcnnWNpNEl+ZbsPtR bAEtpP8bxT4X2YLM1qa3GWG8TdbFdNJilgn93AATIxf1bpJTyxgua9p9ppZCaucy3kw== 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.66 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) (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 C7500606A322 for ; Fri, 4 Dec 2026 19:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7500606A322 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-f66.google.com with SMTP id 6a1803df08f44-92106d5371dso15824086d6.1 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=QXPHOZ5a7QFbcISa6GRC6HYldOZwEelXZMR6Zd7DSFiwTDyCczWI5IornHzNIXpYKb uhP1uM9GPY1giw2XLSWQHxd6PzDMwlWOPB7GjqbIA4tWz54wkk2rqfqXvQ+1aAqL6XE+ zIYUkfe0mMWsdxLlhg/oTbSnAxKjrttPr/eZjXHJQTmSgHRKYzgA16Be6GNMxMLhCyAk lOLWkww4Eb2YJSfzVDP+xXS6qkgUj4HCywlvfQe0f5KulcxNaRdeSNVp1dhSqIdBFpNR IcLwv3lu95k3f9QYuyR0RV/woUDVgmWvHCrxBi2TorZR1iKs7AovEvZaP3/tS5PeypL8 1SPQ== X-Forwarded-Encrypted: i=1; AL+hErGVOx/gGGZoOFPxqUxPhDntEuRDozxAfclCoH0p1rxM+4Tg0al4/iW1DjNM2vrZSsm7DpidLOxr39Y=@vger.kernel.org X-Gm-Message-State: AB4q+uFO18MhUSUCaC4mfEgLLVbTBHw4CDfOch8YIefVXRubB0R6/xLl Iw/eZn7YUYZXBvfVucG2vr8k0y3jCr/rKD/rjH6RS9FJQ2LzgGpHIL2a X-Gm-Gg: AZFdTZeVULYswvSI4XS0bTd1JGzCqzuBA3eFIx5qEna8ei6uHIqYC8vJzhvUlKaDqR3 f+I6ba9KHTts81B1Ltkw8FFBato1LIUBFOZ8+0sUB9n0hGh2Y7wEgExtU4DoUkuSvGh7KDoiTle ZC+0CM6XF1FlJ6yCXDRgac8Z2+yxCyxGKq0VnOXfM/PWPqLBECUOjQd4cTOONkRPCpzdk9XLqwd QrkSSrHxtT2GiiD0s2vpMSfWQFqwd0e5DkbXHCcZ3MwOd+sBT8Pl5G6ga2VeYx0Mo2/mnquA2th CBF21szZjnBM79gACJAdoBVkM/QqHcQQN0MuzYkw4SQPhqWOrjT8QcyHgPPzQC0CgikGMfPZNTZ iueqUbw0opgumPEpn9uxb/1QUGHoetjyWeUDg3dmMPU0vTXB5QpZartm5WolIUYSjsOTSA9OQ6L XL9pmICrWrLRZizPIgCLiGyTIEKlqBHj0gEUi0yc+Jyw0945MHrWFj4a6IfKw3Ciq0dSL073Z7u XI3oP/jOljTFKM07cX8LzLRHX6ZjA04pF55Hkw8dZBlp6TcIDkQ+NTA1F4EbuBsPkYy6VphKIJf SsoqYT9WwjWqx+un0nXJyX3REb2KGWQMZzw= 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-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 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