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, 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
Subject: Re: [PATCH net-next v18 08/15] quic: add path management
Date: Tue, 10 Nov 2026 22:29:40 +0000	[thread overview]
Message-ID: <179434978039.994134.3389995581310140385@kernel.org> (raw)
In-Reply-To: <a9a2d4c0a8fc6b0d9e8abe804aac0b25d2459532.1794241656.git.lucien.xin@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · 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).

- [Medium] quic_udp_sock_create() in net/quic/path.c (line 100) always
  takes an active netns reference with get_net_track(net,…

--

quic: add path management

This patch adds struct quic_path_group to manage the active and alternate
QUIC paths. Each path is bound to a UDP tunnel socket, which is wrapped in
a refcounted struct quic_udp_sock and stored in a global hash table. The
patch also adds connection migration helpers and basic PLPMTUD state
handling.

> diff --git a/net/quic/path.c b/net/quic/path.c
> new file mode 100644
> index 0000000000000..e24968376f6b1
> --- /dev/null
> +++ b/net/quic/path.c
> @@ -0,0 +1,596 @@

[ ... ]

> +static void quic_udp_sock_put_work(struct work_struct *work)
> +{

[ ... ]

> +	head = quic_udp_sock_head(sock_net(sk), ntohs(us->addr.v4.sin_port));
> +	mutex_lock(&head->lock);
> +	__hlist_del(&us->node);
> +	mutex_unlock(&head->lock);
> +
> +	put_net_track(sock_net(sk), &us->ns_tracker);
> +	sock_put(sk);
> +	kfree(us);
> +}
> +
> +static struct quic_udp_sock *quic_udp_sock_create(struct sock *sk,
> +						  union quic_addr *a)
> +{

[ ... ]

> +	refcount_set(&us->refcnt, 1);
> +	us->sk = sock->sk;
> +	memcpy(&us->addr, a, sizeof(*a));
> +	us->bind_ifindex = udp_conf.bind_ifindex;
> +	get_net_track(net, &us->ns_tracker, GFP_KERNEL);

[Severity: Medium]
If the QUIC socket doing the bind is a kernel socket, can this active
netns reference keep the namespace alive forever?

quic_udp_sock_create() calls get_net_track() for every quic_udp_sock. The
only matching put_net_track() is in quic_udp_sock_put_work(). That work
runs only after the last path using the tunnel is unbound, which happens
through quic_destroy_sock()->quic_path_unbind() when the QUIC socket is
closed.

Kernel sockets are deliberately kept from holding an active netns
reference. sk_alloc() does:

	sk->sk_net_refcnt = kern ? 0 : 1;
	if (likely(sk->sk_net_refcnt)) {
		get_net_track(net, &sk->ns_tracker, priority);
		sock_inuse_add(net, 1);
	} else {
		net_passive_inc(net);
		...

The UDP tunnel socket created by udp_sock_create() follows that rule, but
the reference held by quic_udp_sock does not.

Consider an in-kernel user that creates a QUIC socket with
sock_create_kern() in a non-init netns. It then closes that socket from
its pernet ->exit handler, which is the usual pattern for netns-scoped
kernel sockets:

  quic_path_bind()->quic_udp_sock_create()
    get_net_track()            /* active netns ref taken */

  netns teardown:
    active netns count never drops to zero
      cleanup_net() and pernet ->exit never run
        kernel QUIC socket is never closed
          quic_udp_sock_put_work() never runs
            put_net_track() never runs

In that case, wouldn't the namespace and everything it owns be leaked?

No in-tree code creates IPPROTO_QUIC kernel sockets yet, either at this
commit or at the end of the series. So this depends on a future
in-kernel user. The code is still the same at the end of the series.

For user sockets, the extra active reference adds nothing while the
socket is alive, because the socket already holds one. Would a passive
reference (net_passive_inc()/net_passive_dec()) be enough to keep struct
net valid for sock_net() and quic_udp_sock_head() in the deferred work?
Another option would be to follow the owning socket's sk_net_refcnt
semantics.

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

  reply	other threads:[~2026-11-10 22:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 16:27 [PATCH net-next v18 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 01/15] net: define IPPROTO_QUIC and SOL_QUIC constants Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 02/15] net: build socket infrastructure for QUIC protocol Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 03/15] quic: provide common utilities and data structures Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 04/15] quic: provide family ops for address and protocol Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 05/15] quic: provide quic.h header files for kernel and userspace Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 06/15] quic: add stream management Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 07/15] quic: add connection id management Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 08/15] quic: add path management Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko [this message]
2026-11-09 16:27 ` [PATCH net-next v18 09/15] quic: add congestion control Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 10/15] quic: add packet number space Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 11/15] quic: add crypto key derivation and installation Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 12/15] quic: add crypto packet encryption and decryption Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-09 16:27 ` [PATCH net-next v18 13/15] quic: add timer management Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 14/15] quic: add packet builder base Xin Long
2026-11-09 16:27 ` [PATCH net-next v18 15/15] quic: add packet parser base Xin Long
2026-11-10 22:29   ` netdev-bot+sashiko
2026-11-10 15:41 ` [PATCH net-next v18 00/15] net: introduce QUIC infrastructure and core subcomponents Jakub Kicinski
2026-11-10 16:57   ` Xin Long
2026-11-10 17:20     ` Jakub Kicinski

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=179434978039.994134.3389995581310140385@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aahringo@redhat.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=cel@kernel.org \
    --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