* [PATCH net v4] net/rds: defer CM id destruction to a workqueue
@ 2026-11-22 14:51 Aibing Chen
2026-11-23 14:52 ` sashiko-bot
2026-11-23 15:35 ` netdev-bot+sashiko
0 siblings, 2 replies; 10+ messages in thread
From: Aibing Chen @ 2026-11-22 14:51 UTC (permalink / raw)
To: Allison Henderson
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, linux-rdma, rds-devel, linux-kernel
rds_ib_laddr_check_cm() destroys the RDMA CM id it created while
rds_trans_get_preferred() holds rds_trans_sem for reading. The bind
path then takes rds_trans_sem and afterwards handler_mutex in
rdma_destroy_id(), while the CM callback path takes handler_mutex in
cma_ib_req_handler() and afterwards rds_trans_sem through
rds_conn_create(). lockdep reports the resulting cycle.
Queue the destruction on rds_wq instead, so that rds_trans_sem is
released before handler_mutex is taken. The work item is allocated
before the CM id is created and owns the id until rdma_destroy_id() has
run; if the allocation fails, the address check fails with -ENOMEM
rather than falling back to the synchronous destroy, which would bring
the deadlock back under memory pressure.
Deferring the destruction keeps the CM id alive after bind() returns:
until the worker runs it pins a cma_dev reference and an RDMA_PS_TCP
port, and cma_process_remove() waits for every pending destroy. An
unprivileged user can call bind() in a loop, so bound the number of
pending probes with rds_ib_pending_probes and fail the address check
with -EAGAIN above RDS_IB_MAX_PENDING_PROBES.
rds_ib_exit() flushes rds_wq after rds_trans_unregister() so that no
queued destroy runs after the module text is gone.
Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
Suggested-by: Hillf Danton <hdanton@sina.com>
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Suggested-by: Allison Henderson <achender@kernel.org>
Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
v4:
- bound the pending probe ids with an atomic counter and return -EAGAIN
above RDS_IB_MAX_PENDING_PROBES, since each pending id pins a
cma_dev reference and an RDMA_PS_TCP port until the worker runs.
- document that exposure in the commit message.
v3:
- allocate the work item before rdma_create_id() and fail with -ENOMEM
instead of falling back to the synchronous destroy.
- free the work item when rdma_create_id() fails and drop the now
redundant fallback in the out path.
v2:
- move the workqueue from RDMA core into RDS, as suggested in review.
- flush rds_wq in rds_ib_exit() so a queued destroy cannot run after
the module text is freed.
- add the Fixes tag, drop the Tested-by tags.
net/rds/ib.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 58 insertions(+), 2 deletions(-)
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 4ea9838d0..c4c10e3ea 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -391,6 +391,30 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
}
#endif
+/*
+ * Maximum number of probe cm_ids whose destruction is still pending on
+ * rds_wq. Each of them pins a cma_dev reference and an RDMA_PS_TCP port,
+ * so the number of in-flight probes has to be bounded.
+ */
+#define RDS_IB_MAX_PENDING_PROBES 64
+
+static atomic_t rds_ib_pending_probes = ATOMIC_INIT(0);
+
+struct rds_ib_destroy_work {
+ struct work_struct work;
+ struct rdma_cm_id *cm_id;
+};
+
+static void rds_ib_destroy_id_work(struct work_struct *work)
+{
+ struct rds_ib_destroy_work *w =
+ container_of(work, struct rds_ib_destroy_work, work);
+
+ rdma_destroy_id(w->cm_id);
+ kfree(w);
+ atomic_dec(&rds_ib_pending_probes);
+}
+
/*
* Early RDS/IB was built to only bind to an address if there is an IPoIB
* device with that address set.
@@ -411,14 +435,39 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
#endif
struct sockaddr_in sin;
struct sockaddr *sa;
+ struct rds_ib_destroy_work *w;
bool isv4;
isv4 = ipv6_addr_v4mapped(addr);
+
+ /*
+ * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
+ * function with rds_trans_sem held for reading, and rdma_destroy_id()
+ * takes handler_mutex, which the CM callback path acquires before
+ * taking rds_trans_sem. Reserve a pending-probe slot first, so that a
+ * loop of bind() calls cannot pile up ids that pin a cma_dev reference
+ * and an RDMA_PS_TCP port.
+ */
+ if (atomic_inc_return(&rds_ib_pending_probes) >
+ RDS_IB_MAX_PENDING_PROBES) {
+ atomic_dec(&rds_ib_pending_probes);
+ return -EAGAIN;
+ }
+
+ w = kzalloc_obj(*w, GFP_KERNEL);
+ if (!w) {
+ atomic_dec(&rds_ib_pending_probes);
+ return -ENOMEM;
+ }
+
/* Create a CMA ID restricted to IB devices and try to bind it. */
cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
NULL, RDMA_PS_TCP, IB_QPT_RC);
- if (IS_ERR(cm_id))
+ if (IS_ERR(cm_id)) {
+ atomic_dec(&rds_ib_pending_probes);
+ kfree(w);
return PTR_ERR(cm_id);
+ }
ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
if (ret)
goto out;
@@ -484,7 +533,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
cm_id->device ? cm_id->device->node_type : -1);
out:
- rdma_destroy_id(cm_id);
+ INIT_WORK(&w->work, rds_ib_destroy_id_work);
+ w->cm_id = cm_id;
+ queue_work(rds_wq, &w->work);
return ret;
}
@@ -542,6 +593,11 @@ void rds_ib_exit(void)
rds_ib_sysctl_exit();
rds_ib_recv_exit();
rds_trans_unregister(&rds_ib_transport);
+ /*
+ * rds_ib_laddr_check_cm() may have queued rdma_destroy_id() on rds_wq;
+ * wait for it before the module text goes away.
+ */
+ flush_workqueue(rds_wq);
rds_ib_mr_exit();
}
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-22 14:51 [PATCH net v4] net/rds: defer CM id destruction to a workqueue Aibing Chen
@ 2026-11-23 14:52 ` sashiko-bot
2026-11-23 15:35 ` netdev-bot+sashiko
1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-23 14:52 UTC (permalink / raw)
To: Aibing Chen; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/rds: silent TCP fallback or wrong errno on
rds_ib_laddr_check_cm() -EAGAIN
--
commit e574b9774f231da9aa189fbad06e4a6b85eb1372
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>
net/rds: defer CM id destruction to a workqueue
This commit defers rdma_destroy_id() from rds_ib_laddr_check_cm() to rds_wq to
avoid a lockdep cycle between rds_trans_sem and handler_mutex, and bounds the
number of pending probe CM IDs to 64.
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..c4c10e3eabced 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
[ ... ]
> @@ -411,14 +435,39 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> #endif
> struct sockaddr_in sin;
> struct sockaddr *sa;
> + struct rds_ib_destroy_work *w;
> bool isv4;
>
> isv4 = ipv6_addr_v4mapped(addr);
> +
> + /*
> + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> + * takes handler_mutex, which the CM callback path acquires before
> + * taking rds_trans_sem. Reserve a pending-probe slot first, so that a
> + * loop of bind() calls cannot pile up ids that pin a cma_dev reference
> + * and an RDMA_PS_TCP port.
> + */
> + if (atomic_inc_return(&rds_ib_pending_probes) >
> + RDS_IB_MAX_PENDING_PROBES) {
> + atomic_dec(&rds_ib_pending_probes);
> + return -EAGAIN;
> + }
[Severity: Medium]
When rds_ib_laddr_check_cm() returns -EAGAIN (or -ENOMEM), does
rds_trans_get_preferred() silently fall back to rds_tcp_transport instead of
propagating the error?
net/rds/transport.c:rds_trans_get_preferred() {
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];
if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
(!trans->t_owner || try_module_get(trans->t_owner))) {
ret = trans;
break;
}
}
}
rds_trans_get_preferred() treats any non-zero return from trans->laddr_check()
as a non-match and continues to the next transport. Because
rds_tcp_laddr_check() accepts any local address on the host, a socket binding
to a local IPoIB address while RDS_IB_MAX_PENDING_PROBES is exceeded will be
bound to rds_tcp_transport instead of rds_ib_transport, causing subsequent
RDMA operations such as RDS_GET_MR to fail with -EOPNOTSUPP. In rds_bind(),
-EAGAIN is also overwritten with -EADDRNOTAVAIL when no fallback transport is
loaded, or with -ENOPROTOOPT when rs->rs_transport was preset.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122145148.1250-1-chenaibing@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-22 14:51 [PATCH net v4] net/rds: defer CM id destruction to a workqueue Aibing Chen
2026-11-23 14:52 ` sashiko-bot
@ 2026-11-23 15:35 ` netdev-bot+sashiko
2026-11-26 2:36 ` Allison Henderson
1 sibling, 1 reply; 10+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 15:35 UTC (permalink / raw)
To: chenaibing
Cc: achender, davem, edumazet, kuba, pabeni, horms, netdev,
linux-rdma, rds-devel, linux-kernel
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · 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).
- [High] RDS_IB_MAX_PENDING_PROBES (net/rds/ib.c:399-401) is one global
budget of 64 for the whole system, with no per-user or per-socket…
- [Medium] The new temporary errors in rds_ib_laddr_check_cm()
(net/rds/ib.c) never reach userspace; callers read them as "this…
- [Medium] The commit message calls the issue a real deadlock ("falling
back to the synchronous destroy, which would bring the deadlock back…
--
net/rds: defer CM id destruction to a workqueue
This patch moves rdma_destroy_id() for the probe cm_id created in
rds_ib_laddr_check_cm() onto rds_wq, so it no longer runs under
rds_trans_sem. A global atomic counter caps pending probe ids at
RDS_IB_MAX_PENDING_PROBES, and the address check returns -EAGAIN above
that cap. rds_ib_exit() flushes rds_wq before the module goes away.
Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..c4c10e3eabced 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -391,6 +391,30 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
> }
> #endif
>
> +/*
> + * Maximum number of probe cm_ids whose destruction is still pending on
> + * rds_wq. Each of them pins a cma_dev reference and an RDMA_PS_TCP port,
> + * so the number of in-flight probes has to be bounded.
> + */
> +#define RDS_IB_MAX_PENDING_PROBES 64
> +
> +static atomic_t rds_ib_pending_probes = ATOMIC_INIT(0);
[Severity: High]
Is one system-wide budget of 64 safe here? Nothing splits it per user or
per socket. The only place that releases a slot is
rds_ib_destroy_id_work(), which runs on rds_wq. That is an ordered
single-threaded workqueue, and other RDS work shares it:
net/rds/threads.c:rds_threads_init() {
rds_wq = create_singlethread_workqueue("krdsd");
...
}
The commit message only considers a bind() loop. However,
rds_ib_laddr_check_cm() is also reached for every new connection:
__rds_conn_create()
rds_trans_get_preferred(net, faddr, conn->c_dev_if)
rds_ib_laddr_check()
rds_ib_laddr_check_cm()
That includes incoming connect requests. There,
rds_ib_cm_handle_connect() calls rds_conn_create(&init_net, daddr6,
saddr6, ...), and saddr6 comes from the peer's CM private data.
rds_ib_laddr_check() skips the probe only for v4-mapped addresses that
rds_ib_get_device() finds. Remote peers, IPv6 addresses and uncached IPv4
addresses each hold a slot until the worker runs.
Can one unprivileged user, or a burst of connection setup, keep
rds_ib_pending_probes at 64 and make every other user's IB address check
fail? Their bind() would then be moved to RDS/TCP or fail, as described
below for the -EAGAIN return. Before this patch, one user could not
affect another user's IB bind.
There also seems to be a lasting effect on connections. Take a new
connection whose faddr is local but misses the fast path. If the probe
returns -EAGAIN and rds_tcp is not loaded, loop_trans is NULL and
c_loopback stays 0:
net/rds/connection.c:__rds_conn_create() {
...
loop_trans = rds_trans_get_preferred(net, faddr, conn->c_dev_if);
if (loop_trans) {
rds_trans_put(loop_trans);
conn->c_loopback = 1;
...
}
Connections are not re-evaluated later, so the looped-back IB passive
connection split is skipped:
if (conn &&
conn->c_loopback &&
conn->c_trans != &rds_loop_transport &&
ipv6_addr_equal(laddr, faddr) &&
!is_outgoing) {
Wouldn't the incoming self-connect then find the outgoing conn itself,
and rds_ib_cm_handle_connect() reject it as a raced connect?
The commit message mentions neither the connection creation path nor the
shared budget.
[ ... ]
> @@ -411,14 +435,39 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
[ ... ]
> isv4 = ipv6_addr_v4mapped(addr);
> +
> + /*
> + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> + * takes handler_mutex, which the CM callback path acquires before
> + * taking rds_trans_sem. Reserve a pending-probe slot first, so that a
> + * loop of bind() calls cannot pile up ids that pin a cma_dev reference
> + * and an RDMA_PS_TCP port.
> + */
[Severity: Medium]
The commit message, which is tagged Cc: stable, says:
rather than falling back to the synchronous destroy, which would bring
the deadlock back under memory pressure.
Can that deadlock actually happen? The handler_mutex that
rdma_destroy_id() takes here belongs to the private probe cm_id created a
few lines below. That id has a NULL context, is only bound, is never
listened on, and is never shared.
On the CM callback path in the commit message, the code holds the
listener's handler_mutex and the new conn_id's handler_mutex, not the
probe's:
cma_ib_req_handler()
rds_rdma_cm_event_handler()
rds_ib_cm_handle_connect()
rds_conn_create()
rds_trans_get_preferred()
down_read(&rds_trans_sem)
Those are different instances of the same lock class.
For the probe id, the events that could hold its handler_mutex reach
rds_rdma_cm_event_handler_cmn() with conn == NULL, and nothing is done:
case RDMA_CM_EVENT_DEVICE_REMOVAL:
case RDMA_CM_EVENT_ADDR_CHANGE:
if (conn)
rds_conn_drop(conn);
break;
That path never waits for rds_trans_sem. Both sides also take
rds_trans_sem only for read.
This looks like a class-level lockdep report rather than an
instance-level deadlock. It is still worth silencing, but could the
commit message and this comment describe it that way?
If no real deadlock exists, is the stable backport justified? This patch
also brings in the global probe cap and the transport fallback described
here.
> + if (atomic_inc_return(&rds_ib_pending_probes) >
> + RDS_IB_MAX_PENDING_PROBES) {
> + atomic_dec(&rds_ib_pending_probes);
> + return -EAGAIN;
> + }
> +
> + w = kzalloc_obj(*w, GFP_KERNEL);
> + if (!w) {
> + atomic_dec(&rds_ib_pending_probes);
> + return -ENOMEM;
> + }
[Severity: Medium]
Does the -EAGAIN (or -ENOMEM) ever reach userspace?
rds_trans_get_preferred() treats any non-zero laddr_check() result as
"not this transport" and moves on to the next slot:
net/rds/transport.c:rds_trans_get_preferred() {
...
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];
if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
(!trans->t_owner || try_module_get(trans->t_owner))) {
...
}
RDS_TRANS_TCP comes after RDS_TRANS_IB. rds_tcp_laddr_check() returns 0
for any RTN_LOCAL IPv4 address and for any IPv6 address that passes
ipv6_chk_addr(), and IPoIB addresses pass both checks.
While the cap is hit, would the following happen?
- bind() on an IB address succeeds but selects RDS/TCP. rds_bind() then
stores it in rs->rs_transport for the life of the socket, so RDMA cmsgs
and MR registration fail later.
- If rds_tcp is not loaded, bind() fails with -EADDRNOTAVAIL and logs
"load rds_tcp or rds_rdma?".
- With SO_RDS_TRANSPORT set to IB, bind() fails with -ENOPROTOOPT:
if (rs->rs_transport) {
trans = rs->rs_transport;
if (!trans->laddr_check ||
trans->laddr_check(sock_net(sock->sk),
binding_addr, scope_id) != 0) {
ret = -ENOPROTOOPT;
So the cap doesn't seem to give the retryable back-pressure that the
comment and commit message describe. rdma_create_id() could already fail
with -ENOMEM and take the same fallback, but that was rare. Any user can
now hit the cap on purpose.
Is it intended that hitting the cap silently moves the socket to RDS/TCP?
If so, could the commit message mention the transport switch and the
changed errno?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122145148.1250-1-chenaibing%40cmss.chinamobile.com
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-23 15:35 ` netdev-bot+sashiko
@ 2026-11-26 2:36 ` Allison Henderson
0 siblings, 0 replies; 10+ messages in thread
From: Allison Henderson @ 2026-11-26 2:36 UTC (permalink / raw)
To: netdev-bot+sashiko, chenaibing
Cc: davem, edumazet, kuba, pabeni, horms, netdev, linux-rdma,
rds-devel, linux-kernel
On Mon, 2026-11-23 at 15:35 +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 · Medium: 2 · 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).
>
> - [High] RDS_IB_MAX_PENDING_PROBES (net/rds/ib.c:399-401) is one global
> budget of 64 for the whole system, with no per-user or per-socket…
> - [Medium] The new temporary errors in rds_ib_laddr_check_cm()
> (net/rds/ib.c) never reach userspace; callers read them as "this…
> - [Medium] The commit message calls the issue a real deadlock ("falling
> back to the synchronous destroy, which would bring the deadlock back…
>
> --
>
> net/rds: defer CM id destruction to a workqueue
>
> This patch moves rdma_destroy_id() for the probe cm_id created in
> rds_ib_laddr_check_cm() onto rds_wq, so it no longer runs under
> rds_trans_sem. A global atomic counter caps pending probe ids at
> RDS_IB_MAX_PENDING_PROBES, and the address check returns -EAGAIN above
> that cap. rds_ib_exit() flushes rds_wq before the module goes away.
>
> Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
>
> > diff --git a/net/rds/ib.c b/net/rds/ib.c
> > index 4ea9838d090c3..c4c10e3eabced 100644
> > --- a/net/rds/ib.c
> > +++ b/net/rds/ib.c
> > @@ -391,6 +391,30 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
> > }
> > #endif
> >
> > +/*
> > + * Maximum number of probe cm_ids whose destruction is still pending on
> > + * rds_wq. Each of them pins a cma_dev reference and an RDMA_PS_TCP port,
> > + * so the number of in-flight probes has to be bounded.
> > + */
> > +#define RDS_IB_MAX_PENDING_PROBES 64
> > +
> > +static atomic_t rds_ib_pending_probes = ATOMIC_INIT(0);
>
> [Severity: High]
> Is one system-wide budget of 64 safe here? Nothing splits it per user or
> per socket. The only place that releases a slot is
> rds_ib_destroy_id_work(), which runs on rds_wq. That is an ordered
> single-threaded workqueue, and other RDS work shares it:
>
> net/rds/threads.c:rds_threads_init() {
> rds_wq = create_singlethread_workqueue("krdsd");
> ...
> }
>
> The commit message only considers a bind() loop. However,
> rds_ib_laddr_check_cm() is also reached for every new connection:
>
> __rds_conn_create()
> rds_trans_get_preferred(net, faddr, conn->c_dev_if)
> rds_ib_laddr_check()
> rds_ib_laddr_check_cm()
>
> That includes incoming connect requests. There,
> rds_ib_cm_handle_connect() calls rds_conn_create(&init_net, daddr6,
> saddr6, ...), and saddr6 comes from the peer's CM private data.
>
> rds_ib_laddr_check() skips the probe only for v4-mapped addresses that
> rds_ib_get_device() finds. Remote peers, IPv6 addresses and uncached IPv4
> addresses each hold a slot until the worker runs.
>
> Can one unprivileged user, or a burst of connection setup, keep
> rds_ib_pending_probes at 64 and make every other user's IB address check
> fail? Their bind() would then be moved to RDS/TCP or fail, as described
> below for the -EAGAIN return. Before this patch, one user could not
> affect another user's IB bind.
>
> There also seems to be a lasting effect on connections. Take a new
> connection whose faddr is local but misses the fast path. If the probe
> returns -EAGAIN and rds_tcp is not loaded, loop_trans is NULL and
> c_loopback stays 0:
>
> net/rds/connection.c:__rds_conn_create() {
> ...
> loop_trans = rds_trans_get_preferred(net, faddr, conn->c_dev_if);
> if (loop_trans) {
> rds_trans_put(loop_trans);
> conn->c_loopback = 1;
> ...
> }
>
> Connections are not re-evaluated later, so the looped-back IB passive
> connection split is skipped:
>
> if (conn &&
> conn->c_loopback &&
> conn->c_trans != &rds_loop_transport &&
> ipv6_addr_equal(laddr, faddr) &&
> !is_outgoing) {
>
> Wouldn't the incoming self-connect then find the outgoing conn itself,
> and rds_ib_cm_handle_connect() reject it as a raced connect?
>
> The commit message mentions neither the connection creation path nor the
> shared budget.
>
> [ ... ]
>
> > @@ -411,14 +435,39 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
>
> [ ... ]
>
> > isv4 = ipv6_addr_v4mapped(addr);
> > +
> > + /*
> > + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> > + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> > + * takes handler_mutex, which the CM callback path acquires before
> > + * taking rds_trans_sem. Reserve a pending-probe slot first, so that a
> > + * loop of bind() calls cannot pile up ids that pin a cma_dev reference
> > + * and an RDMA_PS_TCP port.
> > + */
>
> [Severity: Medium]
> The commit message, which is tagged Cc: stable, says:
>
> rather than falling back to the synchronous destroy, which would bring
> the deadlock back under memory pressure.
>
> Can that deadlock actually happen? The handler_mutex that
> rdma_destroy_id() takes here belongs to the private probe cm_id created a
> few lines below. That id has a NULL context, is only bound, is never
> listened on, and is never shared.
>
> On the CM callback path in the commit message, the code holds the
> listener's handler_mutex and the new conn_id's handler_mutex, not the
> probe's:
>
> cma_ib_req_handler()
> rds_rdma_cm_event_handler()
> rds_ib_cm_handle_connect()
> rds_conn_create()
> rds_trans_get_preferred()
> down_read(&rds_trans_sem)
>
> Those are different instances of the same lock class.
>
> For the probe id, the events that could hold its handler_mutex reach
> rds_rdma_cm_event_handler_cmn() with conn == NULL, and nothing is done:
>
> case RDMA_CM_EVENT_DEVICE_REMOVAL:
> case RDMA_CM_EVENT_ADDR_CHANGE:
> if (conn)
> rds_conn_drop(conn);
> break;
>
> That path never waits for rds_trans_sem. Both sides also take
> rds_trans_sem only for read.
>
> This looks like a class-level lockdep report rather than an
> instance-level deadlock. It is still worth silencing, but could the
> commit message and this comment describe it that way?
>
> If no real deadlock exists, is the stable backport justified? This patch
> also brings in the global probe cap and the transport fallback described
> here.
Hi Aibing,
Thanks for sticking with this through four versions. I think the sashiko
findings are right, so we'll need to address them. And that means we might
need to change our approach.
Let's drop the deferral and fix the ordering in rds_trans_get_preferred()
instead. Take the module reference under rds_trans_sem, drop the semaphore, and
then call ->laddr_check(). The probe goes back to being destroyed synchronously,
and rds_trans_sem is no longer held when handler_mutex is taken. Something like:
down_read(&rds_trans_sem);
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];
if (!trans ||
(trans->t_owner && !try_module_get(trans->t_owner)))
continue;
/* ->laddr_check() may create and destroy an rdma_cm id, which
* takes rdma_cm's handler_mutex. Don't hold rds_trans_sem
* across it: the module reference keeps trans alive.
*/
up_read(&rds_trans_sem);
if (trans->laddr_check(net, addr, scope_id) == 0)
return trans;
rds_trans_put(trans);
down_read(&rds_trans_sem);
}
up_read(&rds_trans_sem);
That will also stop calling laddr_check() on a transport whose module
is already being unloaded. So with this, all the changes to net/rds/ib.c
can go.
For v5, lets amend the commit message to describe it as a lockdep report caused
by all handler_mutex instances sharing one lock class instead of a deadlock. If you
or Eduard can, please test with lockdep on rxe with both an active and a passive
connection and make sure there are no complaints. It shouldn't, but it would
be nice to know if it does.
Thanks again for working on this!
Allison
pw-bot: cr
>
> > + if (atomic_inc_return(&rds_ib_pending_probes) >
> > + RDS_IB_MAX_PENDING_PROBES) {
> > + atomic_dec(&rds_ib_pending_probes);
> > + return -EAGAIN;
> > + }
> > +
> > + w = kzalloc_obj(*w, GFP_KERNEL);
> > + if (!w) {
> > + atomic_dec(&rds_ib_pending_probes);
> > + return -ENOMEM;
> > + }
>
> [Severity: Medium]
> Does the -EAGAIN (or -ENOMEM) ever reach userspace?
> rds_trans_get_preferred() treats any non-zero laddr_check() result as
> "not this transport" and moves on to the next slot:
>
> net/rds/transport.c:rds_trans_get_preferred() {
> ...
> for (i = 0; i < RDS_TRANS_COUNT; i++) {
> trans = transports[i];
>
> if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
> (!trans->t_owner || try_module_get(trans->t_owner))) {
> ...
> }
>
> RDS_TRANS_TCP comes after RDS_TRANS_IB. rds_tcp_laddr_check() returns 0
> for any RTN_LOCAL IPv4 address and for any IPv6 address that passes
> ipv6_chk_addr(), and IPoIB addresses pass both checks.
>
> While the cap is hit, would the following happen?
>
> - bind() on an IB address succeeds but selects RDS/TCP. rds_bind() then
> stores it in rs->rs_transport for the life of the socket, so RDMA cmsgs
> and MR registration fail later.
>
> - If rds_tcp is not loaded, bind() fails with -EADDRNOTAVAIL and logs
> "load rds_tcp or rds_rdma?".
>
> - With SO_RDS_TRANSPORT set to IB, bind() fails with -ENOPROTOOPT:
>
> if (rs->rs_transport) {
> trans = rs->rs_transport;
> if (!trans->laddr_check ||
> trans->laddr_check(sock_net(sock->sk),
> binding_addr, scope_id) != 0) {
> ret = -ENOPROTOOPT;
>
> So the cap doesn't seem to give the retryable back-pressure that the
> comment and commit message describe. rdma_create_id() could already fail
> with -ENOMEM and take the same fallback, but that was rare. Any user can
> now hit the cap on purpose.
>
> Is it intended that hitting the cap silently moves the socket to RDS/TCP?
> If so, could the commit message mention the transport switch and the
> changed errno?
>
> [ ... ]
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
@ 2026-11-30 15:49 kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2026-11-30 15:49 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "too many reports for this commit"
::::::
BCC: lkp@intel.com
CC: llvm@lists.linux.dev
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20261129094231.1368-1-chenaibing@cmss.chinamobile.com>
References: <20261129094231.1368-1-chenaibing@cmss.chinamobile.com>
TO: Aibing Chen <chenaibing@cmss.chinamobile.com>
TO: achender@kernel.org
CC: jgg@ziepe.ca
CC: leon@kernel.org
CC: davem@davemloft.net
CC: edumazet@kernel.org
CC: kuba@kernel.org
CC: pabeni@redhat.com
CC: horms@kernel.org
CC: netdev@vger.kernel.org
CC: linux-rdma@vger.kernel.org
CC: rds-devel@oss.oracle.com
CC: linux-kernel@vger.kernel.org
CC: hdanton@sina.com
CC: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
CC: Aibing Chen <chenaibing@cmss.chinamobile.com>
CC: stable@vger.kernel.org
Hi Aibing,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Aibing-Chen/net-rds-defer-CM-id-destruction-to-a-workqueue/20261129-174231
base: net/main
patch link: https://lore.kernel.org/r/20261129094231.1368-1-chenaibing%40cmss.chinamobile.com
patch subject: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
:::::: branch date: 30 hours ago
:::::: commit date: 30 hours ago
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20261130/20261130234426.FJXgOsOq-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 04597ff5c4eda9d66da39a536aa26a7bab2fb2dd)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261130/20261130234426.FJXgOsOq-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/20261130234426.FJXgOsOq-lkp@intel.com/
All errors (new ones prefixed by >>):
net/rds/ib.c:408:14: error: use of undeclared identifier 'rds_ib_probe_pending'; did you mean 'rds_destroy_pending'?
408 | atomic_dec(&rds_ib_probe_pending);
| ^~~~~~~~~~~~~~~~~~~~
| rds_destroy_pending
net/rds/rds.h:997:20: note: 'rds_destroy_pending' declared here
997 | static inline bool rds_destroy_pending(struct rds_connection *conn)
| ^
>> net/rds/ib.c:408:13: error: incompatible pointer types passing 'bool (*)(struct rds_connection *)' (aka '_Bool (*)(struct rds_connection *)') to parameter of type 'atomic_t *' [-Wincompatible-pointer-types]
408 | atomic_dec(&rds_ib_probe_pending);
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/atomic/atomic-instrumented.h:590:22: note: passing argument to parameter 'v' here
590 | atomic_dec(atomic_t *v)
| ^
2 errors generated.
vim +408 net/rds/ib.c
cff82395d246dda Aibing Chen 2026-11-29 398
cff82395d246dda Aibing Chen 2026-11-29 399 static void rds_ib_destroy_id_work(struct work_struct *work)
cff82395d246dda Aibing Chen 2026-11-29 400 {
cff82395d246dda Aibing Chen 2026-11-29 401 struct rds_ib_destroy_work *w =
cff82395d246dda Aibing Chen 2026-11-29 402 container_of(work, struct rds_ib_destroy_work, work);
cff82395d246dda Aibing Chen 2026-11-29 403
cff82395d246dda Aibing Chen 2026-11-29 404 rdma_destroy_id(w->cm_id);
cff82395d246dda Aibing Chen 2026-11-29 405 kfree(w);
cff82395d246dda Aibing Chen 2026-11-29 406
cff82395d246dda Aibing Chen 2026-11-29 407 /* Matched by the decrement in this function. */
cff82395d246dda Aibing Chen 2026-11-29 @408 atomic_dec(&rds_ib_probe_pending);
cff82395d246dda Aibing Chen 2026-11-29 409 }
cff82395d246dda Aibing Chen 2026-11-29 410
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH net v3] net/rds: defer CM id destruction to a workqueue
@ 2026-11-17 8:21 Aibing Chen
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
0 siblings, 1 reply; 10+ messages in thread
From: Aibing Chen @ 2026-11-17 8:21 UTC (permalink / raw)
To: Allison Henderson
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev, linux-rdma, rds-devel, linux-kernel
rds_ib_laddr_check_cm() destroys the RDMA CM id it created while
rds_trans_get_preferred() holds rds_trans_sem for reading. The bind
path then takes rds_trans_sem and afterwards handler_mutex in
rdma_destroy_id(), while the CM callback path takes handler_mutex in
cma_ib_req_handler() and afterwards rds_trans_sem through
rds_conn_create(). lockdep reports the resulting cycle.
Queue the destruction on rds_wq instead, so that rds_trans_sem is
released before handler_mutex is taken. The work item is allocated
before the CM id is created and owns the id until rdma_destroy_id() has
run; if the allocation fails, the address check fails with -ENOMEM
rather than falling back to the synchronous destroy, which would bring
the deadlock back under memory pressure.
rds_ib_exit() flushes rds_wq after rds_trans_unregister() so that no
queued destroy runs after the module text is gone.
Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
Suggested-by: Hillf Danton <hdanton@sina.com>
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Suggested-by: Allison Henderson <achender@kernel.org>
Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
v3:
- allocate the work item before rdma_create_id() and fail with -ENOMEM
instead of falling back to the synchronous destroy, which would bring
the deadlock back under memory pressure.
- free the work item when rdma_create_id() fails and drop the now
redundant fallback in the out path.
v2:
- move the workqueue from RDMA core into RDS, as suggested in review.
- flush rds_wq in rds_ib_exit() so a queued destroy cannot run after
the module text is freed.
- add the Fixes tag, drop the Tested-by tags.
net/rds/ib.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 4ea9838d0..44b46defa 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -391,6 +391,20 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
}
#endif
+struct rds_ib_destroy_work {
+ struct work_struct work;
+ struct rdma_cm_id *cm_id;
+};
+
+static void rds_ib_destroy_id_work(struct work_struct *work)
+{
+ struct rds_ib_destroy_work *w =
+ container_of(work, struct rds_ib_destroy_work, work);
+
+ rdma_destroy_id(w->cm_id);
+ kfree(w);
+}
+
/*
* Early RDS/IB was built to only bind to an address if there is an IPoIB
* device with that address set.
@@ -411,14 +425,28 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
#endif
struct sockaddr_in sin;
struct sockaddr *sa;
+ struct rds_ib_destroy_work *w;
bool isv4;
isv4 = ipv6_addr_v4mapped(addr);
+
+ /*
+ * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
+ * function with rds_trans_sem held for reading, and rdma_destroy_id()
+ * takes handler_mutex, which the CM callback path acquires before
+ * taking rds_trans_sem.
+ */
+ w = kzalloc_obj(*w, GFP_KERNEL);
+ if (!w)
+ return -ENOMEM;
+
/* Create a CMA ID restricted to IB devices and try to bind it. */
cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
NULL, RDMA_PS_TCP, IB_QPT_RC);
- if (IS_ERR(cm_id))
+ if (IS_ERR(cm_id)) {
+ kfree(w);
return PTR_ERR(cm_id);
+ }
ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
if (ret)
goto out;
@@ -484,7 +512,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
cm_id->device ? cm_id->device->node_type : -1);
out:
- rdma_destroy_id(cm_id);
+ INIT_WORK(&w->work, rds_ib_destroy_id_work);
+ w->cm_id = cm_id;
+ queue_work(rds_wq, &w->work);
return ret;
}
@@ -542,6 +572,11 @@ void rds_ib_exit(void)
rds_ib_sysctl_exit();
rds_ib_recv_exit();
rds_trans_unregister(&rds_ib_transport);
+ /*
+ * rds_ib_laddr_check_cm() may have queued rdma_destroy_id() on rds_wq;
+ * wait for it before the module text goes away.
+ */
+ flush_workqueue(rds_wq);
rds_ib_mr_exit();
}
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-17 8:21 [PATCH net v3] " Aibing Chen
@ 2026-11-29 9:42 ` Aibing Chen
2026-11-29 16:08 ` kernel test robot
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Aibing Chen @ 2026-11-29 9:42 UTC (permalink / raw)
To: achender
Cc: jgg, leon, davem, edumazet, kuba, pabeni, horms, netdev,
linux-rdma, rds-devel, linux-kernel, hdanton,
syzbot+ccdb5058c3df2d94811c, Aibing Chen, stable
rds_ib_laddr_check_cm() destroys the RDMA CM id it created while
rds_trans_get_preferred() holds rds_trans_sem for reading. The bind
path then takes rds_trans_sem and afterwards handler_mutex in
rdma_destroy_id(), while the CM callback path takes handler_mutex in
cma_ib_req_handler() and afterwards rds_trans_sem through
rds_conn_create(). lockdep reports the resulting cycle.
Queue the destruction on rds_wq instead, so that rds_trans_sem is
released before handler_mutex is taken. The work item is allocated
before the CM id is created and owns the id until rdma_destroy_id()
has run; if the allocation fails, the address check fails with
-ENOMEM rather than falling back to the synchronous destroy, which
would bring the deadlock back under memory pressure.
Deferring the destruction leaves each probe cm_id alive on rds_wq
until the worker runs. rds_wq is an ordered single-worker queue
shared with the rest of RDS, and each pending item holds a
rdma_id_private, a cma_dev reference and an ephemeral RDMA_PS_TCP
port, so an unprivileged bind() loop could pin memory, exhaust ports
needed by other RDMA users (NVMe-oF, iSER, NFS/RDMA) and delay IB
device removal. Bound the number of pending probe destroys with an
atomic counter: rds_ib_laddr_check_cm() returns -EAGAIN once
RDS_IB_MAX_PROBE_PENDING (64) destroys are queued, and the counter is
released on every error path and in the worker.
rds_ib_exit() flushes rds_wq after rds_trans_unregister() so that no
queued destroy runs after the module text is gone.
Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
Suggested-by: Hillf Danton <hdanton@sina.com>
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Suggested-by: Allison Henderson <achender@kernel.org>
Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
v4:
- bound the number of pending probe destroys with an atomic counter
(cap 64, -EAGAIN above it); the deferred destroy leaves each probe
cm_id, its cma_dev reference and an ephemeral RDMA_PS_TCP port alive
on the ordered rds_wq until the worker runs, and nothing previously
limited the backlog (Allison Henderson).
v3:
- allocate the work item before rdma_create_id() and fail with -ENOMEM
instead of falling back to the synchronous destroy, which would bring
the deadlock back under memory pressure.
- free the work item when rdma_create_id() fails and drop the now
redundant fallback in the out path.
v2:
- move the workqueue from RDMA core into RDS, as suggested in review.
- flush rds_wq in rds_ib_exit() so a queued destroy cannot run after
the module text is freed.
- add the Fixes tag, drop the Tested-by tags.
---
net/rds/ib.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 63 insertions(+), 2 deletions(-)
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 4ea9838d0..b83220de9 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -391,6 +391,31 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
}
#endif
+struct rds_ib_destroy_work {
+ struct work_struct work;
+ struct rdma_cm_id *cm_id;
+};
+
+static void rds_ib_destroy_id_work(struct work_struct *work)
+{
+ struct rds_ib_destroy_work *w =
+ container_of(work, struct rds_ib_destroy_work, work);
+
+ rdma_destroy_id(w->cm_id);
+ kfree(w);
+
+ /* Matched by the decrement in this function. */
+ atomic_dec(&rds_ib_probe_pending);
+}
+
+/*
+ * Bound the number of probe cm_ids pending destruction on rds_wq: each
+ * holds a rdma_id_private, a cma_dev reference and an ephemeral
+ * RDMA_PS_TCP port until the worker runs.
+ */
+#define RDS_IB_MAX_PROBE_PENDING 64
+static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
+
/*
* Early RDS/IB was built to only bind to an address if there is an IPoIB
* device with that address set.
@@ -411,14 +436,42 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
#endif
struct sockaddr_in sin;
struct sockaddr *sa;
+ struct rds_ib_destroy_work *w;
bool isv4;
+ /*
+ * Bound the probe backlog: each queued destroy pins the cm_id, a
+ * cma_dev reference and an ephemeral RDMA_PS_TCP port until the
+ * worker runs.
+ */
+ if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
+ atomic_dec(&rds_ib_probe_pending);
+ return -EAGAIN;
+ }
+
isv4 = ipv6_addr_v4mapped(addr);
+
+ w = kzalloc_obj(*w, GFP_KERNEL);
+ if (!w) {
+ atomic_dec(&rds_ib_probe_pending);
+ return -ENOMEM;
+ }
+
/* Create a CMA ID restricted to IB devices and try to bind it. */
cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
NULL, RDMA_PS_TCP, IB_QPT_RC);
- if (IS_ERR(cm_id))
+ if (IS_ERR(cm_id)) {
+ kfree(w);
+ atomic_dec(&rds_ib_probe_pending);
return PTR_ERR(cm_id);
+ }
+
+ /*
+ * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
+ * function with rds_trans_sem held for reading, and rdma_destroy_id()
+ * takes handler_mutex, which the CM callback path acquires before
+ * taking rds_trans_sem.
+ */
ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
if (ret)
goto out;
@@ -484,7 +537,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
cm_id->device ? cm_id->device->node_type : -1);
out:
- rdma_destroy_id(cm_id);
+ INIT_WORK(&w->work, rds_ib_destroy_id_work);
+ w->cm_id = cm_id;
+ queue_work(rds_wq, &w->work);
return ret;
}
@@ -542,6 +597,12 @@ void rds_ib_exit(void)
rds_ib_sysctl_exit();
rds_ib_recv_exit();
rds_trans_unregister(&rds_ib_transport);
+
+ /*
+ * rds_ib_laddr_check_cm() may have queued rdma_destroy_id() on rds_wq;
+ * wait for it before the module text goes away.
+ */
+ flush_workqueue(rds_wq);
rds_ib_mr_exit();
}
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
@ 2026-11-29 16:08 ` kernel test robot
2026-11-29 20:25 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2026-11-29 16:08 UTC (permalink / raw)
To: Aibing Chen, achender
Cc: llvm, oe-kbuild-all, jgg, leon, davem, edumazet, kuba, pabeni,
horms, netdev, linux-rdma, rds-devel, linux-kernel, hdanton,
syzbot+ccdb5058c3df2d94811c, Aibing Chen, stable
Hi Aibing,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Aibing-Chen/net-rds-defer-CM-id-destruction-to-a-workqueue/20261129-174231
base: net/main
patch link: https://lore.kernel.org/r/20261129094231.1368-1-chenaibing%40cmss.chinamobile.com
patch subject: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
config: s390-defconfig (https://download.01.org/0day-ci/archive/20261130/20261130000118.mvVQ8b5B-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261130/20261130000118.mvVQ8b5B-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261130000118.mvVQ8b5B-lkp@intel.com/
All errors (new ones prefixed by >>):
>> net/rds/ib.c:408:14: error: use of undeclared identifier 'rds_ib_probe_pending'; did you mean 'rds_destroy_pending'?
408 | atomic_dec(&rds_ib_probe_pending);
| ^~~~~~~~~~~~~~~~~~~~
| rds_destroy_pending
net/rds/rds.h:997:20: note: 'rds_destroy_pending' declared here
997 | static inline bool rds_destroy_pending(struct rds_connection *conn)
| ^
1 error generated.
vim +408 net/rds/ib.c
398
399 static void rds_ib_destroy_id_work(struct work_struct *work)
400 {
401 struct rds_ib_destroy_work *w =
402 container_of(work, struct rds_ib_destroy_work, work);
403
404 rdma_destroy_id(w->cm_id);
405 kfree(w);
406
407 /* Matched by the decrement in this function. */
> 408 atomic_dec(&rds_ib_probe_pending);
409 }
410
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
2026-11-29 16:08 ` kernel test robot
@ 2026-11-29 20:25 ` kernel test robot
2026-11-30 9:42 ` sashiko-bot
2026-12-01 3:56 ` Allison Henderson
3 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2026-11-29 20:25 UTC (permalink / raw)
To: Aibing Chen, achender
Cc: oe-kbuild-all, jgg, leon, davem, edumazet, kuba, pabeni, horms,
netdev, linux-rdma, rds-devel, linux-kernel, hdanton,
syzbot+ccdb5058c3df2d94811c, Aibing Chen, stable
Hi Aibing,
kernel test robot noticed the following build errors:
[auto build test ERROR on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Aibing-Chen/net-rds-defer-CM-id-destruction-to-a-workqueue/20261129-174231
base: net/main
patch link: https://lore.kernel.org/r/20261129094231.1368-1-chenaibing%40cmss.chinamobile.com
patch subject: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
config: i386-randconfig-1004-20261129 (https://download.01.org/0day-ci/archive/20261130/20261130042230.yz5LTggD-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261130/20261130042230.yz5LTggD-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261130042230.yz5LTggD-lkp@intel.com/
All errors (new ones prefixed by >>):
net/rds/ib.c: In function 'rds_ib_destroy_id_work':
>> net/rds/ib.c:408:21: error: 'rds_ib_probe_pending' undeclared (first use in this function); did you mean 'rds_destroy_pending'?
408 | atomic_dec(&rds_ib_probe_pending);
| ^~~~~~~~~~~~~~~~~~~~
| rds_destroy_pending
net/rds/ib.c:408:21: note: each undeclared identifier is reported only once for each function it appears in
vim +408 net/rds/ib.c
398
399 static void rds_ib_destroy_id_work(struct work_struct *work)
400 {
401 struct rds_ib_destroy_work *w =
402 container_of(work, struct rds_ib_destroy_work, work);
403
404 rdma_destroy_id(w->cm_id);
405 kfree(w);
406
407 /* Matched by the decrement in this function. */
> 408 atomic_dec(&rds_ib_probe_pending);
409 }
410
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
2026-11-29 16:08 ` kernel test robot
2026-11-29 20:25 ` kernel test robot
@ 2026-11-30 9:42 ` sashiko-bot
2026-12-01 3:56 ` Allison Henderson
3 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-30 9:42 UTC (permalink / raw)
To: Aibing Chen; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] net/rds: rds_ib_probe_pending used before declaration in
rds_ib_destroy_id_work()
- [Medium] net/rds: silent TCP fallback and lost -EAGAIN when
rds_ib_laddr_check_cm() hits cap
- [Medium] net/rds: deferred cm_id destroy cap breaks
rds_trans_get_preferred()
--
commit 5d5ae2e4ce33977f5f5c4a838c5ab4ec75ae672a
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>
net/rds: defer CM id destruction to a workqueue
This commit defers rdma_destroy_id() in rds_ib_laddr_check_cm() to rds_wq
to avoid taking handler_mutex while holding rds_trans_sem, caps pending
probe destroys at 64, and flushes rds_wq in rds_ib_exit().
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..b83220de964ca 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -391,6 +391,31 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
> }
> #endif
>
> +struct rds_ib_destroy_work {
> + struct work_struct work;
> + struct rdma_cm_id *cm_id;
> +};
> +
> +static void rds_ib_destroy_id_work(struct work_struct *work)
> +{
> + struct rds_ib_destroy_work *w =
> + container_of(work, struct rds_ib_destroy_work, work);
> +
> + rdma_destroy_id(w->cm_id);
> + kfree(w);
> +
> + /* Matched by the decrement in this function. */
> + atomic_dec(&rds_ib_probe_pending);
> +}
> +
> +/*
> + * Bound the number of probe cm_ids pending destruction on rds_wq: each
> + * holds a rdma_id_private, a cma_dev reference and an ephemeral
> + * RDMA_PS_TCP port until the worker runs.
> + */
> +#define RDS_IB_MAX_PROBE_PENDING 64
> +static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
[Severity: High]
Does rds_ib_destroy_id_work() reference rds_ib_probe_pending before it is
declared, breaking compilation when CONFIG_RDS_RDMA is enabled? Also, the
comment above atomic_dec() says "Matched by the decrement in this
function" rather than the increment in rds_ib_laddr_check_cm().
> @@ -411,14 +436,42 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> #endif
> struct sockaddr_in sin;
> struct sockaddr *sa;
> + struct rds_ib_destroy_work *w;
> bool isv4;
>
> + /*
> + * Bound the probe backlog: each queued destroy pins the cm_id, a
> + * cma_dev reference and an ephemeral RDMA_PS_TCP port until the
> + * worker runs.
> + */
> + if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -EAGAIN;
> + }
[Severity: Medium]
Can returning -EAGAIN here cause rds_trans_get_preferred() to silently
demote an IPoIB socket to rds_tcp_transport?
rds_trans_get_preferred() checks only whether trans->laddr_check() == 0,
so any non-zero return from rds_ib_laddr_check() is treated as a transport
mismatch rather than a transient error:
net/rds/transport.c:rds_trans_get_preferred() {
...
for (i = 0; i < RDS_TRANS_COUNT; i++) {
trans = transports[i];
if (trans && (trans->laddr_check(net, addr, scope_id) == 0) &&
(!trans->t_owner || try_module_get(trans->t_owner))) {
ret = trans;
break;
}
}
...
}
Once 64 probe destroys are queued on the single-threaded rds_wq (from
concurrent binds or new connections calling rds_trans_get_preferred() in
__rds_conn_create()), rds_trans_get_preferred() falls through from
RDS_TRANS_IB to RDS_TRANS_TCP, where rds_tcp_laddr_check() accepts any
local IPv4 or IPv6 address and permanently binds IPoIB sockets to TCP
(or fails rds_bind() with -EADDRNOTAVAIL / -ENOPROTOOPT when rds_tcp is
not used, and leaves conn->c_loopback unset in __rds_conn_create()).
> + isv4 = ipv6_addr_v4mapped(addr);
> +
> + w = kzalloc_obj(*w, GFP_KERNEL);
> + if (!w) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -ENOMEM;
> + }
> +
> /* Create a CMA ID restricted to IB devices and try to bind it. */
> cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
> NULL, RDMA_PS_TCP, IB_QPT_RC);
> - if (IS_ERR(cm_id))
> + if (IS_ERR(cm_id)) {
> + kfree(w);
> + atomic_dec(&rds_ib_probe_pending);
> return PTR_ERR(cm_id);
> + }
> +
> + /*
> + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> + * takes handler_mutex, which the CM callback path acquires before
> + * taking rds_trans_sem.
> + */
> ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
> if (ret)
> goto out;
> @@ -484,7 +537,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> cm_id->device ? cm_id->device->node_type : -1);
>
> out:
> - rdma_destroy_id(cm_id);
> + INIT_WORK(&w->work, rds_ib_destroy_id_work);
> + w->cm_id = cm_id;
> + queue_work(rds_wq, &w->work);
[Severity: Medium]
As reported by Allison Henderson on v4 [1], could rds_trans_get_preferred()
take the module reference under rds_trans_sem and drop rds_trans_sem before
calling trans->laddr_check(), instead of deferring rdma_destroy_id() to
rds_wq?
Destroying the probe cm_id synchronously with rds_trans_sem released avoids
taking handler_mutex under rds_trans_sem without needing workqueue deferral
or the 64-probe cap that breaks transport selection in
rds_trans_get_preferred(). In addition, because the probe cm_id is created
with a NULL context and never listens, its callbacks in
rds_rdma_cm_event_handler_cmn() never acquire rds_trans_sem, so the commit
message should describe the issue as a class-level lockdep report rather
than a runtime deadlock.
[1] https://lore.kernel.org/r/d83709308a038467b3a4849d814978b84328d2bc.camel@kernel.org
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129094231.1368-1-chenaibing@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
` (2 preceding siblings ...)
2026-11-30 9:42 ` sashiko-bot
@ 2026-12-01 3:56 ` Allison Henderson
3 siblings, 0 replies; 10+ messages in thread
From: Allison Henderson @ 2026-12-01 3:56 UTC (permalink / raw)
To: Aibing Chen
Cc: jgg, leon, davem, edumazet, kuba, pabeni, horms, netdev,
linux-rdma, rds-devel, linux-kernel, hdanton,
syzbot+ccdb5058c3df2d94811c, stable
On Sun, 2026-11-29 at 17:42 +0800, Aibing Chen wrote:
> rds_ib_laddr_check_cm() destroys the RDMA CM id it created while
> rds_trans_get_preferred() holds rds_trans_sem for reading. The bind
> path then takes rds_trans_sem and afterwards handler_mutex in
> rdma_destroy_id(), while the CM callback path takes handler_mutex in
> cma_ib_req_handler() and afterwards rds_trans_sem through
> rds_conn_create(). lockdep reports the resulting cycle.
>
> Queue the destruction on rds_wq instead, so that rds_trans_sem is
> released before handler_mutex is taken. The work item is allocated
> before the CM id is created and owns the id until rdma_destroy_id()
> has run; if the allocation fails, the address check fails with
> -ENOMEM rather than falling back to the synchronous destroy, which
> would bring the deadlock back under memory pressure.
>
> Deferring the destruction leaves each probe cm_id alive on rds_wq
> until the worker runs. rds_wq is an ordered single-worker queue
> shared with the rest of RDS, and each pending item holds a
> rdma_id_private, a cma_dev reference and an ephemeral RDMA_PS_TCP
> port, so an unprivileged bind() loop could pin memory, exhaust ports
> needed by other RDMA users (NVMe-oF, iSER, NFS/RDMA) and delay IB
> device removal. Bound the number of pending probe destroys with an
> atomic counter: rds_ib_laddr_check_cm() returns -EAGAIN once
> RDS_IB_MAX_PROBE_PENDING (64) destroys are queued, and the counter is
> released on every error path and in the worker.
>
> rds_ib_exit() flushes rds_wq after rds_trans_unregister() so that no
> queued destroy runs after the module text is gone.
>
> Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c
> Suggested-by: Hillf Danton <hdanton@sina.com>
> Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
> Suggested-by: Allison Henderson <achender@kernel.org>
> Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
Hi Aibing,
I'm presuming this patch must have gone out by mistake since it looks like
it still has build errors, and doesnt cover the findings from the last review:
ttps://lore.kernel.org/r/d83709308a038467b3a4849d814978b84328d2bc.camel@kernel.org
No worries, just send v5 when it's ready.
Thanks!
pw-bot: cr
> ---
> v4:
> - bound the number of pending probe destroys with an atomic counter
> (cap 64, -EAGAIN above it); the deferred destroy leaves each probe
> cm_id, its cma_dev reference and an ephemeral RDMA_PS_TCP port alive
> on the ordered rds_wq until the worker runs, and nothing previously
> limited the backlog (Allison Henderson).
>
> v3:
> - allocate the work item before rdma_create_id() and fail with -ENOMEM
> instead of falling back to the synchronous destroy, which would bring
> the deadlock back under memory pressure.
> - free the work item when rdma_create_id() fails and drop the now
> redundant fallback in the out path.
>
> v2:
> - move the workqueue from RDMA core into RDS, as suggested in review.
> - flush rds_wq in rds_ib_exit() so a queued destroy cannot run after
> the module text is freed.
> - add the Fixes tag, drop the Tested-by tags.
> ---
> net/rds/ib.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d0..b83220de9 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c
> @@ -391,6 +391,31 @@ static void rds6_ib_ic_info(struct socket *sock, unsigned int len,
> }
> #endif
>
> +struct rds_ib_destroy_work {
> + struct work_struct work;
> + struct rdma_cm_id *cm_id;
> +};
> +
> +static void rds_ib_destroy_id_work(struct work_struct *work)
> +{
> + struct rds_ib_destroy_work *w =
> + container_of(work, struct rds_ib_destroy_work, work);
> +
> + rdma_destroy_id(w->cm_id);
> + kfree(w);
> +
> + /* Matched by the decrement in this function. */
> + atomic_dec(&rds_ib_probe_pending);
> +}
> +
> +/*
> + * Bound the number of probe cm_ids pending destruction on rds_wq: each
> + * holds a rdma_id_private, a cma_dev reference and an ephemeral
> + * RDMA_PS_TCP port until the worker runs.
> + */
> +#define RDS_IB_MAX_PROBE_PENDING 64
> +static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
> +
> /*
> * Early RDS/IB was built to only bind to an address if there is an IPoIB
> * device with that address set.
> @@ -411,14 +436,42 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> #endif
> struct sockaddr_in sin;
> struct sockaddr *sa;
> + struct rds_ib_destroy_work *w;
> bool isv4;
>
> + /*
> + * Bound the probe backlog: each queued destroy pins the cm_id, a
> + * cma_dev reference and an ephemeral RDMA_PS_TCP port until the
> + * worker runs.
> + */
> + if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -EAGAIN;
> + }
> +
> isv4 = ipv6_addr_v4mapped(addr);
> +
> + w = kzalloc_obj(*w, GFP_KERNEL);
> + if (!w) {
> + atomic_dec(&rds_ib_probe_pending);
> + return -ENOMEM;
> + }
> +
> /* Create a CMA ID restricted to IB devices and try to bind it. */
> cm_id = rdma_create_id(&init_net, rds_rdma_cm_event_handler,
> NULL, RDMA_PS_TCP, IB_QPT_RC);
> - if (IS_ERR(cm_id))
> + if (IS_ERR(cm_id)) {
> + kfree(w);
> + atomic_dec(&rds_ib_probe_pending);
> return PTR_ERR(cm_id);
> + }
> +
> + /*
> + * The id is destroyed from rds_wq: rds_trans_get_preferred() calls this
> + * function with rds_trans_sem held for reading, and rdma_destroy_id()
> + * takes handler_mutex, which the CM callback path acquires before
> + * taking rds_trans_sem.
> + */
> ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
> if (ret)
> goto out;
> @@ -484,7 +537,9 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> cm_id->device ? cm_id->device->node_type : -1);
>
> out:
> - rdma_destroy_id(cm_id);
> + INIT_WORK(&w->work, rds_ib_destroy_id_work);
> + w->cm_id = cm_id;
> + queue_work(rds_wq, &w->work);
>
> return ret;
> }
> @@ -542,6 +597,12 @@ void rds_ib_exit(void)
> rds_ib_sysctl_exit();
> rds_ib_recv_exit();
> rds_trans_unregister(&rds_ib_transport);
> +
> + /*
> + * rds_ib_laddr_check_cm() may have queued rdma_destroy_id() on rds_wq;
> + * wait for it before the module text goes away.
> + */
> + flush_workqueue(rds_wq);
> rds_ib_mr_exit();
> }
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-01 3:56 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 14:51 [PATCH net v4] net/rds: defer CM id destruction to a workqueue Aibing Chen
2026-11-23 14:52 ` sashiko-bot
2026-11-23 15:35 ` netdev-bot+sashiko
2026-11-26 2:36 ` Allison Henderson
-- strict thread matches above, loose matches on Subject: below --
2026-11-30 15:49 kernel test robot
2026-11-17 8:21 [PATCH net v3] " Aibing Chen
2026-11-29 9:42 ` [PATCH net v4] " Aibing Chen
2026-11-29 16:08 ` kernel test robot
2026-11-29 20:25 ` kernel test robot
2026-11-30 9:42 ` sashiko-bot
2026-12-01 3:56 ` Allison Henderson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.