mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v6 0/2] net/rds: fix the probe cm_id lock ordering
@ 2026-12-02  2:40 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-02  2:40 ` [PATCH net v6 2/2] net/rds: defer the probe cm_id destroy to rds_wq Aibing Chen
  0 siblings, 2 replies; 5+ messages in thread
From: Aibing Chen @ 2026-12-02  2:40 UTC (permalink / raw)
  To: Allison Henderson; +Cc: netdev, linux-kernel

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.

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(-)

-- 
2.50.1.windows.1




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v6 1/2] net/rds: drop rds_trans_sem around laddr_check()
  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 ` 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
  1 sibling, 1 reply; 5+ messages in thread
From: Aibing Chen @ 2026-12-02  2:40 UTC (permalink / raw)
  To: Allison Henderson; +Cc: netdev, linux-kernel

rds_trans_get_preferred() calls ->laddr_check() while holding
rds_trans_sem for reading.  The IB transport's laddr_check() creates a
temporary rdma_cm id and destroys it again, and rdma_destroy_id() takes
rdma_cm's handler_mutex.  The CM callback path takes handler_mutex before
entering RDS through rds_conn_create(), which ends up in
rds_trans_get_preferred() and takes rds_trans_sem, so lockdep reports a
circular locking dependency between the semaphore and the handler mutex
class.

All handler_mutex instances share one lock class and the probe id's mutex
is private to it, so this is a lock class conflict rather than a single
deadlock, but rds_trans_sem should not be held across a call that reaches
into another subsystem's locking.

Take the module reference for the candidate transport while holding
rds_trans_sem, drop the semaphore, and only then call ->laddr_check().
The module reference keeps the transport and its callback alive, and
rds_trans_sem is no longer held when handler_mutex is taken.  A transport
that fails its check is put and the scan continues.

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>
---
 net/rds/transport.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/net/rds/transport.c b/net/rds/transport.c
index f8001ec80..904b9351e 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -86,7 +86,6 @@ struct rds_transport *rds_trans_get_preferred(struct net *net,
 					      const struct in6_addr *addr,
 					      __u32 scope_id)
 {
-	struct rds_transport *ret = NULL;
 	struct rds_transport *trans;
 	unsigned int i;
 
@@ -101,15 +100,26 @@ struct rds_transport *rds_trans_get_preferred(struct net *net,
 	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;
-		}
+		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);
 
-	return ret;
+	return NULL;
 }
 
 struct rds_transport *rds_trans_get(int t_type)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v6 2/2] net/rds: defer the probe cm_id destroy to rds_wq
  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-02  2:40 ` Aibing Chen
  2026-12-03  3:38   ` netdev-bot+sashiko
  1 sibling, 1 reply; 5+ messages in thread
From: Aibing Chen @ 2026-12-02  2:40 UTC (permalink / raw)
  To: Allison Henderson; +Cc: netdev, linux-kernel

rds_ib_laddr_check() is called from rds_trans_get_preferred(), which runs
both on the bind path and from the passive connection path, where
rdma_cm's handler_mutex is already held:

  cma_ib_req_handler()
    rds_ib_cm_handle_connect()
      rds_conn_create()
        rds_trans_get_preferred()
          rds_ib_laddr_check()
            rdma_destroy_id()
              mutex_lock(&id_priv->handler_mutex)

rdma_destroy_id() takes the handler mutex of the probe id, which is a
different instance of the same lock class, so lockdep reports a
recursive locking dependency as soon as a connection is established.

Destroy the probe id from rds_wq instead.  The work item is allocated
before rdma_create_id(), so an allocation failure fails the address check
instead of falling back to the synchronous destroy, and the number of
pending destroys is bounded by RDS_IB_MAX_PROBE_PENDING (64); above the
bound the check fails with -ENOMEM rather than returning a value that
would make rds_trans_get_preferred() fall back to another transport.

rds_ib_exit() flushes rds_wq after unregistering the transport, so a
queued destroy cannot run after the module text is gone.

Fixes: ec16227e1414 ("RDS/IB: Infiniband transport")
Cc: stable@vger.kernel.org
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 net/rds/ib.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/net/rds/ib.c b/net/rds/ib.c
index 4ea9838d0..624374ecf 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
 
+/*
+ * The probe cm_id must not be destroyed from the caller's context:
+ * rds_ib_laddr_check() runs it while rdma_cm's handler_mutex is held
+ * (the passive connection path) or while rds_trans_get_preferred() holds
+ * rds_trans_sem, and rdma_destroy_id() takes handler_mutex again.  Queue
+ * the destruction on rds_wq, which runs without either lock.
+ */
+struct rds_ib_probe_work {
+	struct work_struct work;
+	struct rdma_cm_id *cm_id;
+};
+
+static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
+#define RDS_IB_MAX_PROBE_PENDING 64
+
+static void rds_ib_probe_work_fn(struct work_struct *work)
+{
+	struct rds_ib_probe_work *pw =
+		container_of(work, struct rds_ib_probe_work, work);
+
+	rdma_destroy_id(pw->cm_id);
+	kfree(pw);
+	atomic_dec(&rds_ib_probe_pending);
+}
+
 /*
  * Early RDS/IB was built to only bind to an address if there is an IPoIB
  * device with that address set.
@@ -406,6 +431,7 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
 {
 	int ret;
 	struct rdma_cm_id *cm_id;
+	struct rds_ib_probe_work *pw;
 #if IS_ENABLED(CONFIG_IPV6)
 	struct sockaddr_in6 sin6;
 #endif
@@ -414,11 +440,25 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
 	bool isv4;
 
 	isv4 = ipv6_addr_v4mapped(addr);
+
+	pw = kzalloc_obj(*pw);
+	if (!pw)
+		return -ENOMEM;
+
+	if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
+		atomic_dec(&rds_ib_probe_pending);
+		kfree(pw);
+		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(pw);
+		atomic_dec(&rds_ib_probe_pending);
 		return PTR_ERR(cm_id);
+	}
 	ret = rdma_restrict_node_type(cm_id, RDMA_NODE_IB_CA);
 	if (ret)
 		goto out;
@@ -484,7 +524,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(&pw->work, rds_ib_probe_work_fn);
+	pw->cm_id = cm_id;
+	queue_work(rds_wq, &pw->work);
 
 	return ret;
 }
@@ -542,6 +584,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 a probe destroy 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] 5+ messages in thread

* Re: [PATCH net v6 1/2] net/rds: drop rds_trans_sem around laddr_check()
  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
  0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03  3:38 UTC (permalink / raw)
  To: chenaibing; +Cc: achender, netdev, linux-kernel, kuba

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] rds_trans_get_preferred() (net/rds/transport.c) now takes the
  transport's module reference with try_module_get(), drops…

--

net/rds: drop rds_trans_sem around laddr_check()

This commit changes rds_trans_get_preferred() so that it takes the module
reference for each candidate transport while holding rds_trans_sem. It then
drops the semaphore before calling ->laddr_check(). The goal is to break a
lockdep-reported circular dependency between rds_trans_sem and rdma_cm's
handler_mutex.

Link: https://lore.kernel.org/all/d83709308a038467b3a4849d814978b84328d2bc.camel@kernel.org/

> diff --git a/net/rds/transport.c b/net/rds/transport.c
> index f8001ec808671..904b9351e7613 100644
> --- a/net/rds/transport.c
> +++ b/net/rds/transport.c

[ ... ]

> @@ -101,15 +100,26 @@ struct rds_transport *rds_trans_get_preferred(struct net *net,
>  	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;
> -		}
> +		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;

[Severity: Medium]
Does the module reference keep trans and ->laddr_check() alive while
rds_rdma is still in MODULE_STATE_COMING? The commit message says:

  "The module reference keeps the transport and its callback alive"

However, try_module_get() only refuses modules that are in
MODULE_STATE_GOING:

include/linux/module.h:module_is_live() {
	return mod->state != MODULE_STATE_GOING;
}

rds_ib_init() publishes rds_ib_transport through rds_trans_register() during
module init. rds_rdma_init() can still fail after that point:

net/rds/rdma_transport.c:rds_rdma_init() {
    ...
	ret = rds_ib_init();
	if (ret)
		goto out;

	ret = rds_rdma_listen_init();
	if (ret)
		rds_ib_exit();
    ...
}

rds_rdma_listen_init() can fail with -ENOMEM from rdma_create_id(). It can
also fail if rdma_bind_addr() or rdma_listen() fails, for example when
RDS_PORT is already bound in RDMA_PS_TCP.

On that failure, do_init_module() frees the module and does not wait for
references taken by try_module_get() during COMING:

kernel/module/main.c:do_init_module() {
    ...
fail:
	mod->state = MODULE_STATE_GOING;
	synchronize_rcu();
	module_put(mod);
    ...
	free_module(mod);
}

Before this patch, laddr_check ran under down_read(&rds_trans_sem). The
down_write() in rds_trans_unregister() therefore waited for it to finish.
Now that the semaphore is dropped, can this interleaving happen?

CPU1 (unprivileged, bind() on AF_RDS without SO_RDS_TRANSPORT)
rds_bind()->rds_trans_get_preferred()
    try_module_get(trans->t_owner)    /* succeeds in COMING */
    up_read(&rds_trans_sem);
    trans->laddr_check()              /* rds_ib_laddr_check() */

CPU2
rds_rdma_init()
    rds_rdma_listen_init()            /* fails */
    rds_ib_exit()
        rds_trans_unregister()        /* down_write no longer waits */
do_init_module() fail path
    free_module()

In that case CPU1 would run freed module text and touch freed module data,
such as rds_ib_devices and rds_rdma_cm_event_handler.

The follow-up patch in this series, "net/rds: defer the probe cm_id destroy
to rds_wq", seems to make the window larger. With that patch,
rds_ib_laddr_check_cm() queues module text on rds.ko's workqueue:

	INIT_WORK(&pw->work, rds_ib_probe_work_fn);
	pw->cm_id = cm_id;
	queue_work(rds_wq, &pw->work);

rds_ib_exit() flushes that workqueue right after unregistering:

	rds_trans_unregister(&rds_ib_transport);
	...
	flush_workqueue(rds_wq);

A probe that is still running in the window above can queue its work after
that flush. rds_wq belongs to rds.ko and outlives rds_rdma. Could
rds_ib_probe_work_fn() then run after rds_rdma has been freed? It would also
be touching rds_ib_probe_pending.

> +
> +		rds_trans_put(trans);
> +		down_read(&rds_trans_sem);
>  	}
>  	up_read(&rds_trans_sem);
>  
> -	return ret;
> +	return NULL;
>  }

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net v6 2/2] net/rds: defer the probe cm_id destroy to rds_wq
  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
  0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03  3:38 UTC (permalink / raw)
  To: chenaibing; +Cc: achender, netdev, linux-kernel, kuba

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

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] The commit message says that above RDS_IB_MAX_PROBE_PENDING
  the check 'fails with -ENOMEM rather than returning a value that would…
- [Low] The new comment above struct rds_ib_probe_work in net/rds/ib.c
  says the probe runs 'while rds_trans_get_preferred() holds…

--

net/rds: defer the probe cm_id destroy to rds_wq

This patch moves the rdma_destroy_id() of the probe cm_id in
rds_ib_laddr_check_cm() onto rds_wq. This avoids a recursive handler_mutex
lockdep report on the passive connection path. A global counter caps pending
destroys at RDS_IB_MAX_PROBE_PENDING (64), and rds_ib_exit() flushes rds_wq
before the module goes away.

> diff --git a/net/rds/ib.c b/net/rds/ib.c
> index 4ea9838d090c3..624374ecf4fad 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
>  
> +/*
> + * The probe cm_id must not be destroyed from the caller's context:
> + * rds_ib_laddr_check() runs it while rdma_cm's handler_mutex is held
> + * (the passive connection path) or while rds_trans_get_preferred() holds
> + * rds_trans_sem, and rdma_destroy_id() takes handler_mutex again.  Queue
> + * the destruction on rds_wq, which runs without either lock.
> + */

[Severity: Low]
Is the rds_trans_sem part of this comment accurate? In this tree,
rds_trans_get_preferred() drops the semaphore before it calls
->laddr_check():

net/rds/transport.c:rds_trans_get_preferred() {
    ...
		/*
		 * ->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;
    ...
}

The SO_RDS_TRANSPORT path in rds_bind() doesn't take rds_trans_sem either.

The transport.c comment has the opposite problem. It says ->laddr_check()
destroys the rdma_cm id and takes handler_mutex, but with this patch the
destroy runs later on rds_wq.

Could both comments be updated so they describe the same locking rules for
->laddr_check()?

> +struct rds_ib_probe_work {
> +	struct work_struct work;
> +	struct rdma_cm_id *cm_id;
> +};
> +
> +static atomic_t rds_ib_probe_pending = ATOMIC_INIT(0);
> +#define RDS_IB_MAX_PROBE_PENDING 64
> +
> +static void rds_ib_probe_work_fn(struct work_struct *work)
> +{
> +	struct rds_ib_probe_work *pw =
> +		container_of(work, struct rds_ib_probe_work, work);
> +
> +	rdma_destroy_id(pw->cm_id);
> +	kfree(pw);
> +	atomic_dec(&rds_ib_probe_pending);
> +}

[ ... ]

> @@ -414,11 +440,25 @@ static int rds_ib_laddr_check_cm(struct net *net, const struct in6_addr *addr,
>  	bool isv4;
>  
>  	isv4 = ipv6_addr_v4mapped(addr);
> +
> +	pw = kzalloc_obj(*pw);
> +	if (!pw)
> +		return -ENOMEM;
> +
> +	if (atomic_inc_return(&rds_ib_probe_pending) > RDS_IB_MAX_PROBE_PENDING) {
> +		atomic_dec(&rds_ib_probe_pending);
> +		kfree(pw);
> +		return -ENOMEM;
> +	}

[Severity: Medium]
The commit message says:

    above the bound the check fails with -ENOMEM rather than returning a
    value that would make rds_trans_get_preferred() fall back to another
    transport.

Does -ENOMEM actually prevent the fallback? rds_trans_get_preferred() only
checks for zero:

		if (trans->laddr_check(net, addr, scope_id) == 0)
			return trans;

		rds_trans_put(trans);
		down_read(&rds_trans_sem);

Any non-zero return, including -ENOMEM, moves on to the next registered
transport. RDS_TRANS_TCP comes after RDS_TRANS_IB, and
rds_tcp_laddr_check() returns 0 for any local address, IPoIB addresses
included.

rds_ib_probe_pending is also a single global counter that every caller
shares. Every call that reaches the cm path takes a slot. That covers every
IPv6 address and every IPv4 address that rds_ib_get_device() doesn't find,
including addresses that don't exist.

A slot is freed only when rds_ib_probe_work_fn() runs. rds_wq comes from
create_singlethread_workqueue("krdsd"), so those destroys wait behind all
other RDS work queued there. Nothing in net/rds/ requires a capability to
create AF_RDS sockets.

While more than 64 destroys are pending, an unrelated bind() seems to end up
like this:

  - Without SO_RDS_TRANSPORT, an IB address is silently bound to RDS/TCP,
    and rs->rs_transport keeps that value for the life of the socket. If
    rds_tcp isn't loaded, the bind fails with -EADDRNOTAVAIL.

  - With SO_RDS_TRANSPORT set to IB, rds_bind() returns -ENOPROTOOPT.

In both cases userspace never sees the -ENOMEM.

The loopback check in __rds_conn_create() also goes through this path:

	loop_trans = rds_trans_get_preferred(net, faddr, conn->c_dev_if);

Could that check give the wrong answer during the same window?

I wasn't able to confirm how easily more than 64 destroys can be kept
pending in practice. Still, before this patch the destroy was synchronous
and there was no shared budget.

Is it intended that one user can use up this cap and affect everyone else?
Should the commit message's explanation for returning -ENOMEM be corrected?

[ ... ]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03  3:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®