🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26666

[PATCH net v7 0/3] net/rds: fix the probe cm_id lock ordering

#26666
From: Aibing Chen
Date: Fri, 04 Dec 2026 02:22
91 lines
12741 bytes
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 2 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().

Dropping the semaphore means rds_trans_unregister() no longer waits for
an in-flight ->laddr_check(), so the module reference has to be
sufficient on its own.  It is not while the module is being initialized:
rds_rdma_init() calls rds_ib_init(), which registers the transport, and
only then creates the RDMA CM listener; if that fails, rds_ib_exit()
unregisters again, and do_init_module() frees the module without waiting
for a reference taken on a module in MODULE_STATE_COMING.  Patch 1
registers the transport only once the listener is up, so a transport is
never reachable from a module that can still fail to initialize.

Patch 3 handles the second problem on the same path: 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() 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 recursive
locking once the semaphore cycle is gone.  Queue that destroy on rds_wq.

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.

v7:
- add patch 1: the module reference taken once rds_trans_sem is dropped
  cannot pin a module in MODULE_STATE_COMING that do_init_module() is
  about to free; move the transport registration after the listener.
- patch 3: describe the -ENOMEM bound as bounding the queue of pending
  destroys, and note that a failing laddr_check() is handled like any
  other unsuccessful check.
- fix the comments that still described the old locking.

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.

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 (3):
  net/rds: register the IB transport last
  net/rds: drop rds_trans_sem around laddr_check()
  net/rds: defer the probe cm_id destroy to rds_wq

 net/rds/ib.c             | 56 ++++++++++++++++++++++++++++++++++++----
 net/rds/rdma_transport.c |  7 ++++-
 net/rds/transport.c      | 25 +++++++++++++-----
 3 files changed, 75 insertions(+), 13 deletions(-)
Technical Details
Message-ID: <20261204022245.381-1-chenaibing@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-nl.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376980-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-nl.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376980-linux-kernel-netdev=dewy.ru
From: chenaibing@cmss.chinamobile.com (Aibing Chen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v7 0/3] net/rds: fix the probe cm_id lock ordering
Date: Fri,  4 Dec 2026 10:22:41 +0800
Organization: Usenet Network
Message-ID: <20261204022245.381-1-chenaibing@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2655227"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:opJ6TiEZDDfRunhWYZoAJhsY4Gk= sha256:maOtwRO93Qv6fCawe2+NPUezkQnKSRVrvBxdakj9Hjo=
	sha1:JJDoR21KCgW7PF//MxYuuqR91SY= sha256:v5EZN2dagwAM3g6VeNOf0Duvs6GdfSjDIs+bRdN7NfQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CC33D117AB6; Fri,  4 Dec 2026 05:23:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.098
X-Spam-Status: No, score=-3.098 tagged_above=-9999 required=6.31
	tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id yE5UzmjnGD1y;
	Fri,  4 Dec 2026 05:23:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376980-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id F336B117AB3; Fri,  4 Dec 2026 05:23:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8CD4C26950; Fri,  4 Dec 2026 02:23:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796350981;
	b=dd5NMVfrKPMbhqUBuH2bO1J/JDhs1uzZeV7XD15qsJwIE7A8BYFlZXIU7PceZKS5javg
	 GzL5DZBrx7ojvpJA4RwlzTcnsDO5d5mx3RuvTldpH+KDU73v03xvGfy55AjzRevmTUNNC
	 04Sygk6rDyrG+Jv3aF+mJ6C9WDRHCz7lb2FyBx4fUMCsxuDGQGvwhe69GpLjGHTj8ymAb
	 /g0oYE4JhsQuluugXCXUWBrrDZTgMWZyCNR+0gkYJZQHtrTrCR0U1aooW888GhnKUOJRj
	 rvfYWamtiHTFHOgiSFSnLz/FtsRy3eotzCA/86fGobVxRTmuQgalwUXlX0DYVKhx2EQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796350981;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Bo759M9MfJlgg9ql9Lbr11P0bJO+6OecWrtIqv1G8dU=;
	b=bHzs4pwtxFmxISPLSirqPcG6tlYhqp3mV46sCzCaeWa45/6DdGNj6genMm0Bf0cbeXav
	 UXhhQ7UkheHNBGM23wZebjBaFdNNgcI/izZG3MB3e3dXb+Wyt8FR4jB1YuF9v96oPrPtZ
	 wPYoain3GqkbnBlObAt6ytM9L533sOG3V2m8YzwTqkoLKxvsIWSzgCcTGh2di3ty50br/
	 nMD1mCC/Avif5sw+f4L4wnH+QSu9wjVIFtplLVSFGVWyJLOJI1udKuaRjP24e036kJfYh
	 tx/n/Qy3WtIGAz3XGX4iaPJPgHYXmyuCMC1P/hxwSc9yFQfw5KxDTQBLCDmd/MosXxw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=rBpPLOKq;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C2C2606A6A0;
	Fri,  4 Dec 2026 02:23:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=rBpPLOKq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796350980;
	b=IiBnkGGOLwN6HD8TTVcszTkNb8AltIy5e7Pbe8P65SmBoiGO4c7FmC7vudFlQ6XsUrnc
	 JtuaEaH1G/hubgdwgDRHEUTLAdBZvqeSlsTb4gSQDCRYpyCirPK6QYAeE8Qck2fj8lfta
	 PR9Xiailkr2jTvbIjy/2utel5PSZvM6zYeo9RK6Y7ussFTohtzlzKIKXxoSj56BTh6cTx
	 hqETOApfQZSlAfXgnBNwn07f3pbBXHHX7eqBCOrXODtXgjqIiZ5oaReGfxdaozib9NGe+
	 5oGyJBujyv3k83/4uPN7ZKqT2LAYwKFLhnb0O9VJGX0J4rqW+KsZ8d8/ddz4Zm+7bmw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796350980;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding;
	bh=Bo759M9MfJlgg9ql9Lbr11P0bJO+6OecWrtIqv1G8dU=;
	b=oSj0AfHOza9GDpl6SBXCJ65ppEMxSN/RJnwnYQOG1JLI3Uq4u+lgbQs/o9m7psxzwZGy
	 Z9k3JgJa88EtDsE5Ug8gQ5Pl5/zmr5cC/c5uu0/zhcsiOwLPGbk4eNpfXpPB8e873u028
	 ohrHETsg1CTOgyIAnwZbYMgkdRcvUwaxFT7dPZqAfqTEjJV+Qs/G9pW5N11UAoSCEMBIE
	 3LWoBiM7YTCU6mbXf3kVnh+3shiyvwwMUC7vjUqf9XKjOKKaiuMV7PGjeXuRter6x2pw/
	 0SzyGRoX+GDKLiqiRDqPuIC5KAYw+H0IMdqTfwutqMpHVNBibPl9m07BEZqkPwdBcTQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=rBpPLOKq;
	arc=none smtp.remote-ip=111.22.67.151
X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E93B606A33B;
	Fri,  4 Dec 2026 02:22:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E93B606A33B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=rBpPLOKqROnYXdpuKWM38IgNnhC8AYbWF/47OaiB34UJUpoiD7hG+t0+vkEclUDYo5MBY7a8MXbQ0
	 qzJJelNG3zVdL8aW9rXLzGmQAHF21qJRsDlz2BKKqUkOaEo8udg5ex430QnpIq2v0WwtzGH7fhDjJs
	 SEjdiQT2QGkVvMVk=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app02-12002 (RichMail) with SMTP id 2ee26b1223f8e44-dbd2d;
	Fri, 04 Dec 2026 10:22:48 +0800 (CST)
X-RM-TRANSID: 2ee26b1223f8e44-dbd2d
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from FHD-W7400297 (unknown[10.55.1.70])
	by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16b1223f64fe-846c3;
	Fri, 04 Dec 2026 10:22:48 +0800 (CST)
X-RM-TRANSID: 2ee16b1223f64fe-846c3
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.50.1.windows.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list