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 v17 11/15] quic: add crypto key derivation and installation
Date: Mon, 19 Oct 2026 21:30:04 +0000	[thread overview]
Message-ID: <179244540463.3135.17132817693152829356@kernel.org> (raw)
In-Reply-To: <1da72318e969eb252977ccf5d8e3e506c2fa2e69.1792164438.git.lucien.xin@gmail.com>

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

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

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).

- [High] quic_init_sock() (net/quic/socket.c:58) sets sk->sk_destruct =
  quic_sock_destruct.

--

quic: add crypto key derivation and installation

This patch adds quic_crypto, which derives and installs QUIC packet
protection keys for the Initial, Handshake, 0-RTT and 1-RTT levels. It
handles key updates and stateless reset token generation. It also adds a
quic_sock_destruct() callback that frees the per-level crypto transforms
when the last socket reference goes away.

> diff --git a/net/quic/socket.c b/net/quic/socket.c
> index 12f0817c8b55f..9b1106a9f5e73 100644
> --- a/net/quic/socket.c
> +++ b/net/quic/socket.c
> @@ -40,10 +40,22 @@ static void quic_write_space(struct sock *sk)
>  	rcu_read_unlock();
>  }
>  
> +static void quic_sock_destruct(struct sock *sk)
> +{
> +	u8 i;
> +
> +	/* Deferred crypto free for async encryption/decryption. */
> +	for (i = 0; i < QUIC_CRYPTO_MAX; i++)
> +		quic_crypto_free(quic_crypto(sk, i));

[Severity: High]
Is it safe to free the crypto transforms from sk_destruct, given the
context it can run in?

sk_destruct runs in whatever context drops the last socket reference.
Later in this series, several of those contexts are softirq:

  quic_packet_rcv() (UDP encap receive) ends with sock_put(sk)
  quic_timer_timeout() ends with sock_put(sk)
  quic_packet_rcv_err() drops its reference with sock_put()
  quic_packet_xmit() takes a reference per TX skb through
    skb_set_owner_sk_safe(); sock_efree() releases it on TX completion,
    usually in NAPI

If the user has already closed the socket, any of these can end up as:

  sock_put()
    __sk_destruct()
      quic_sock_destruct()
        quic_crypto_free()
          crypto_free_aead()
            crypto_destroy_tfm()
              alg->cra_exit()

The AEADs come from crypto_alloc_aead(cipher->aead, 0, 0), so an async
hardware implementation can be selected. hisi_sec2, for example, registers
both "gcm(aes)" and "ccm(aes)". Its sec_aead_exit() calls
dma_free_coherent(). Behind an IOMMU that leads to __iommu_dma_free() and
then vunmap(), which begins with:

mm/vmalloc.c:vunmap() {
	...
	BUG_ON(in_interrupt());
	...
}

Can this hit that BUG when a QUIC socket is destroyed from softirq?
Listen sockets already hold AEAD transforms in this series, via
quic_packet_get_alpn()->quic_crypto_initial_keys_install().

macsec hit the same crash and fixed it in commit 6624bba469a3 ("macsec:
use rcu_work to defer RX SA crypto cleanup out of softirq").

The note about in-flight async requests holding a socket reference covers
the lifetime of the transforms. It does not cover the context in which
the free runs.

Would it work to defer the tfm teardown to process context, for example
with a work item or rcu_work queued from quic_sock_destruct()?

> +
> +	quic_sk_destruct(sk);
> +}
> +
>  static int quic_init_sock(struct sock *sk)
>  {
>  	u8 i;
>  
> +	sk->sk_destruct = quic_sock_destruct;
>  	sk->sk_write_space = quic_write_space;
>  	sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);

[ ... ]

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

             reply	other threads:[~2026-10-19 21:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 21:30 netdev-bot+sashiko [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-10-16 15:27 [PATCH net-next v17 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-10-16 15:27 ` [PATCH net-next v17 11/15] quic: add crypto key derivation and installation 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=179244540463.3135.17132817693152829356@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