From: netdev-bot+sashiko@kernel.org
To: achender@kernel.org
Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
pabeni@redhat.com, edumazet@google.com, kuba@kernel.org,
horms@kernel.org, nicoyip.dev@gmail.com
Subject: Re: [PATCH net-next v2 9/9] net/rds: hold a connection reference from struct rds_incoming
Date: Wed, 16 Sep 2026 04:36:51 +0000 [thread overview]
Message-ID: <178953341168.22033.7134703325658795703@kernel.org> (raw)
In-Reply-To: <20260912035027.27447-10-achender@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 2
- [Low] The commit fixes a reported, user-visible use-after-free (KASAN
slab-use-after-free in rds6_inc_info_copy() via rds_info_getsockopt(),…
- [Low] In rds_recv_incoming() (net/rds/recv.c), the cross-netns
rejection comment at lines 424-431 still states that netns teardown…
--
net/rds: hold a connection reference from struct rds_incoming
Every assignment of struct rds_incoming->i_conn now takes a connection
reference, so an inc parked on a socket receive queue (or an m_inc on a
send queue) keeps its connection allocated. The references are dropped
from rds_inc_put() and from a new rds_message_free() helper.
Closes: https://lore.kernel.org/netdev/20260720184955.3008978-1-nicoyip.dev@gmail.com/
Two questions, one about the tag block and one about a comment that the
patch appears to make stale.
> Reported-by: Chengfeng Ye <nicoyip.dev@gmail.com>
> Closes: https://lore.kernel.org/netdev/20260720184955.3008978-1-nicoyip.dev@gmail.com/
> Signed-off-by: Sharath Srinivasan <sharath.srinivasan@oracle.com>
[Severity: Low]
Should this carry a Fixes: tag? The change closes a reported
slab-use-after-free (rds6_inc_info_copy() reached from
rds_info_getsockopt(), and the panic in rds_ib_recv_cache_put() reached
through rds_release()->rds_clear_recv_queue()->rds_ib_inc_free()), but no
originating commit is named.
git blame on the inc->i_conn = conn assignment in rds_inc_init() points at
bdbe6fbc6a2f ("RDS: recv.c"), so the origin looks identifiable. Other
patches in this series do carry the tag, for example "net/rds: make
rds_destroy_pending() cover single-connection destroy" with Fixes:
cdc306a5c9cd3 and "net/rds: guard every work-requeueing site with
rds_destroy_pending()" with Fixes: ebeeb1ad9b8a.
The commit message says in prose:
This is not a stable candidate: reaching the use-after-free requires
freeing a connection out from under a live socket
That reasoning is fine, but it is not something backport tooling parses,
and the tag block on its own does not say how far back the defect reaches.
> diff --git a/net/rds/recv.c b/net/rds/recv.c
> index 6204e577a90ae..b031c0b43af83 100644
> --- a/net/rds/recv.c
> +++ b/net/rds/recv.c
> @@ -46,6 +46,7 @@ void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,
> {
> refcount_set(&inc->i_refcount, 1);
> INIT_LIST_HEAD(&inc->i_item);
> + rds_conn_get(conn); /* put in rds_inc_put() */
> inc->i_conn = conn;
> inc->i_conn_path = NULL;
> inc->i_saddr = *saddr;
[ ... ]
> @@ -325,6 +337,13 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,
> unsigned long flags;
> struct rds_conn_path *cp;
>
> + /* every caller initialized @inc with rds_inc_init() or
> + * rds_inc_path_init() first, so i_conn already holds a reference.
> + * Take the new one before dropping the old, so that re-pointing an
> + * inc at the connection it already refers to cannot free it.
> + */
> + rds_conn_get(conn);
> + rds_conn_put(inc->i_conn);
> inc->i_conn = conn;
> inc->i_rx_jiffies = jiffies;
> if (conn->c_trans->t_mp_capable)
[Severity: Low]
Does this make the cross-netns comment further down in the same function
inaccurate? That comment still reads:
net/rds/recv.c:rds_recv_incoming() {
...
/*
* rds_find_bound() uses a global (netns-agnostic) hash table.
* An RDS connection created in netns A can match a socket bound
* in the init netns, delivering inc cross-netns with inc->i_conn
* pointing into netns A. When cleanup_net() then frees that conn,
* any subsequent dereference of inc->i_conn is a use-after-free.
* Drop the inc if the receiving socket lives in a different netns.
*/
if (!net_eq(sock_net(rds_rs_to_sk(rs)), rds_conn_net(conn))) {
...
}
After this patch the inc owns a reference from rds_inc_init() or
rds_inc_path_init(), and rds_inc_put() releases it only after
->inc_free() has run:
conn->c_trans->inc_free(inc);
rds_conn_put(conn);
rds_conn_put() reaches kmem_cache_free() only when the kref hits zero, so
a cross-netns inc sitting on a receive queue keeps its connection
allocated across cleanup_net().
The check itself still looks wanted, since cross-netns delivery is wrong on
its own and an outliving conn leaves conn->c_net stale. Could the comment
be reworded to state that reason rather than a use-after-free this patch
removes?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260912035027.27447-1-achender%40kernel.org
prev parent reply other threads:[~2026-09-16 4:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 3:50 [PATCH net-next v2 0/9] net/rds: make connection lifetime reference-counted Allison Henderson
2026-09-12 3:50 ` [PATCH net-next v2 1/9] net/rds: guard every work-requeueing site with rds_destroy_pending() Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 2/9] net/rds: make rds_destroy_pending() cover single-connection destroy Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 3/9] net/rds: split connection destroy into quiesce and kref-governed free Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 4/9] net/rds: wait for connections to be freed on transport unload Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 5/9] net/rds: unlink transport nodes before a possibly deferred connection free Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 6/9] net/rds: hold connection references in lookup, sockets and c_passive Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 7/9] net/rds: pin the connection across RDMA-CM event handling Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 8/9] net/rds: drop rds_conn_count in favor of t_conn_count Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko
2026-09-12 3:50 ` [PATCH net-next v2 9/9] net/rds: hold a connection reference from struct rds_incoming Allison Henderson
2026-09-16 4:36 ` netdev-bot+sashiko [this message]
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=178953341168.22033.7134703325658795703@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=achender@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicoyip.dev@gmail.com \
--cc=pabeni@redhat.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