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=v8aLG0KE1eHopcsYOJmIybGt8rgrAWlZI1CwBS+K/L30tXamSqzJLWJRkhpYoZZJ1KjC 91vQdSTTAtmLVH4qZLpYTaSzfIhFU/oJgTRX8SQENdZABSOZUmW2KYsnhgDoMU8YXoff5 ome/98esOor1ay2EAE3Wxl06TAepAR5E9OJXGzBU2nG1GbugKpnqTuPkcgXJvixeM51n7 Om3yapbI7ZES5Q2EfBeVkTUg191Xelo3r8gTDjJKLnu+SyxrKPQweOQUoGq2sKdVi2ooz K0xx4gynG0cJApExRbOkx22oKwECZj/KNVm0k34h8h14WmArThehPvkdUu4rVuowmJw== 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=Amlo5dSgMJ6PLe6FfCkYJpEFx8EjN13/DzLJetzN5HUAWN0k+oLrf1RkrigWLQgJUVjr gPOSPuKmCleKHmbLq/nMExcpZnhM8Gy/65+UR5Gi4HoEhHwGIdfTudU7Ig/QwW1PD9jf+ kBva9i3825phXbpJkGmKoD7eAm/zD9qWBpiu6MDR89Ycpf0W/spCZlzNT5xMSh0zNE/ZW cavwTj0asbMg0D7PMlB3XTTWRFo0HClzcbzxVGJycb5lUEZ9xCEMLIum42W450bwzp3Vc RK2aluQ7W6ckSkvMq8gt6+bTiqyBsIhTSmwrV3KYSSzlidBySwz7y9hdArXPY9XhF1w== 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 C7632606A32C for ; Fri, 4 Dec 2026 19:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7632606A32C 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-91c847584b8so15156506d6.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=UX5B960g0Y8DKDFlf7wm6nGJfbYMQ9bX1Bs0RGV1x0WSDXShIFkN+10fyDNlLC6aHi 9G9xlSKANjWTb/Kj0oRHrG+jAD6OpCe/UE5rNpLIvEHrm1CiaCWVdQZvMWIfb+whXBvd 07psuesAcGA1PtIPxtkln9UvBuzdyBoK43l/g6qZrW7KGAHXm+kiW/kcx2KBMZJaArFb ZmxY7jBUs0oPs72XJrqx0V1dLRj1NjCLXxXZkW2Gi7vmArCNVHmLK3qdkY6aR8axARl5 LH/4IDECl1Y9csxZtE5Pz48YkQnfZAv2DNjeORbdYO0SbY6C62kfN7FVCLE4Vw23u724 m5ow== X-Forwarded-Encrypted: i=1; AL+hErFFhebTAIgII2tWheOR6N+QHdJN61CzmVSvf3lWWXBwzmgf4qON2il69xEpFyuUbr6Bn/486yY=@vger.kernel.org X-Gm-Message-State: AB4q+uHAgvniiKPnLOhAApPkd4wJCGWiCqbHvqDlSvlk4sHP2m28+6iR 7DK6xsrZ4lCIkEV0OgEFV1GICPBU43sVZZ5JxCscoM+Lc+wo1eaOyNRu X-Gm-Gg: AZFdTZfgFkFP+BrvdeOK5aYcYps86hxGf3o1u3L2n3lKy5ffBkhjkABK4T+hP8jQrCH KOjTULDDNYcDuIgc0XxxWwplFsroY/4AS7HoOZFG6Y5vedlP2DEQeV3QhVB57Y/jbtU0dV+tmgj oTQWN1CKJs2lLTeKw5ln4LxiK1egEc8R5hEZ0kqoejdgsoV5tNAIP4WThWB96w/qDqfRePIUQ6D 69Vzbfk/lyLQCOEAeTKcuoyqqyvkCVLubxTAVZtlyN9+OPiC05RMCHiah3LYmSKSkheMwekko9W IO/FycRGoaCsJece8uukMJGRMTkAfZz+9KDIR0Ls98R7WimgOvGRMjpQJJMmm28aQbIJviBEI9h mnmSh8eos261TcBilppApMqDz9D3MSQN/AmpskQUBxLXR+7Ahmk6Gg1YwpPaxhWjbYC0FxF9Mpz g4WtXwBedUOVerH9e/xFRQ8g6kBPkkKERlDv8jcT2VB/3CzZY/79DLdXlZ5iWh8xPSmvm8uuNff txY1SxyIqD477nPIzn7x4aSkMtwfIzOZsri/TIJN1SIbUqqYcV7hOALx2ll28elYC5pxDMqRtHQ gL2OtsWdWnwt8xBTQws+aPoHO4Lm5Tx2W1A= 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: netdev@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