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 07/15] quic: add connection id management
Date: Tue, 15 Sep 2026 19:50:41 +0000 [thread overview]
Message-ID: <178950184154.22033.11596322184319753011@kernel.org> (raw)
In-Reply-To: <03da9d52c2e42c4e06c47dafd8437c38c2ee1d41.1789393775.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: 0 · Low: 1
- [Low] quic_conn_id_lookup() (net/quic/connid.c) takes a hard socket
reference via refcount_inc_not_zero(&s_conn_id->sk->sk_refcnt) but…
--
quic: add connection id management
This patch adds struct quic_conn_id_set plus helpers to add, remove, and
look up source and destination Connection IDs, including insertion of
source CIDs into the global connection ID hash table. It also wires the
per-socket source/dest sets into quic_init_sock() and quic_destroy_sock().
> diff --git a/net/quic/connid.c b/net/quic/connid.c
> new file mode 100644
> index 0000000000000..e726a1d02c970
> --- /dev/null
> +++ b/net/quic/connid.c
> @@ -0,0 +1,283 @@
[ ... ]
> +/* Lookup a source connection ID (scid) in the global source connection ID hash
> + * table.
> + */
> +struct quic_conn_id *quic_conn_id_lookup(struct net *net, u8 *scid, u32 len)
> +{
> + struct quic_shash_head *head = quic_source_conn_id_head(net, scid, len);
> + struct quic_source_conn_id *s_conn_id;
> + struct quic_conn_id *conn_id = NULL;
> + struct hlist_nulls_node *node;
> +
> + WARN_ON_ONCE(!rcu_read_lock_held());
> +
> + hlist_nulls_for_each_entry_rcu(s_conn_id, node, &head->head, node) {
> + if (net != sock_net(s_conn_id->sk))
> + continue;
> + if (s_conn_id->common.id.len != len ||
> + memcmp(scid, &s_conn_id->common.id.data, len))
> + continue;
> + if (likely(refcount_inc_not_zero(&s_conn_id->sk->sk_refcnt)))
> + conn_id = &s_conn_id->common.id;
> + break;
> + }
[Severity: Low]
This isn't a bug, but could the reference semantics here be spelled out?
quic_conn_id_lookup() takes a hard socket reference with
refcount_inc_not_zero(&s_conn_id->sk->sk_refcnt), yet it returns a
struct quic_conn_id pointer. Neither the kerneldoc-style comment above the
function ("Lookup a source connection ID (scid) in the global source
connection ID hash table.") nor the prototype in connid.h mentions that the
caller now owns an sk reference that must be dropped with sock_put().
Recovering the socket from the return value also requires the caller to know
about the type-punning accessor:
net/quic/connid.h:
static inline struct sock *quic_conn_id_sk(struct quic_conn_id *conn_id)
{
return ((struct quic_source_conn_id *)conn_id)->sk;
}
Within this patch there is no matching sock_put() anywhere in the tree; the
balance only appears later in the series in "quic: add packet parser base",
where quic_packet_get_sock() converts the result via
return quic_conn_id_sk(conn_id); and quic_packet_rcv() drops the reference
with sock_put(sk) on every path after the lookup. So this is not a leak as
the series stands, only an implicit handoff that is easy to miss.
Would a short comment on quic_conn_id_lookup() stating that it returns with
an sk reference held, and that the caller must sock_put(quic_conn_id_sk())
it, make the contract clearer?
> + /* No need to check get_nulls_value(node) != hash for !conn_id, as
> + * hashtable size is fixed and a conn_id can not rehashed.
> + */
> + return conn_id;
> +}
[ ... ]
> diff --git a/net/quic/connid.h b/net/quic/connid.h
> new file mode 100644
> index 0000000000000..abad396a6ad6a
> --- /dev/null
> +++ b/net/quic/connid.h
> @@ -0,0 +1,183 @@
[ ... ]
> +struct quic_conn_id *quic_conn_id_find(struct quic_conn_id_set *id_set,
> + u32 number);
> +struct quic_conn_id *quic_conn_id_lookup(struct net *net, u8 *scid, u32 len);
[Severity: Low]
These two declarations sit next to each other, return the same type, but
have opposite reference-counting rules: quic_conn_id_find() returns a
borrowed pointer while quic_conn_id_lookup() returns one with an sk
reference attached. Would it be worth documenting that difference here, or
returning the struct sock * (or an output sk parameter) from
quic_conn_id_lookup() so the acquired reference is visible in the signature?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1789393775.git.lucien.xin%40gmail.com
next reply other threads:[~2026-09-15 19:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 19:50 netdev-bot+sashiko [this message]
-- strict thread matches above, loose matches on Subject: below --
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 07/15] quic: add connection id management 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=178950184154.22033.11596322184319753011@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