From: sashiko-bot@kernel.org
To: "Edward Srouji" <edwards@nvidia.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next 04/11] RDMA/mlx5: Select the core device through PD for QP commands
Date: Wed, 18 Nov 2026 14:04:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-221133@kernel.org> (raw)
In-Reply-To: <20261117-mlx5-sd-prep-v1-4-8efd124c7895@nvidia.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 2 related pre-existing issues it does not
introduce:
- [Critical] RDMA/mlx5: unhandled error in destroy_raw_packet_qp_rq()
causes use-after-free [1]
- [High] RDMA/mlx5: unchecked to_ib_qp_state() return in query_qp_attr()
[2]
--
commit c8de8977935b4bc94238c72869a744ae61d62546
Author: Akiva Goldberger <agoldberger@nvidia.com>
RDMA/mlx5: Select the core device through PD for QP commands
This commit introduces qp_to_mdev() to resolve the core device from a QP's
associated PD and updates QP, RQ, SQ, and DCT command helpers to obtain the
core device from the PD or caller.
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index da4e9a52d2f9b..2196e06f593e1 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
[ ... ]
> @@ -1526,17 +1525,16 @@ static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
> pas = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
> mlx5_ib_populate_pas(umem, page_size, pas, 0);
>
> - err = mlx5_core_create_rq_tracked(dev, in, inlen, &rq->base.mqp);
> + err = mlx5_core_create_rq_tracked(pd, in, inlen, &rq->base.mqp);
>
> kvfree(in);
>
> return err;
> }
>
> -static void destroy_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
> - struct mlx5_ib_rq *rq)
> +static void destroy_raw_packet_qp_rq(struct ib_pd *pd, struct mlx5_ib_rq *rq)
> {
> - mlx5_core_destroy_rq_tracked(dev, &rq->base.mqp);
> + mlx5_core_destroy_rq_tracked(pd, &rq->base.mqp);
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can ignoring the return
value of mlx5_core_destroy_rq_tracked() in destroy_raw_packet_qp_rq()
[1] cause a use-after-free?
When the firmware DESTROY_RQ command fails, mlx5_core_destroy_rq_tracked()
re-enables the resource and leaves &rq->base.mqp in dev->qp_table.tree:
drivers/infiniband/hw/mlx5/qpc.c:mlx5_core_destroy_rq_tracked() {
...
modify_resource_common_state(dev, rq, true);
ret = destroy_rq_tracked(pd_to_mdev(pd), rq->qpn, rq->uid);
if (ret) {
modify_resource_common_state(dev, rq, false);
return ret;
}
destroy_resource_common(dev, rq);
return 0;
}
Because destroy_raw_packet_qp_rq() drops that error, raw packet QP teardown
completes and frees the enclosing mlx5_ib_qp. If an asynchronous firmware
event later arrives for the undestroyed RQ, rsc_event_notifier() looks up
the dangling pointer in the radix tree and calls qp->event() on freed
memory.
[ ... ]
> @@ -5122,8 +5123,8 @@ static int query_qp_attr(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
> if (!outb)
> return -ENOMEM;
>
> - err = mlx5_core_qp_query(dev, &qp->trans_qp.base.mqp, outb, outlen,
> - false);
> + err = mlx5_core_qp_query(qp_to_mdev(qp), &qp->trans_qp.base.mqp, outb,
> + outlen, false);
> if (err)
> goto out;
[Severity: High]
This problem wasn't introduced by this patch, but can query_qp_attr() store
an invalid state in qp->state [2] and cause an out-of-bounds read
in ib_modify_qp_is_ok()?
Just below this call, query_qp_attr() assigns to_ib_qp_state() directly to
the u8 field qp->state:
drivers/infiniband/hw/mlx5/qp.c:query_qp_attr() {
...
qpc = MLX5_ADDR_OF(query_qp_out, outb, qpc);
qp->state = to_ib_qp_state(MLX5_GET(qpc, qpc, state));
...
}
For any hardware QPC state not handled in to_ib_qp_state() (such as
MLX5_QP_STATE_SUSPENDED), to_ib_qp_state() returns -1, which truncates to
255 in qp->state. A subsequent mlx5_ib_modify_qp() call without
IB_QP_CUR_STATE in attr_mask passes cur_state = qp->state (255) to
ib_modify_qp_is_ok(), indexing past the 7x7 qp_state_table[] array.
[1] https://sashiko.dev/#/bug/linux-314256a0-4860-4700-943f-7cc6aed26289
[2] https://sashiko.dev/#/bug/linux-05b234dc-14ed-449f-97cf-d7b4682a7a8d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-mlx5-sd-prep-v1-0-8efd124c7895@nvidia.com?part=4
next prev parent reply other threads:[~2026-11-18 14:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 14:01 [PATCH rdma-next 00/11] RDMA/mlx5: Preparation for SD support Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 01/11] RDMA/mlx5: Enforce dev/mdev naming for device pointers Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 02/11] RDMA/mlx5: Rename to_mdev() helpers that return an IB device Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 03/11] RDMA/mlx5: Select the PD and SRQ core device through the PD Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 04/11] RDMA/mlx5: Select the core device through PD for QP commands Edward Srouji
2026-11-18 14:04 ` sashiko-bot [this message]
2026-11-17 14:01 ` [PATCH rdma-next 05/11] RDMA/mlx5: Cache the MR core device and resolve the MW's via its PD Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 06/11] RDMA/mlx5: Select the AH core device through their PD Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 07/11] RDMA/mlx5: Select the QP core device through its PD Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 08/11] RDMA/mlx5: Resolve core device from ucontext for DEVX resources Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 09/11] RDMA/mlx5: Cache the CQ core device and resolve it via cq_to_mdev() Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 10/11] RDMA/mlx5: Resolve the bfreg UAR-index core device from the ucontext Edward Srouji
2026-11-18 14:04 ` sashiko-bot
2026-11-17 14:01 ` [PATCH rdma-next 11/11] RDMA/mlx5: Resolve UAR and mmap core devices via " Edward Srouji
2026-11-18 14:04 ` sashiko-bot
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-221133@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=edwards@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.