Re: [PATCH net v3] net/rds: defer CM id destruction to a workqueue

From: netdev-bot+sashiko

Date: Sat Nov 21 2026 - 03:37:41 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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).

- [Medium] Each call to rds_ib_laddr_check_cm() (net/rds/ib.c) now
allocates a work item (kzalloc_obj(*w, GFP_KERNEL), line 439) and an…

--

net/rds: defer CM id destruction to a workqueue

This commit moves the rdma_destroy_id() call in rds_ib_laddr_check_cm()
to a work item on rds_wq, so rds_trans_sem is released before
handler_mutex is taken. The work item is allocated before the CM id is
created, and the address check fails with -ENOMEM if that allocation
fails. rds_ib_exit() now flushes rds_wq after unregistering the transport.

Closes: https://syzkaller.appspot.com/bug?extid=ccdb5058c3df2d94811c

> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..44b46defa1ae0 100644
> --- a/net/rds/ib.c
> +++ b/net/rds/ib.c

[ ... ]

> @@ -411,14 +425,28 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,

[ ... ]

> + 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);

[ ... ]

> @@ -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;
> }

[Severity: Medium]
Is there anything that limits how many of these destroys can be pending?

Before this change, rdma_destroy_id() ran synchronously. The number of
live cm_ids could never exceed the number of threads inside bind() at
that moment.

Now each call keeps two objects allocated until the krdsd worker gets to
the item: the work item and the rdma_id_private from rdma_create_id().
The caller returns right away, so the producer gets no backpressure.

An unprivileged user can reach this by calling bind() in a loop on an
AF_RDS socket, using an address that no IB device owns:

rds_bind()
rds_trans_get_preferred()
rds_ib_laddr_check()
rds_ib_laddr_check_cm()
kzalloc_obj(*w, GFP_KERNEL)
rdma_create_id()
...
queue_work(rds_wq, &w->work)

A failed laddr_check leaves the socket unbound, so the same socket can
call bind() again at once. The rds_rdma module has to be loaded, but it
can be autoloaded through SO_RDS_TRANSPORT.

Neither allocation uses __GFP_ACCOUNT. Could the pending objects pile up
as kernel memory that is never charged to the caller's memcg?

rds_threads_init() creates rds_wq with
create_singlethread_workqueue("krdsd"). That leaves one ordered worker to
drain items that can be queued from many CPUs.

The same workqueue also handles other RDS work:

- the cp_wq for RDS IB and TCP connection paths
- the TCP accept worker
- message unpin work
- rds_ib_dev_free()

Could a backlog of destroy items hold up connection, accept and teardown
work for every RDS user on the system?

When rdma_bind_addr() succeeds (for example IPv6 on IPoIB), each pending
cm_id also holds an RDMA_PS_TCP port until its destroy runs.

There are a few possible ways around this:

- return the cm_id to the caller and destroy it after
up_read(&rds_trans_sem)
- limit the number of in-flight destroys
- use a dedicated unordered workqueue and add __GFP_ACCOUNT

Would one of these work here?

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117082145.1737-1-chenaibing%40cmss.chinamobile.com