Article View: linux.kernel.netdev
Article #26128Re: [PATCH net v6 1/2] net/rds: drop rds_trans_sem around laddr_check()
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 03:38
Date: Thu, 03 Dec 2026 03:38
154 lines
12731 bytes
12731 bytes
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
Technical Details
Message-ID:
<179626908850.3146.14670637682082504192@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.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-376263-linux-kernel-netdev=dewy.ruReferences:
<20261202024054.1945-2-chenaibing@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.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-376263-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v6 1/2] net/rds: drop rds_trans_sem around laddr_check() Date: Thu, 03 Dec 2026 03:38:08 +0000 Organization: Usenet Network Message-ID: <179626908850.3146.14670637682082504192@kernel.org> References: <20261202024054.1945-2-chenaibing@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2133362"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:GRQXrQDgogMZlpLs5uTrn80Fq+M= sha256:X5RN6zjas7+GmNk5bvTGN2KhDhckR+DXRP6UlUWpRVs= sha1:RNbQAakOTCb/vHVCbMtCAE3XP+k= sha256:Y7k2ZXUfH+i5Tyg9PKB/9KaFTYMqC06E9PVgEd03LBs= 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 F257011780A; Thu, 3 Dec 2026 06:38:37 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 flS11ZZFblYa; Thu, 3 Dec 2026 06:38:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376263-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 6E52B1177F9; Thu, 3 Dec 2026 06:38:25 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 74536218A9; Thu, 3 Dec 2026 03:38:15 +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=1796269095; b=pj5JPmzk+yFJr7z8pWKnaUUh9YIHtrtlDM4vWZDtF0LBmMkjcfNaB6g8D0lchFx+yV9p NqFpySBmxA/TzoO8p4WIoaFOZNpWXXC9fnRGpD6ZBSYWp0PY4W2V7N/w5wWUJj0BpwSWv VqsbdRjEHj4SKdNwUsO+26V1JHAX5k40BawwIQQe0VZo2mQfT7i34XRxP3uivBJ0nNtxZ a0gjWZr+Jk2KaSLGZGSl0Gb+KfVR1iVco3Mz6gO5G5yGVwa5Cf4a5k5i+9SvEqM28TMdZ GDNJDt8Yb6o7P+HHk4+aNjdckCIgRDoa3obbwR/hqTJmxTE3O+j3oYSpNduVPxnGXbQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796269095; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=APMPKaOQWAQjNOpwNudo3iJ00eYdbNDrwsdPC7ApbVs=; b=s+uQdSqhZi3xxyIO30Pc01dGkQJaGxh38mtPx/pNPKmL/4pV8molOxCUzRkTmXt9TeVV G0zieoh3rdsxLINtgr37RWYaTugyrJAyU3PFCTnvOwi7nGzVprXKkRw29ZcfZ99qU6mzf nGEqHD4M3ZoRbpIDOZFyOEKJ8FFwYA20MuBCTit7jBCHkUhzBR8pYkxdFftnYl/MrqkA4 //dwLoqAGl3tMe+ehFW5qgGqlUlIYL+aO6eLKEmwAuY7BGNb6JSmotTPydfRBebekF99Q c9m9IGNOHs1Q8qDpAl2geWZM6Q3Rb5DH38mM2qsDA3B10lgCBfoJ4I2tG9AjTr2zvGw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WdKy28FA; 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 4D57E606A338; Thu, 3 Dec 2026 03:38:15 +0000 (UTC) X-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=WdKy28FA X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796269089; b=5bb83LD7mQKEqQtsa2XdEP2/wRdQU5+Y6isnaxBJjCytu6sjSjPiIP+bph/5qMqMGEY2 PRx8MHckLrsI/T4UsqqexKBJxCLR/ysH7GpLByOb+NZM9mTJ17dqlvnAn5t0k7WiAiR8i LiBRIv1EK+Lpmebb/OwfNqkx7n43w2IQ+UVxJjdJCyAQf39fgw2rRSnRr9ps2yjcVRsx6 eE9G+wKWoShpXUcQ7dbfEEJs6WhE2OnRuVfT2g7JYr9RtrkdvLQM7TmrG7G0g06gAyLgb wyy8Y8c/1iGc4n93KxWBTxyFGW5XuiM8eM+bYOPEHSzH4+5CBgdOW7yUtEF1N6OlvVg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796269089; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=APMPKaOQWAQjNOpwNudo3iJ00eYdbNDrwsdPC7ApbVs=; b=vj+t6SUH1CkFWmO/GJ14qRRHQBuhdZFvNnITm/h+xgZ6cT8L4sICaZEPWh9m6vFHCdZa BzBrNw/OXcBMBCD/o7UggHFpnZ87h9+kqJuT0L+K8oyFwQ1WxZvUGEYNaxd8mNX+excsV mkd8ABNuOMfQFth34W2IBR/Ab1M+G2cJnioBsJRP2rmLmG1MFYyGCpMHNfoHPWGF3FVXQ 8PMSKT2Nr8PQFuzcuOL5jM6DnvuYxrrPqao980Fl9rVaANQElMZWFQxh0WeUVfLdZKEgl RGcdDH2kGjn614vpal78ZFIbnYERsutWZrQ8MwC+4Zh0PQBq7nx7nOfV7cR9zniGA+Q== X-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=WdKy28FA; arc=none smtp.remote-ip=100.103.45.18 X-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 6C7AD606A682; Thu, 3 Dec 2026 03:38:09 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0002C1F00896; Thu, 3 Dec 2026 03:38:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796269089; bh=APMPKaOQWAQjNOpwNudo3iJ00eYdbNDrwsdPC7ApbVs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=WdKy28FA9CoE1Y2wr7yXTDB8fQlvKRghzshMb0Foh5vpxe1GcT9udraAIbBFLEIUB rUoUS5dMxIStQGPH382tHpfSATRQ5ZwjoHBGOmE2eEfWE2KG5OSiLDm0GCB0GueylS QZcdZFozeEfLjC3dvGkD2lsWC3mp6NgiREA7NWdv3l8Fia0oumxcsG6kH4yQmPnOiX z6KguUoFG4CwsIv+TyCdhL/CGd3AmoCFAVwL6JHu8kQ7sawg1iW5xd/670vRpHz34j 4NHKFioBk4oWlrYDbR2a67LlX3pA0fu/4mVyG2b6KSbo4QWKpRGwJWBSKQi63N4TSV aQKaoYgZfuBtQ== X-Cc: achender@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org X-In-Reply-To: <20261202024054.1945-2-chenaibing@cmss.chinamobile.com> X-sashiko-severity: Medium 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