Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aibing Chen" <chenaibing@cmss.chinamobile.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net v4] net/rds: defer CM id destruction to a workqueue
Date: Mon, 23 Nov 2026 14:52:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-229449@kernel.org> (raw)
In-Reply-To: <20261122145148.1250-1-chenaibing@cmss.chinamobile.com>

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

      reply	other threads:[~2026-11-23 14:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [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=sashiko-outbox-229449@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=chenaibing@cmss.chinamobile.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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