From: Allison Henderson <achender@kernel.org>
To: Aibing Chen <chenaibing@cmss.chinamobile.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v6 0/2] net/rds: fix the probe cm_id lock ordering
Date: Thu, 03 Dec 2026 09:40:43 -0700 [thread overview]
Message-ID: <6f68f3e15dcbe159ccb4503f27329de05c125047.camel@kernel.org> (raw)
In-Reply-To: <20261202024054.1945-1-chenaibing@cmss.chinamobile.com>
On Wed, 2026-12-02 at 10:40 +0800, Aibing Chen wrote:
> syzbot reported a circular locking dependency between rds_trans_sem and
> rdma_cm's handler_mutex:
>
> CPU0 (passive connection) CPU1 (bind)
> ---- ----
> mutex_lock(&handler_mutex) down_read(&rds_trans_sem)
> rds_ib_cm_handle_connect() rds_ib_laddr_check()
> rds_conn_create() rdma_destroy_id()
> rds_trans_get_preferred() mutex_lock(&handler_mutex)
> down_read(&rds_trans_sem)
>
> Patch 1 fixes the cycle the way the review asked for: take the module
> reference for the candidate transport under rds_trans_sem, drop the
> semaphore, and only then call ->laddr_check().
>
> Running that on a two-node rxe setup showed one more problem on the same
> path, which patch 2 fixes: when ->laddr_check() runs from the passive
> connection path, cma_ib_req_handler() already holds the listener's
> handler_mutex, and rds_ib_laddr_check() creates and destroys a probe
> cm_id whose rdma_destroy_id() takes the handler mutex of the probe id.
> Both are instances of the same lock class, so lockdep reports a
> recursive locking dependency. Destroy the probe id from rds_wq, where
> neither lock is held.
Hi Aibing,
Thanks for the follow up and the rxe testing. The sashiko findings on
both patches are valid, but I think we're getting closer, and I think your
testing points at a simpler fix. Both reports come from the same call of
__rds_conn_create() calling rds_trans_get_preferred() from inside an
rdma_cm handler. But all we really need it for here is deciding whether
faddr is local. So I think if we just hoist that logic out of
rds_trans_get_preferred() and make a helper that checks directly instead
of asking the transports, then both reports go away. Something like:
#include <net/route.h>
...
static bool rds_conn_addr_is_local(struct net *net,
const struct in6_addr *addr, int dev_if)
{
bool ret = false;
if (ipv6_addr_v4mapped(addr)) {
if (*(u8 *)&addr->s6_addr32[3] == IN_LOOPBACKNET)
return true;
return inet_addr_type(net, addr->s6_addr32[3]) == RTN_LOCAL;
}
if (ipv6_addr_loopback(addr))
return true;
#if IS_ENABLED(CONFIG_IPV6)
if (ipv6_mod_enabled()) {
struct net_device *dev = NULL;
rcu_read_lock();
if (dev_if)
dev = dev_get_by_index_rcu(net, dev_if);
if (!dev_if || dev)
ret = ipv6_chk_addr(net, addr, dev, 0);
rcu_read_unlock();
}
#endif
return ret;
}
and then in __rds_conn_create():
- loop_trans = rds_trans_get_preferred(net, faddr, conn->c_dev_if);
- if (loop_trans) {
- rds_trans_put(loop_trans);
+ if (rds_conn_addr_is_local(net, faddr, conn->c_dev_if)) {
conn->c_loopback = 1;
That should get us the same check rds_tcp_laddr_check() does, but without
taking rds_trans_sem under handler_mutex. So if we do this, we would only
need this one patch in place of the other two. Please re-run your rxe
setup with lockdep, ideally with active and passive connections, plus a
bind() to an address that isn't on an RDMA device.
Also cc'ing stable is fine since this is pretty small, but we should leave
a note for stable maintainers below the --- that stable trees where IPv6 can
still be a module would need "depends on IPV6 || !IPV6" on CONFIG_RDS since
this fix uses ipv6_chk_addr().
Thanks again for working on this!
Allison
pw-bot: cr
>
> Evidence, both nodes on a PROVE_LOCKING kernel, rxe0 on each node, an RDS
> connection established and then a bind() to an address that is not on an
> RDMA device (which is what reaches rds_ib_laddr_check_cm()):
>
> mainline: WARNING: possible circular locking dependency detected
> rds_trans_sem --> &id_priv->handler_mutex
> --> &id_priv->handler_mutex/1
> ... rdma_destroy_id <- rds_ib_laddr_check
> <- rds_trans_get_preferred <- rds_bind
> and down_read(rds_trans_sem) <- rds_trans_get_preferred
> <- __rds_conn_create
>
> this series: no lockdep report at all in the same run.
>
> I could not run syzbot's reproducer; the setup above is a hand-made
> equivalent. No runtime testing on real RDMA hardware was done, so the
> patches are compile tested (W=1) and tested on rxe only.
>
> v6:
> - add patch 2: the ordering fix alone still leaves the probe cm_id
> destroy nested under the CM handler's mutex, which lockdep reports as
> recursive locking once the semaphore cycle is gone.
> - patch 2 fails the address check with -ENOMEM above the bound instead
> of returning -EAGAIN, so rds_trans_get_preferred() cannot fall back to
> another transport.
>
> v5:
> - implement the ordering fix in rds_trans_get_preferred() as requested
> in the review (dropping the net/rds/ib.c workqueue, the global cap and
> the rds_wq flush of v4) and describe the report as a lock class
> conflict rather than a deadlock.
>
> v4 and earlier:
> - deferred rdma_destroy_id() to a workqueue and bounded the backlog.
>
> Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
> Suggested-by: Allison Henderson <achender@kernel.org>
> Link: https://lore.kernel.org/all/d83709308a038467b3a4849d814978b84328d2bc.camel@kernel.org/
> Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
>
> Aibing Chen (2):
> net/rds: drop rds_trans_sem around laddr_check()
> net/rds: defer the probe cm_id destroy to rds_wq
>
> net/rds/ib.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--
> net/rds/transport.c | 24 +++++++++++++++-------
> 2 files changed, 67 insertions(+), 7 deletions(-)
>
prev parent reply other threads:[~2026-12-03 16:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:40 [PATCH net v6 0/2] net/rds: fix the probe cm_id lock ordering Aibing Chen
2026-12-02 2:40 ` [PATCH net v6 1/2] net/rds: drop rds_trans_sem around laddr_check() Aibing Chen
2026-12-03 3:38 ` netdev-bot+sashiko
2026-12-02 2:40 ` [PATCH net v6 2/2] net/rds: defer the probe cm_id destroy to rds_wq Aibing Chen
2026-12-03 3:38 ` netdev-bot+sashiko
2026-12-03 16:40 ` Allison Henderson [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=6f68f3e15dcbe159ccb4503f27329de05c125047.camel@kernel.org \
--to=achender@kernel.org \
--cc=chenaibing@cmss.chinamobile.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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