From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796316044; b=OUp7gzpH73/Zifze37HW28vq+bAajXjPexnW+u+KlhqetNd7U4yoEzoe43Mc8kpb3/tN t3TsWKXSdiIfpM/pgfiMfbnk/QrOeM2yX989wl2uWSXmCAKlSTppVfOLQozrouCg/U6Md u/Vr3p8oEqPGNI+5B7Umat1Yqj5Rb6X+rVVvdV+q1RGDDmnPectCUunj4yv7sxd7O4o8v wixd1sjlCgJOlqFgmujQY/E8JTg15WiCfOM9Td8DchgNy4BtOs8rwmsCCS2qwOvd4zVSF RdRT6HLeyprPfMwdGwYHBDIKr5BgMOch3djCo6L9P8UIrcV25w5VfTroQJnKu0RR03A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796316044; h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=oWrPnRRLvhJCS9rph2zFiKa1U2EBOzSzBn6MwQHBtQU=; b=Qz3ZTn8QQaWTh9Tr2Lvvir6d7Xr950hQou811tMirUA+83Q4HyIEvqG2zDhc6tZffH3+ VQ5jwCg/nFjXRSsLA4cc5hrFZ77WNqBPYqYRJBc98eCAKy7cvPi8tHNHXtFUwih/5c80O tAqV+6ucCPil88Uz3zFcgGW9awqGUR81DUZKgvjAXNKNWXCIn6XVCh1QgkFdagXfmGc83 ha53Cs6YjUBbufHTXVqC5YtlX0H2CyshxFEV6cyZSAr3RKxx19gemWQS29+aBFKdTh2IH oDeERtp7AgO/FW4Yq8UD4VoNf1frJC/Gazv8Bn8UhnuFAkYzwYJw7AKrFpcfklHBHOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZV+QxeO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD297606A322; Thu, 3 Dec 2026 16:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iZV+QxeO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 024D91F000C1; Thu, 3 Dec 2026 16:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796316044; bh=oWrPnRRLvhJCS9rph2zFiKa1U2EBOzSzBn6MwQHBtQU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=iZV+QxeOhtJ4ITP18G3tbL1Pawp7bnUBTmbkPvZgeXLoQSBkap6Yt6pSsI8ijYrJ/ stRLXvH/S3sYWp0bSxUBpVWNJzABEanOJrkObsEyRnk9UJVRL8xKWuOkMm/iQYEsQn c8uX8QYeeg5I8x2Zj2zKjEpEFU30EuoXQCwjqJa0RCOwRYf6A+dV2nmGekmSAb+oQZ Z5atnTTVGlJBo2EJaa2HNtvg2rBdZbEl1mtkwWT527XalvhzYaJD0pRs4cmOe3VcXa i03viEKr7N6MbR57f7c9o//Xr8JvJ/bXC5XFAHwlguVLxiu1ceXe6lH809aloS/4DA 33L/LsXEX/K0g== Message-ID: <6f68f3e15dcbe159ccb4503f27329de05c125047.camel@kernel.org> Subject: Re: [PATCH net v6 0/2] net/rds: fix the probe cm_id lock ordering From: Allison Henderson To: Aibing Chen Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 09:40:43 -0700 In-Reply-To: <20261202024054.1945-1-chenaibing@cmss.chinamobile.com> References: <20261202024054.1945-1-chenaibing@cmss.chinamobile.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Wed, 2026-12-02 at 10:40 +0800, Aibing Chen wrote: > syzbot reported a circular locking dependency between rds_trans_sem and > rdma_cm's handler_mutex: >=20 > 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) >=20 > 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(). >=20 > 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. Hi Aibing, Thanks for the follow up and the rxe testing. The sashiko findings on both patches are valid, but I think we're getting closer, and I think your testing points at a simpler fix. Both reports come from the same call of __rds_conn_create() calling rds_trans_get_preferred() from inside an rdma_cm handler. But all we really need it for here is deciding whether faddr is local. So I think if we just hoist that logic out of rds_trans_get_preferred() and make a helper that checks directly instead of asking the transports, then both reports go away. Something like: #include =20 ... static bool rds_conn_addr_is_local(struct net *net, const struct in6_addr *addr, int dev_if) { bool ret =3D false; if (ipv6_addr_v4mapped(addr)) { if (*(u8 *)&addr->s6_addr32[3] =3D=3D IN_LOOPBACKNET) return true; return inet_addr_type(net, addr->s6_addr32[3]) =3D=3D RTN_L= OCAL; } if (ipv6_addr_loopback(addr)) return true; #if IS_ENABLED(CONFIG_IPV6) if (ipv6_mod_enabled()) { struct net_device *dev =3D NULL; rcu_read_lock(); if (dev_if) dev =3D dev_get_by_index_rcu(net, dev_if); if (!dev_if || dev) ret =3D ipv6_chk_addr(net, addr, dev, 0); rcu_read_unlock(); } #endif return ret; }=20 and then in __rds_conn_create(): - loop_trans =3D rds_trans_get_preferred(net, faddr, conn->c_dev_if); - if (loop_trans) { - rds_trans_put(loop_trans); + if (rds_conn_addr_is_local(net, faddr, conn->c_dev_if)) { conn->c_loopback =3D 1; That should get us the same check rds_tcp_laddr_check() does, but without taking rds_trans_sem under handler_mutex. So if we do this, we would only need this one patch in place of the other two. Please re-run your rxe setup with lockdep, ideally with active and passive connections, plus a bind() to an address that isn't on an RDMA device. Also cc'ing stable is fine since this is pretty small, but we should leave a note for stable maintainers below the --- that stable trees where IPv6 ca= n still be a module would need "depends on IPV6 || !IPV6" on CONFIG_RDS sinc= e this fix uses ipv6_chk_addr(). Thanks again for working on this! Allison pw-bot: cr >=20 > 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()): >=20 > 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 >=20 > this series: no lockdep report at all in the same run. >=20 > 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=3D1) and tested on rxe only. >=20 > 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. >=20 > 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. >=20 > v4 and earlier: > - deferred rdma_destroy_id() to a workqueue and bounded the backlog. >=20 > Reported-by: syzbot+ccdb5058c3df2d94811c@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3Dccdb5058c3df2d94811c > Suggested-by: Allison Henderson > Link: https://lore.kernel.org/all/d83709308a038467b3a4849d814978b84328d2b= c.camel@kernel.org/ > Fixes: ec16227e1414 ("RDS/IB: Infiniband transport") > Cc: stable@vger.kernel.org > Signed-off-by: Aibing Chen >=20 > Aibing Chen (2): > net/rds: drop rds_trans_sem around laddr_check() > net/rds: defer the probe cm_id destroy to rds_wq >=20 > net/rds/ib.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++= -- > net/rds/transport.c | 24 +++++++++++++++------- > 2 files changed, 67 insertions(+), 7 deletions(-) >=20