[rds-devel] [External] : Re: [PATCH] RDMA/cma: add rdma_destroy_id_wq() and use it from RDS

Allison Henderson achender at kernel.org
Mon Nov 16 06:47:45 UTC 2026


On Sat, 2026-11-14 at 20:18 -0400, Jason Gunthorpe wrote:
> On Sat, Nov 14, 2026 at 11:05:41PM +0800, Aibing Chen wrote:
> > syzbot reported a possible circular locking dependency between
> > rds_trans_sem and the RDMA CM handler mutex:
> > 
> >   CPU0 (bind path)                    CPU1 (CM callback path)
> >   ----                                ----
> >   down_read(&rds_trans_sem)           mutex_lock(&handler_mutex)
> >   rds_ib_laddr_check()                cma_ib_req_handler()
> >     rdma_destroy_id()                   rds_ib_cm_handle_connect()
> >       mutex_lock(&handler_mutex)          rds_conn_create()
> >                                             rds_trans_get_preferred()
> >                                               down_read(&rds_trans_sem)
> > 
> > rds_ib_laddr_check_cm() destroys the CM id from inside
> > rds_trans_get_preferred()'s read-side critical section, while CM
> > callbacks create RDS connections (taking the same read lock) from
> > under handler_mutex.
> > 
> > Break the cycle by destroying the CM id asynchronously: add
> > rdma_destroy_id_wq(), which queues the destruction on cma_wq, and
> > switch rds_ib_laddr_check_cm() to it.  The destroy work is embedded
> > in struct rdma_id_private, which keeps the id alive until the work
> > runs; rds does not touch cm_id after the destroy call.
> 
> This doesn't seem like it should be the core codes problem? Why can't
> rds do the workqueue?
> 
> Jason

Hi Aibing,

Aibing, thanks for chasing this down.  I think Jason is right, this
should probably be in the rds side.  This solution doesnt quite cover
all the locking issues though.  rds_conn_create calls
rds_trans_get_preferred() which falls through to rds_ib_laddr_check_cm()
when not local.  And then we get a rdma_destroy_id while the listen id's
handler_mutex is still held.

I think a better way to do this might be to create a new work item and
then deffer the rdma_destroy_id to be completed later by a worker.  The
work item would just hold the cm_id queued on rds_wq, and then the handler
just calls rdma_destroy_id() and frees itself.  alloc the new work item at
the top of rds_ib_laddr_check_cm and then queue the new work item in place of
the rdma_destroy_id.  You'll also need to add another flush_workqueue(rds_wq)
after rds_trans_unregister() in rds_ib_exit().

Other nits:  this patch should have a fixes tag, and target the net tree
like this: "[PATCH net v2] net/rds ...".  And I think the fixes tag is:
ec16227e1414 ("RDS/IB: Infiniband transport").  Drop the tested-by until it
is tested by syzbot and/or Eduard, and be sure to update your change log
below the dashed line.

Thanks for working on this!
Allion



More information about the rds-devel mailing list