Article View: linux.kernel.netdev
Article #14255Re: [PATCH net-next v18 11/15] quic: add crypto key derivation and installation
From: netdev-bot+sashiko
Date: Tue, 10 Nov 2026 22:29
Date: Tue, 10 Nov 2026 22:29
159 lines
14102 bytes
14102 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] quic_crypto_set_cipher() (net/quic/crypto.c:272) stores seven
freshly allocated transforms (secret_tfm, rx_tfm[0..1], rx_hp_tfm,…
- [Low] The commit message that stays in git history leaves out the
socket lifecycle changes in net/quic/socket.c.
- [Low] quic_crypto_set_cipher() allocates the header-protection
transforms with crypto_alloc_sync_skcipher(), which returns struct…
--
quic: add crypto key derivation and installation
This patch adds net/quic/crypto.c. It provides HKDF helpers, cipher
transform allocation, traffic secret installation, key update and
stateless reset token derivation for QUIC. It also allocates one
struct quic_crypto per encryption level in quic_init_sock(), and a new
sk_destruct callback defers freeing those contexts to quic_wq.
> quic: add crypto key derivation and installation
>
> This patch introduces 'quic_crypto', a component responsible for QUIC
> encryption key derivation and installation across the various key
> levels: Initial, Handshake, 0-RTT (Early), and 1-RTT (Application).
[ ... ]
> - quic_crypto_derive_secret(): Generate token for stateless reset or
> master key for session resumption.
>
> These mechanisms are essential for establishing and maintaining secure
> communication throughout the QUIC connection lifecycle.
[Severity: Low]
The commit message describes this patch only as adding crypto helpers.
Could it also mention the socket lifecycle changes in net/quic/socket.c?
The patch also does the following:
- installs a new quic_sock_destruct() as sk->sk_destruct in
quic_init_sock()
- allocates QUIC_CRYPTO_MAX struct quic_crypto contexts per socket
with kzalloc_obj()
- defers transform teardown to quic_crypto_free_work() on quic_wq,
which runs after the socket has been destroyed
The function list also leaves out the new exported helper
quic_crypto_set_token_secret().
These details appear only in the v18 notes below the --- line, and
git am drops that text.
> diff --git a/net/quic/crypto.c b/net/quic/crypto.c
> new file mode 100644
> index 0000000000000..c4bf99b3e8239
> --- /dev/null
> +++ b/net/quic/crypto.c
[ ... ]
> +int quic_crypto_set_cipher(struct quic_crypto *crypto, u32 type)
> +{
> + const struct quic_cipher *cipher;
> + void *tfm;
> + int err;
> +
> + if (type < QUIC_CIPHER_MIN || type > QUIC_CIPHER_MAX)
> + return -EINVAL;
> +
> + cipher = &ciphers[type - QUIC_CIPHER_MIN];
> + tfm = crypto_alloc_shash(cipher->shash, 0, 0);
> + if (IS_ERR(tfm))
> + return PTR_ERR(tfm);
> + crypto->secret_tfm = tfm;
[ ... ]
> + tfm = crypto_alloc_sync_skcipher(cipher->skc, 0, 0);
> + if (IS_ERR(tfm)) {
> + err = PTR_ERR(tfm);
> + goto err;
> + }
> + crypto->rx_hp_tfm = tfm;
[Severity: Low]
Are the types for the header protection transforms consistent here?
crypto_alloc_sync_skcipher() returns a struct crypto_sync_skcipher *.
The result passes through the void *tfm local into rx_hp_tfm, and
tx_hp_tfm is handled the same way. Both fields are declared as struct
crypto_skcipher * in net/quic/crypto.h.
quic_crypto_free() then releases them with crypto_free_skcipher()
instead of crypto_free_sync_skcipher():
if (crypto->rx_hp_tfm)
crypto_free_skcipher(crypto->rx_hp_tfm);
if (crypto->tx_hp_tfm)
crypto_free_skcipher(crypto->tx_hp_tfm);
This works today only because struct crypto_sync_skcipher wraps a
struct crypto_skcipher base at offset 0. Because tfm is a void *, the
compiler cannot catch the mismatch. The mismatch is still present at
the end of the series, where quic_crypto_header_protect() uses these
fields as struct crypto_skcipher *.
Should the fields be declared as struct crypto_sync_skcipher * and
freed with crypto_free_sync_skcipher()?
[ ... ]
> + crypto->tx_hp_tfm = tfm;
> +
> + crypto->cipher = cipher;
> + crypto->cipher_type = type;
> + return 0;
> +err:
> + quic_crypto_free(crypto);
> + return err;
> +}
[Severity: Medium]
Can this error path destroy state that this call did not create?
quic_crypto_set_cipher() stores seven newly allocated transforms
without checking whether the context already holds any. On failure it
calls quic_crypto_free() on the whole context. That frees every
transform and then zeroes the structure up to send_offset:
memzero_explicit(crypto, offsetof(struct quic_crypto, send_offset));
If this ran on a context that was already set up, the old transforms
would leak. If that second call then failed, it would also wipe the
live keys, the token secret in tx_secret[1], and the cipher,
send_ready and recv_ready state.
In this series the only caller is quic_crypto_set_secret(). It calls
quic_crypto_set_cipher() only when crypto->cipher is NULL, so this
path does not appear to be reachable yet.
The notes say later patches call quic_crypto_set_cipher() directly from
quic_inet_listen(), quic_connect() and quic_accept(). Those patches are
not part of this series.
Would it be safer to reject a context that already has transforms, and
to unwind only the allocations made by this call?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794241654.git.lucien.xin%40gmail.com
Technical Details
Message-ID:
<179434978792.994134.17759133431780284123@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360695-linux-kernel-netdev=dewy.ruReferences:
<b269e7436d8e9b5816a8e716d661767a2e43c27b.1794241656.git.lucien.xin@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360695-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v18 11/15] quic: add crypto key derivation and installation Date: Tue, 10 Nov 2026 22:29:47 +0000 Organization: Usenet Network Message-ID: <179434978792.994134.17759133431780284123@kernel.org> References: <b269e7436d8e9b5816a8e716d661767a2e43c27b.1794241656.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="718546"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2x2WXACV0IiiUatMukSzG8mUZ/E= sha256:oTuJlVZNUN+QPKacIba5FAzy0QZXvLXLqRvDFioojzY= sha1:JiFaHWRswmqfRjIOgsb8SzA/LsQ= sha256:b9B2OzYW+8O9wVhrk/N9odWM4LforaI50oke6t0bxCw= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CEE5C113D82; Wed, 11 Nov 2026 01:30:47 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k-OdHCfwGJ2l; Wed, 11 Nov 2026 01:30:42 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360695-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4997E113D80; Wed, 11 Nov 2026 01:30:33 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id E8D2031046; Tue, 10 Nov 2026 22:29:54 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794349792; b=4q7xAP9TRDqNmWk7pruj/gtt3YB8uia79FWcZ4bhSqrPiw3tUaZwBphOu6Y8LkHvJS7D 9Ix7wWaoGGF5fRTdQB+dDmzPU1ryImdmTCFBikeKZkNHhY6zEum0v4P3G3GvwNl8IHRA0 19OL+JCe+ciRfwxq+A+LbRibBkA0CAcQd6UM6QS3knUkjXVMPOE6Dq/89XoM1zL+I8zOO FHtXWYaDZJ2v4hGWNlTpHQiFQnQCvet3q7hkMEQTh/jn5TxKS1hkNt57p6ePi6UHyWsML YoxuT3spGz8JDZEm4uZUY75zwMzMeY//IpAB8KsOoo1nAo6ax/NJJ8vKQYZgI8Nz9Sw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794349792; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=A7tASFXnNuPE+e+nS1b06UWislcan1F6/IvDUWRJ6dY=; b=fDvTjlBM5FeVdrWo41JsI4JdZjEcyUTedtjLMDLLMCDvdmgsZa8Q4NMzPMroF8XyPhzM sRjBFavfmik+00uew5XYEeJOkxjUT471JXpzSbcHWJ3zc/aWTnAD46P1d2J0sBidY8IQl v5k1SPDTD9q+zjgWLEpFpywonZc47ZjzWp/Zgoo+QVvs5hu4DebaDceoFI85drEDrsvj2 Z3+RrePUQO9ij4aW7Y6YLdc3bi9zVhOnyY16k1TzeRXmSmtXT3rjWjg3RFBP3Y7QPUF1+ GormgVbMlozF9NpbJjnRykxQczLOh7tjLI6LtE7SNu/MH9DWqRyZNrazB+f1Bz27Huw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XYAFMpwx; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13007606A33D; Tue, 10 Nov 2026 22:29:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XYAFMpwx X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794349791; b=RN8x1sojbjwEwqo9R11T+gN/piFkrcmXZLtIGL284YNXuhPObkXZcN2Sy9AHRtM6WY17 CcqZQM3j8FLWQkAc92ydNqLW7I1okCLAG3AIf799daAF15QhScL1kdWpNaC9o/ZlFsyQv YpTUfsupFh4h+eCMlnASrj5lBNC/jK1fx60lItjOjRgI1PCu9wz+9iVBoC7D4VVlQ1lRU e0o0nJ1Mx17/WxEAieJBMVnvkzwNue/i8qBZOrhNLBPgXmAlBOElqUtAExLi9/3XqKn5F AzYWvyirmOuRjADHea4Jq86C2dpABR3RzKXXlmp8JssVtdhKIxu2NTgspw9m6Mg3DoA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794349791; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=A7tASFXnNuPE+e+nS1b06UWislcan1F6/IvDUWRJ6dY=; b=yNL66GEQaEO0EBwlLoL562gKsLnCA+sCfY1witHKsWdL9UQowA5VOHpE+r9KiRTQZW2w SSYm8qYcw4o29hvRXYk2UaGxLOdadw/59ObxWLyudptE0sk39No/R1++c8+zokW/1uU1f 2MnzL7r5GwaLpoSWzpqH+53A9Z+zlK9tkiqudUFEaVzL5/irseWn+FhVLcf9oS+Ya15Ct s179dVage5IJHOTNtcFO4mnF4Ozd8nYVOdjnyrdGrryiBOkKVKSLHxo4bc6jjIQ5WM2g9 jyQIE8z/Yq0ErgxuSnQXpKfXt5Nx0WFyJJJwdn9cDiZyWMj9Kz2gw4+0zKgCGS2ViKw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XYAFMpwx; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27D0606A325; Tue, 10 Nov 2026 22:29:50 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 614441F008A2; Tue, 10 Nov 2026 22:29:48 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794349790; bh=A7tASFXnNuPE+e+nS1b06UWislcan1F6/IvDUWRJ6dY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=XYAFMpwxw45Mkdk/2AXix7iUkAY1Rlyq/LaeRmxo2ZjGrowkCLXk3KEBUGulsXekV bmSSzJ4an125Gqm1gKtJKoVoFIJQrnUePTefr1iaTldCLN2lh64LouTcFPx24kMBAE S2W8xZ9s80qGLkMUUtJDErfiYwzS69M5K6XHgzLVO02mo/2yn5Y+WhJ+16pHFQGX6O 91bwg4+RziJEIUvoSY94FuYsGBzc5MldYAnZgu637Rox3jGNzVoigXhy/9rjpMc3cL OCYOWyCNOyvW5qqTnydp31qSrF9e/F6zdArpmqUxoGP8HT9MCPDN/AQeXirofAoqmX O2orAmc+iok1g== X-Cc: netdev@vger.kernel.org, quic@lists.linux.dev, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, horms@kernel.org, metze@samba.org, mbuhl@openbsd.org, tfanelli@redhat.com, hepengtao@xiaomi.com, dreibh@simula.no, linux-cifs@vger.kernel.org, pc@manguebit.org, linkinjeon@kernel.org, tom@talpey.com, kernel-tls-handshake@lists.linux.dev, cel@kernel.org, jlayton@kernel.org, steved@redhat.com, hare@suse.de, aahringo@redhat.com, dhowells@redhat.com, matttbe@kernel.org, mail@johnericson.me, xiyou.wangcong@gmail.com, alibuda@linux.alibaba.com, jbaron@akamai.com, illiliti@protonmail.com, sd@queasysnail.net, marcelo.leitner@gmail.com, daniel@haxx.se, andrew.gospodarek@broadcom.com, mef@scarletmail.rutgers.edu, paul@jakma.org, kuniyu@google.com X-In-Reply-To: <b269e7436d8e9b5816a8e716d661767a2e43c27b.1794241656.git.lucien.xin@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list