public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: lucien.xin@gmail.com
Cc: Simon Horman <horms@kernel.org>,
	steved@redhat.com, marcelo.leitner@gmail.com,
	aahringo@redhat.com, alibuda@linux.alibaba.com,
	jbaron@akamai.com, hare@suse.de, kuba@kernel.org, tom@talpey.com,
	linux-cifs@vger.kernel.org, daniel@haxx.se, quic@lists.linux.dev,
	jlayton@kernel.org, tfanelli@redhat.com, dhowells@redhat.com,
	linkinjeon@kernel.org, hepengtao@xiaomi.com, pc@manguebit.com,
	kernel-tls-handshake@lists.linux.dev, illiliti@protonmail.com,
	xiyou.wangcong@gmail.com, andrew.gospodarek@broadcom.com,
	mail@johnericson.me, edumazet@google.com, pabeni@redhat.com,
	matttbe@kernel.org, netdev@vger.kernel.org, smfrench@gmail.com,
	metze@samba.org, mbuhl@openbsd.org, chuck.lever@oracle.com,
	dreibh@simula.no, davem@davemloft.net, sd@queasysnail.net
Subject: Re: [net-next,v9,02/15] net: build socket infrastructure for QUIC protocol
Date: Thu,  5 Feb 2026 11:54:23 +0000	[thread overview]
Message-ID: <20260205115423.2195277-1-horms@kernel.org> (raw)
In-Reply-To: <28a1e36188b1a84193ef2d78f12ecbc0e43ae7f1.1770042461.git.lucien.xin@gmail.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: build socket infrastructure for QUIC protocol

This patch lays the groundwork for QUIC socket support in the kernel.
It defines the core structures and protocol hooks needed to create
QUIC sockets, without implementing any protocol behavior at this stage.
Basic integration is included to allow building the module via
CONFIG_IP_QUIC=m. This provides the scaffolding necessary for adding
actual QUIC socket behavior in follow-up patches.

> diff --git a/net/quic/protocol.c b/net/quic/protocol.c
> new file mode 100644
> index 000000000000..6ab81f1c50cc
> --- /dev/null
> +++ b/net/quic/protocol.c

[ ... ]

> @@ -0,0 +1,369 @@

[ ... ]

> +static int quic_protosw_init(void)
> +{
> +	int err;
> +
> +	err = proto_register(&quic_prot, 1);
> +	if (err)
> +		return err;
> +
> +	err = proto_register(&quicv6_prot, 1);
> +	if (err) {
> +		proto_unregister(&quic_prot);
> +		return err;
> +	}
> +
> +	inet_register_protosw(&quic_stream_protosw);
> +	inet_register_protosw(&quic_dgram_protosw);
> +	inet6_register_protosw(&quicv6_stream_protosw);
> +	inet6_register_protosw(&quicv6_dgram_protosw);
> +
> +	return 0;
> +}

Can the return values from inet6_register_protosw() be checked?

Looking at the implementation, inet6_register_protosw() returns int and
can fail with -EINVAL (if p->type >= SOCK_MAX) or -EPERM (if trying to
override a permanent protocol). The calls at lines 234-235 don't check
these return values, so if registration fails, quic_protosw_init() still
returns 0 (success).

More critically, quic_protosw_exit() unconditionally calls
inet6_unregister_protosw() on both structures:

static void quic_protosw_exit(void)
{
	inet_unregister_protosw(&quic_dgram_protosw);
	inet_unregister_protosw(&quic_stream_protosw);
	proto_unregister(&quic_prot);

	inet6_unregister_protosw(&quicv6_dgram_protosw);
	inet6_unregister_protosw(&quicv6_stream_protosw);
	proto_unregister(&quicv6_prot);
}

If a protosw was never successfully registered, its list field remains
zero-initialized (NULL pointers). inet6_unregister_protosw() calls
list_del_rcu(&p->list), which with NULL pointers will dereference NULL
in __list_del_entry() -> __list_del(NULL, NULL), causing a kernel crash.

Note that inet_register_protosw() returns void (cannot fail from caller's
perspective), but inet6_register_protosw() returns int (can fail). The
code correctly checks errors from proto_register() but not from
inet6_register_protosw().

Should the return values from inet6_register_protosw() be checked, and
should the cleanup path track which registrations succeeded so only those
are unregistered?

  reply	other threads:[~2026-02-05 11:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02 14:27 [PATCH net-next v9 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 01/15] net: define IPPROTO_QUIC and SOL_QUIC constants Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 02/15] net: build socket infrastructure for QUIC protocol Xin Long
2026-02-05 11:54   ` Simon Horman [this message]
2026-02-05 12:48     ` [net-next,v9,02/15] " Paolo Abeni
2026-02-05 19:03       ` Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 03/15] quic: provide common utilities and data structures Xin Long
2026-02-05 11:54   ` [net-next,v9,03/15] " Simon Horman
2026-02-05 12:51     ` Paolo Abeni
2026-02-05 19:18       ` Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 04/15] quic: provide family ops for address and protocol Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 05/15] quic: provide quic.h header files for kernel and userspace Xin Long
2026-02-05 11:55   ` [net-next,v9,05/15] " Simon Horman
2026-02-05 19:37     ` Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 06/15] quic: add stream management Xin Long
2026-02-05 11:55   ` [net-next,v9,06/15] " Simon Horman
2026-02-05 18:56     ` Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 07/15] quic: add connection id management Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 08/15] quic: add path management Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 09/15] quic: add congestion control Xin Long
2026-02-05 11:55   ` [net-next,v9,09/15] " Simon Horman
2026-02-05 19:00     ` Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 10/15] quic: add packet number space Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 11/15] quic: add crypto key derivation and installation Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 12/15] quic: add crypto packet encryption and decryption Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 13/15] quic: add timer management Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 14/15] quic: add packet builder base Xin Long
2026-02-02 14:27 ` [PATCH net-next v9 15/15] quic: add packet parser base Xin Long
2026-02-05 11:55   ` [net-next,v9,15/15] " Simon Horman
2026-02-05 19:02     ` 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=20260205115423.2195277-1-horms@kernel.org \
    --to=horms@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=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=metze@samba.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pc@manguebit.com \
    --cc=quic@lists.linux.dev \
    --cc=sd@queasysnail.net \
    --cc=smfrench@gmail.com \
    --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