From: Allison Henderson <achender@kernel.org>
To: Aibing Chen <chenaibing@cmss.chinamobile.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
rds-devel@oss.oracle.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] net/rds: defer CM id destruction to a workqueue
Date: Mon, 16 Nov 2026 23:15:46 -0700 [thread overview]
Message-ID: <6f4cebe1dae4c25d7618f0a08c1412cd0c68faeb.camel@kernel.org> (raw)
In-Reply-To: <20261116075423.782-1-chenaibing@cmss.chinamobile.com>
On Mon, 2026-11-16 at 15:54 +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 allocated here
> owns the cm_id until rdma_destroy_id() has run; if the allocation fails,
> the id is destroyed synchronously as before.
>
> 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>
> ---
> 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 | 37 ++++++++++++++++++++++++++++++++++++-
> 1 file changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d0..66af4a72a 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,6 +425,7 @@ 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;
>
Hi Aibing,
Thanks for the quick turn around, this is looking much better. Just a few things to get this
through: we cant fall back to the synchronous destroy if alloc fails, or the same bug
will come back under memory pressure. Lets hoist the alloc up here before the
rdma_create_id(). If alloc fails, just return -ENOMEM right away.
> isv4 = ipv6_addr_v4mapped(addr);
> @@ -419,6 +434,15 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
> NULL, RDMA_PS_TCP, IB_QPT_RC);
> if (IS_ERR(cm_id))
Then add a kfree(w) here before returning on this error case
> 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. If the allocation fails, fall back to the
> + * synchronous destroy.
> + */
> + w = kzalloc_obj(*w, GFP_KERNEL);
> ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
> if (ret)
> goto out;
> @@ -484,7 +508,13 @@ 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);
> + if (w) {
> + INIT_WORK(&w->work, rds_ib_destroy_id_work);
> + w->cm_id = cm_id;
> + queue_work(rds_wq, &w->work);
> + } else {
> + rdma_destroy_id(cm_id);
> + }
And then this else part can be removed since w is guaranteed here
Other than that, this looking really good.
Thanks for working on this!
Allison
>
> 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();
> }
>
>
>
>
prev parent reply other threads:[~2026-11-17 6:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 15:05 [PATCH] RDMA/cma: add rdma_destroy_id_wq() and use it from RDS Aibing Chen
2026-11-15 0:18 ` Jason Gunthorpe
2026-11-16 6:47 ` Allison Henderson
2026-11-15 15:05 ` sashiko-bot
2026-11-16 7:54 ` [PATCH net v2] net/rds: defer CM id destruction to a workqueue Aibing Chen
2026-11-17 6:15 ` 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=6f4cebe1dae4c25d7618f0a08c1412cd0c68faeb.camel@kernel.org \
--to=achender@kernel.org \
--cc=chenaibing@cmss.chinamobile.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rds-devel@oss.oracle.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