Article View: linux.kernel.netdev
Article #12568Re: [PATCH rdma-next 16/23] RDMA/mlx5: Ignore completion events for a CQ without a handler
From: netdev-bot+sashiko
Date: Sat, 07 Nov 2026 20:25
Date: Sat, 07 Nov 2026 20:25
115 lines
12353 bytes
12353 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท 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).
- [High] The fix leaves a memory-ordering race on comp_handler.
--
RDMA/mlx5: Ignore completion events for a CQ without a handler
This patch makes mlx5_ib_cq_comp() skip the comp_handler call when no
handler is set. The case it targets is devr->c0, which is never armed, but
a hostile NIC in adversarial mode can still raise a completion event for
it.
> diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
> index 5cc86c3f93f3e..f955eb762051d 100644
> --- a/drivers/infiniband/hw/mlx5/cq.c
> +++ b/drivers/infiniband/hw/mlx5/cq.c
> @@ -46,7 +46,12 @@ static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq, struct mlx5_eqe *eqe)
> {
> struct ib_cq *ibcq = &to_mibcq(cq)->ibcq;
>
> - ibcq->comp_handler(ibcq, ibcq->cq_context);
> + /*
> + * A CQ created without a handler (devr->c0) is never armed, but a
> + * hostile NIC can still raise a completion event for it.
> + */
> + if (ibcq->comp_handler)
> + ibcq->comp_handler(ibcq, ibcq->cq_context);
[Severity: High]
For devr->c0 this check is enough, because comp_handler stays NULL for
that CQ. Is it also enough for the CQs set up by __ib_alloc_cq()?
The companion commit "RDMA/core: Set the CQ comp_handler after its poll
context is set up" relies on this NULL check as a "poll context ready"
gate. Neither side of that gate has any ordering, though.
On the writer side, the CQ can be reached from the EQ interrupt once
create_cq() puts it in eq->cq_table.tree. The handler is published later
with a plain store:
drivers/infiniband/core/cq.c:__ib_alloc_cq() {
...
ret = dev->ops.create_cq(cq, &cq_attr, NULL);
...
case IB_POLL_SOFTIRQ:
comp_handler = ib_cq_completion_softirq;
irq_poll_init(&cq->iop, IB_POLL_BUDGET_IRQ, ib_poll_handler);
break;
case IB_POLL_WORKQUEUE:
case IB_POLL_UNBOUND_WORKQUEUE:
comp_handler = ib_cq_completion_workqueue;
INIT_WORK(&cq->work, ib_cq_poll_work);
cq->comp_wq = ...
...
cq->comp_handler = comp_handler;
...
}
On the reader side, mlx5_eq_comp_int() gets the CQ with mlx5_eq_cq_get(),
which is an RCU radix_tree_lookup() plus a refcount increment. That orders
against the tree insertion, but not against the stores made after it.
mlx5_ib_cq_comp() then loads comp_handler twice with plain loads.
Adversarial mode is enabled when cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)
is true. That includes arm64 Realm and pKVM guests, and those CPUs are
weakly ordered. Take the UMR CQ, which mlx5r_umr_resource_init() allocates
with IB_POLL_SOFTIRQ.
Could another CPU see comp_handler == ib_cq_completion_softirq before the
memset(), INIT_LIST_HEAD(), weight and poll stores from irq_poll_init()
are visible? If so, irq_poll_sched() would link iop onto the per-CPU list.
The delayed irq_poll_init() stores could then overwrite iop->state and
iop->list while iop is still on that list.
Possible results are per-CPU list corruption, irq_poll_softirq() spinning
on a stale entry, or a NULL iop->poll call. For the workqueue cases, the
compiler is also free to move the plain comp_handler store ahead of the
INIT_WORK() and cq->comp_wq stores. That could lead to queue_work() with a
NULL workqueue or an uninitialized work item.
The wmb() in the later ib_req_notify_cq() only helps if the device waits
for the arm doorbell, and a hostile device does not wait.
Would it make sense to publish the handler with:
smp_store_release(&cq->comp_handler, comp_handler);
in __ib_alloc_cq(), and read it once in mlx5_ib_cq_comp() with:
ib_comp_handler h = smp_load_acquire(&ibcq->comp_handler);
if (h)
h(ibcq, ibcq->cq_context);
That also removes the double fetch. KCSAN would likely report the current
plain check against the plain store as a data race. Later patches in the
series do not change this code.
> }
>
> static void mlx5_ib_cq_event(struct mlx5_core_cq *mcq, enum mlx5_event type)
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261103163949.1554-1-yishaih%40nvidia.com
Technical Details
Message-ID:
<179408310019.994134.8139150984682840933@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358512-linux-kernel-netdev=dewy.ruReferences:
<20261103163949.1554-17-yishaih@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358512-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH rdma-next 16/23] RDMA/mlx5: Ignore completion events for a CQ without a handler Date: Sat, 07 Nov 2026 20:25:00 +0000 Organization: Usenet Network Message-ID: <179408310019.994134.8139150984682840933@kernel.org> References: <20261103163949.1554-17-yishaih@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4186328"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:xgLyCqiZN0yLQa2nLBnJQACtS1Q= sha256:u2uGNLZv2KmCXKDS7No3QdaWC3aDQrovpHXhpqdYsDI= sha1:tbFWvBVtnKuHnTNjG/9Ldgx2qXA= sha256:+w6o9cb0EWwVn6e2kF4Q2WLybD+bumAddoROkLLaWlE= 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 B3859113499; Sat, 7 Nov 2026 23:27:04 +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 H1M0J_vbGQEs; Sat, 7 Nov 2026 23:27:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358512-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id D704B1134A0; Sat, 7 Nov 2026 23:26:51 +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 8CBA4838FB; Sat, 7 Nov 2026 20:25:24 +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=1794083108; b=UKb/Ey7m+07doSarSgPUfD7ieytZoWNoNSIAKz0J0ZV/qNm7oi9WBpPrpyBHqArWstPD MozH+L/nsD3wIsJvDlBhOFyjdlbvgbXjqsLSmr4Ijw8qjSjjMPoe6M63sP2emx+LbEScI Wl9wa8dV5bPOyr7EXOCEhdB1qZzsfyB7Vul6L85ISTu47Bvxc2HXM5mjWHDwJkw3+x1Rm oo4VqYzOqiquiVQ+oiNrobqIpUrT0GB8p6vkBzEnvOpXyXHvl0OjanxqXUj57a5dd6ayd ejJJFzZq03XJOxilRPLGG2Wt1rblaexOWwb/5AXNzQyOgDMrIphTG9weYpQYQKKWYng== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794083108; 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=hAxrrIcR8kFy2gsceeU205RpPHqOi1H7v/dWyGTpYxY=; b=knrU8QfqzjD7vk+bm3J6qrxm/rjwD/tWz35TEv2XkuLCNHeg8cg8OxjBHvGRfxtCJIjg t1IRxdsMRjZywOl0ZCpglMkLVdsra62Tcbo8brMs+WMWXl/X+ONle+PUxt7iwsUoZQU/j qXqZ/sXSwAfNh+Nls3IsVLEe2jwCj7zBzivc9UcYfge6Oil8IJ8l0kah3pQAi58HXB28w QhXRSc7egjw5R0veFN2L6pNV2KQ1M0cHbe9ZZiuxvjBIVjVQCf5kA5b/j1/JfRGjKVliq GlIi3/BmdW2nLZR+Xp0ochKceiGdfmSncU9VZbuOBtLlOYi+gpKjlbpmsOcGKUsRONw== 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=NuVbsSZn; 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 87201606EE99; Sat, 7 Nov 2026 20:25:08 +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=NuVbsSZn 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=1794083102; b=X5X75YWxrJI7iN+bFsBwJzMgOAoY3wZbky7irpzzmHScyyC3OaozLYnCCm/oI700S2os GrCi/nM/pZvuA9fQ1ZBWcyFf/Lljn28S+Al1NoMpamgxAmoxeVvTCJsvWcLwqr+34jZ7i OEDIxPiLY353DqyhLTDfKAw3stsW4KhX/CRDZDBUI8p9hkHq9Z7tI2L3flgxh2cA/DrYb +/l+2GHssg/yQllydCdnpmmZXFFO7UOoKhATa1NV+wiYYZFS2juiyLBjsgV8+F8yqZ0XS Zm+euDVon/xPicxPEEayWn6UmvArWs4V63nFKBaYgy2RkzcX7By6BFa4ARPOqNlm++A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794083102; 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=hAxrrIcR8kFy2gsceeU205RpPHqOi1H7v/dWyGTpYxY=; b=ih3TDKoZcrB4y1Pipd9kec0OGpijzYrJsNvxEi0KcnHGbKJwkV2LTfbRVUqXQkt4OoYD QreO00PlKzTudlsxf9nHj2iYoYhjJGu+DdJIW4NOqesMB2OS/OYQC92zbRiCB3gW9gjEV w5BNN+RRZKk4Buk5U7j/P+vy05sZT35D8V/EwAYIsONBDdS8IkFBdbHBGxy3brrn1Whug N8dj6objzj+Hg3132KthKDM48JcH5eZnNFTcg05fQ5lQguALWU5uUi/Xqu1MPxv9m+oem Ki13RXwfupiAbIsrBp3pyY5jNjKo3oGGhB6Uh0DVfTHVd+719EJlPrRbJqjaLIbT34w== 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=NuVbsSZn; 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 98BB9606A32F; Sat, 7 Nov 2026 20:25:01 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F7BC1F008A1; Sat, 7 Nov 2026 20:25:00 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794083101; bh=hAxrrIcR8kFy2gsceeU205RpPHqOi1H7v/dWyGTpYxY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NuVbsSZneZIFgRql+d1Rn2GBYJawSe+9wASghXgzUEqq7jPAyAZaG4SbUlOU2AJ4z 9AccY7j4qTFLOzpALyYR8bOd18+TOvM1LDAI56tWEn4bdHauWnPPofnO1o+HNNm+2v uZ/RJXf+qXaKHIEE1VsmB50LZhJD9shrYSo8kEVmZxlt6Dy7uKA2dooQMNK5onchst sGgj5ZLX2o5rIVuAmq86RtNBM6DotzEkgAoIif6M47JOu3H54OoQNiRrv56CI1No68 HtCPDD9t/wPtfW77wXu1cGfOMvJ3QNvG7xYYa9S+KZSTWjGdbNp0Lgrte1Rqg9niaU Dd4zf8SiS1biQ== X-Cc: jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, davem@davemloft.net, andrew+netdev@lunn.ch, dtatulea@nvidia.com, moshe@nvidia.com, maorg@nvidia.com X-In-Reply-To: <20261103163949.1554-17-yishaih@nvidia.com> X-sashiko-severity: High 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