Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: lucien.xin@gmail.com
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, chuck.lever@oracle.com,
	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
Subject: Re: [PATCH net-next v15 11/15] quic: add crypto key derivation and installation
Date: Tue, 15 Sep 2026 19:50:51 +0000	[thread overview]
Message-ID: <178950185147.22033.10922498784930147476@kernel.org> (raw)
In-Reply-To: <f886c618bd560e42692c0ac3296bae4878755cc1.1789393775.git.lucien.xin@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider:

Critical: 0 · High: 0 · Medium: 1 · Low: 1

- [Medium] net/quic/Kconfig selects CRYPTO_HMAC but not a concrete digest
  implementation, while every entry of the new ciphers[] table in…
- [Low] quic_crypto_set_secret() consumes the uAPI struct
  quic_crypto_secret but never reads `level` or `reserved`, and honours…

--

quic: add crypto key derivation and installation

This adds net/quic/crypto.c with the QUIC key schedule: HKDF-Extract and
HKDF-Expand-Label helpers, Initial secret derivation, traffic secret
installation, key update, and stateless reset token derivation.  The new
struct quic_crypto is embedded per encryption level in struct quic_sock and
freed from the new quic_sock_destruct().

> diff --git a/net/quic/crypto.c b/net/quic/crypto.c
> new file mode 100644
> index 0000000000000..910557b680524
> --- /dev/null
> +++ b/net/quic/crypto.c
> @@ -0,0 +1,567 @@

[ ... ]

> +static const struct quic_cipher
> +ciphers[QUIC_CIPHER_MAX + 1 - QUIC_CIPHER_MIN] = {
> +	CIPHER_DESC(TLS_CIPHER_AES_GCM_128,
> +		    "gcm(aes)", "ecb(aes)", "hmac(sha256)"),
> +	CIPHER_DESC(TLS_CIPHER_AES_GCM_256,
> +		    "gcm(aes)", "ecb(aes)", "hmac(sha384)"),
> +	CIPHER_DESC(TLS_CIPHER_AES_CCM_128,
> +		    "ccm(aes)", "ecb(aes)", "hmac(sha256)"),
> +	CIPHER_DESC(TLS_CIPHER_CHACHA20_POLY1305,
> +		    "rfc7539(chacha20,poly1305)", "chacha20", "hmac(sha256)"),
> +};
> +
> +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;

[Severity: Medium]

Every entry of ciphers[] requests either hmac(sha256) or hmac(sha384), but
net/quic/Kconfig does not select a digest implementation:

	select CRYPTO
	select CRYPTO_HMAC
	select CRYPTO_AES
	select CRYPTO_GCM
	select CRYPTO_CCM
	select CRYPTO_CHACHA20POLY1305
	select NET_UDP_TUNNEL

CRYPTO_HMAC is only the template (it selects CRYPTO_HASH and
CRYPTO_MANAGER), while CRYPTO_SHA256 and CRYPTO_SHA512 are independent
tristates without default y.

With IP_QUIC=y/m and CRYPTO_SHA256=n, does crypto_alloc_shash(cipher->shash,
0, 0) in quic_crypto_set_cipher() fail with -ENOENT, so that
quic_crypto_set_secret() and quic_crypto_initial_keys_install() can never
install keys and no connection can be established?

Should IP_QUIC also select CRYPTO_SHA256 and CRYPTO_SHA512 (the latter for
the hmac(sha384) entry)?

[ ... ]

> +int quic_crypto_set_secret(struct quic_crypto *crypto,
> +			   struct quic_crypto_secret *srt, u32 version)
> +{
> +	const struct quic_cipher *cipher;
> +	u8 phase = crypto->key_phase;
> +	int err;
> +
> +	/* If no cipher has been initialized yet, set it up. */
> +	if (!crypto->cipher) {
> +		err = quic_crypto_set_cipher(crypto, srt->type);
> +		if (err)
> +			return err;
> +	}
> +	cipher = crypto->cipher;

[Severity: Low]

This isn't a bug in the current series, since quic_do_setsockopt() still
returns -EOPNOTSUPP and the only in-tree producer,
quic_crypto_initial_keys_install(), sets srt.type = TLS_CIPHER_AES_GCM_128 on
both calls.

Still, srt->type is only consulted while crypto->cipher is NULL, and
srt->level and srt->reserved are never read at all.  Once the setsockopt path
is wired up, would a second call carrying a different TLS_CIPHER_* value be
silently served with the already installed cipher, copying cipher->secretlen
bytes out of the caller's secret buffer instead of returning -EINVAL?

Would it make sense to reject srt->type disagreeing with crypto->cipher_type
here?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1789393775.git.lucien.xin%40gmail.com

         reply	other threads:[~2026-09-15 19:50 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 13:49 [PATCH net-next v15 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 01/15] net: define IPPROTO_QUIC and SOL_QUIC constants Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 02/15] net: build socket infrastructure for QUIC protocol Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 03/15] quic: provide common utilities and data structures Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 15:18     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 04/15] quic: provide family ops for address and protocol Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 05/15] quic: provide quic.h header files for kernel and userspace Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 06/15] quic: add stream management Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 15:21     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 07/15] quic: add connection id management Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 08/15] quic: add path management Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 15:43     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 09/15] quic: add congestion control Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 15:48     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 10/15] quic: add packet number space Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 11/15] quic: add crypto key derivation and installation Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko [this message]
2026-09-16 15:51     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 12/15] quic: add crypto packet encryption and decryption Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 16:01     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 13/15] quic: add timer management Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 14/15] quic: add packet builder base Xin Long
2026-09-15 19:50   ` netdev-bot+sashiko
2026-09-16 16:20     ` Xin Long
2026-09-14 13:49 ` [PATCH net-next v15 15/15] quic: add packet parser base Xin Long
2026-09-15 19:51   ` netdev-bot+sashiko
2026-09-15 21:34     ` Xin Long
2026-09-16 18:08     ` Xin Long
2026-09-16 23:46       ` Kuniyuki Iwashima
2026-09-17 13:38         ` Xin Long
2026-09-17 19:06           ` Kuniyuki Iwashima
2026-09-18 19:51             ` Xin Long
2026-09-16 18:33 ` [PATCH net-next v15 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-09-17  8:35   ` Paolo Abeni
2026-09-18 19:59     ` Xin Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178950185147.22033.10922498784930147476@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aahringo@redhat.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=chuck.lever@oracle.com \
    --cc=daniel@haxx.se \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dreibh@simula.no \
    --cc=edumazet@google.com \
    --cc=hare@suse.de \
    --cc=hepengtao@xiaomi.com \
    --cc=horms@kernel.org \
    --cc=illiliti@protonmail.com \
    --cc=jbaron@akamai.com \
    --cc=jlayton@kernel.org \
    --cc=kernel-tls-handshake@lists.linux.dev \
    --cc=kuba@kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=mail@johnericson.me \
    --cc=marcelo.leitner@gmail.com \
    --cc=matttbe@kernel.org \
    --cc=mbuhl@openbsd.org \
    --cc=mef@scarletmail.rutgers.edu \
    --cc=metze@samba.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paul@jakma.org \
    --cc=pc@manguebit.org \
    --cc=quic@lists.linux.dev \
    --cc=sd@queasysnail.net \
    --cc=steved@redhat.com \
    --cc=tfanelli@redhat.com \
    --cc=tom@talpey.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox