Netdev List
 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, kuniyu@google.com
Subject: Re: [PATCH net-next v16 11/15] quic: add crypto key derivation and installation
Date: Wed, 07 Oct 2026 01:05:21 +0000	[thread overview]
Message-ID: <179133512119.434549.18318076229328796602@kernel.org> (raw)
In-Reply-To: <e7412c320cae4da8e01f4f4809f92e570a999593.1791227050.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

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_keys_derive_and_install() (net/quic/crypto.c) sets
  `crypto->rx_fails[phase] = 0` every time it installs RX keys.
- [Low] Two comments in net/quic/crypto.c do not match the code.

--

quic: add crypto key derivation and installation

This patch adds the quic_crypto component. It derives and installs QUIC
packet protection keys for the Initial, Handshake, 0-RTT and 1-RTT
levels. Its helpers cover initial key installation, transform allocation,
traffic secret installation, key updates, and secret derivation for
stateless reset tokens and session resumption, and a new
quic_sock_destruct() frees the crypto state.

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

[ ... ]

> +/* Derive and install reception (RX) or transmission (TX) packet protection
> + * keys for the current key phase.  This installs AEAD protection key, IV, and
> + * optionally header protection key.
> + */

[Severity: Low]
This isn't a bug, but this comment says the keys are installed "for the
current key phase". The function takes an explicit phase argument, and
quic_crypto_key_update() calls it with !phase, which is the next phase.

That is also the case where header protection key derivation is skipped:

	if (crypto->key_phase == phase)
		hp = quic_data(&hp_k, hp_key, keylen);

There is a similar mismatch in quic_crypto_set_cipher(). The comments say:

	/* Allocate AEAD and HP transform for each RX key phase. */
	...
	/* Allocate AEAD and HP transform for each TX key phase. */

But only one HP skcipher is allocated per direction (rx_hp_tfm and
tx_hp_tfm), and both phases share it. Only the AEAD tfms are per phase.

Could these comments be updated to match the code?

> +static int quic_crypto_keys_derive_and_install(struct quic_crypto *crypto,
> +					       bool rx, u8 phase)
> +{

[ ... ]

> +	if (rx) {
> +		crypto->rx_fails[phase] = 0;

[Severity: Medium]
Can resetting rx_fails[phase] here let the connection go past the AEAD
integrity limit?

RFC 9001 section 6.6 says endpoints must count packets that fail
authentication across all keys used in the connection. Once that total
goes over the integrity limit, the endpoint has to close the connection
with AEAD_LIMIT_REACHED.

Here the counter is split by key phase, and every RX key installation
zeroes it, including each key update:

quic_crypto_key_update()
    quic_crypto_keys_derive_and_install(crypto, true, !phase)
        crypto->rx_fails[phase] = 0;

crypto.h also describes rxlimit as "Max failures decrypted per key".

Later in the series, "quic: add crypto packet encryption and decryption"
checks the limit in quic_crypto_decrypt() like this:

	if (++crypto->rx_fails[cb->key_phase] >= crypto->cipher->rxlimit)
		err = -EKEYEXPIRED;

The later patches do not change how the counter works.

An off-path attacker who knows the connection ID could send forged
short-header packets until one phase counter is just below rxlimit. The
next legitimate key update would then reset that counter to zero.

With AES-CCM the limit is 2^21.5. A busy connection also has to update
its keys about every 2^21.5 sent packets, so the attacker's total
forgery budget grows with each key update. Splitting the count by phase
also allows about twice rxlimit per key epoch.

Should rx_fails be one connection-wide counter that key installation does
not reset?

[ ... ]

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

         reply	other threads:[~2026-10-07  1:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 19:03 [PATCH net-next v16 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-10-05 19:03 ` [PATCH net-next v16 01/15] net: define IPPROTO_QUIC and SOL_QUIC constants Xin Long
2026-10-05 19:03 ` [PATCH net-next v16 02/15] net: build socket infrastructure for QUIC protocol Xin Long
2026-10-05 19:03 ` [PATCH net-next v16 03/15] quic: provide common utilities and data structures Xin Long
2026-10-05 19:03 ` [PATCH net-next v16 04/15] quic: provide family ops for address and protocol Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-07 18:41     ` Xin Long
2026-10-09  1:18     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 05/15] quic: provide quic.h header files for kernel and userspace Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 06/15] quic: add stream management Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-09  1:28     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 07/15] quic: add connection id management Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 08/15] quic: add path management Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-07 19:11     ` Xin Long
2026-10-09  1:37     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 09/15] quic: add congestion control Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-09  1:42     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 10/15] quic: add packet number space Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 11/15] quic: add crypto key derivation and installation Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko [this message]
2026-10-09  1:44     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 12/15] quic: add crypto packet encryption and decryption Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-09  1:48     ` Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 13/15] quic: add timer management Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 14/15] quic: add packet builder base Xin Long
2026-10-05 19:04 ` [PATCH net-next v16 15/15] quic: add packet parser base Xin Long
2026-10-07  1:05   ` netdev-bot+sashiko
2026-10-09  1:55     ` Xin Long
2026-10-07 19:19 ` [PATCH net-next v16 00/15] net: introduce QUIC infrastructure and core subcomponents 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=179133512119.434549.18318076229328796602@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=kuniyu@google.com \
    --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