From: sashiko-bot@kernel.org
To: "Yuho Choi" <oss.patchbox@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v1 4/4] net/mlx5: HWS, Don't free the send ring CQ buffer if destroying the CQ fails
Date: Sat, 17 Oct 2026 04:59:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-175297@kernel.org> (raw)
In-Reply-To: <20261016045849.813696-10-oss.patchbox@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mlx5: software UAF of embedded CQ struct when firmware destroy command fails
--
commit 46458ea83b82e1a1672d9e95c03b0f4bac750b05
Author: Yuho Choi <oss.patchbox@gmail.com>
net/mlx5: HWS, Don't free the send ring CQ buffer if destroying the CQ fails
hws_send_ring_close_cq() ignores the result of mlx5_core_destroy_cq()
and frees the CQ buffer and doorbell record with mlx5_wq_destroy()
anyway. If DESTROY_CQ fails, the CQ may still exist in firmware and
retain access to that memory after it has been returned to the
allocator.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> index df3b93499eebb..21e2d0a26e88a 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c
> @@ -1005,7 +1005,9 @@ static int hws_send_ring_open_cq(struct mlx5_core_dev *mdev,
>
> static void hws_send_ring_close_cq(struct mlx5hws_send_ring_cq *cq)
> {
> - mlx5_core_destroy_cq(cq->mdev, &cq->mcq);
> + /* A CQ that was not destroyed can still access its buffer, leak it */
> + if (mlx5_core_destroy_cq(cq->mdev, &cq->mcq))
> + return;
[Severity: High]
Does returning early here expose the software CQ structure to a use-after-free?
When mlx5_core_destroy_cq() fails, it skips synchronization and completion
wait for concurrent users of the software CQ:
drivers/net/ethernet/mellanox/mlx5/core/cq.c:mlx5_core_destroy_cq() {
...
err = mlx5_cmd_exec_in(dev, destroy_cq, in);
if (err)
return err;
synchronize_irq(cq->irqn);
mlx5_cq_put(cq);
wait_for_completion(&cq->free);
...
}
Because hws_send_ring_close_cq() now returns without any indication of failure,
its caller (mlx5hws_send_queues_close()) will proceed to unconditionally free
the array embedding the CQ structure:
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c:mlx5hws_send_queues_close() {
...
kfree(ctx->send_queue);
...
}
Since wait_for_completion() and synchronize_irq() were skipped, could an
executing concurrent EQ interrupt handler or async event handler still hold
a reference to mcq and access it after the send_queue array has been freed?
> mlx5_wq_destroy(&cq->wq_ctrl);
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016045849.813696-6-oss.patchbox@gmail.com?part=4
next prev parent reply other threads:[~2026-10-17 4:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 4:57 [PATCH net-next v1 0/4] net/mlx5: Don't free CQs whose destroy failed Yuho Choi
2026-10-16 4:57 ` [PATCH net-next v1 1/4] net/mlx5: Don't free the ASO CQ if destroying it fails Yuho Choi
2026-10-17 4:59 ` sashiko-bot
2026-10-16 4:57 ` [PATCH net-next v1 2/4] net/mlx5: Don't free the WC test " Yuho Choi
2026-10-17 4:59 ` sashiko-bot
2026-10-16 4:57 ` [PATCH net-next v1 3/4] net/mlx5: DR, Don't free the send ring " Yuho Choi
2026-10-17 4:59 ` sashiko-bot
2026-10-16 4:57 ` [PATCH net-next v1 4/4] net/mlx5: HWS, Don't free the send ring CQ buffer if destroying the CQ fails Yuho Choi
2026-10-17 4:59 ` sashiko-bot [this message]
2026-10-16 6:59 ` [PATCH net-next v1 0/4] net/mlx5: Don't free CQs whose destroy failed Junxian Huang
2026-10-16 13:30 ` Yuho Choi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-175297@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=oss.patchbox@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox