From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E93B606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com 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 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 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 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 From: Aibing Chen To: Allison Henderson Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v7 0/3] net/rds: fix the probe cm_id lock ordering Date: Fri, 4 Dec 2026 10:22:41 +0800 Message-ID: <20261204022245.381-1-chenaibing@cmss.chinamobile.com> X-Mailer: git-send-email 2.50.1.windows.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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(-)