Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Edward Srouji" <edwards@nvidia.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next 08/11] RDMA/mlx5: Resolve core device from ucontext for DEVX resources
Date: Wed, 18 Nov 2026 14:04:18 +0000	[thread overview]
Message-ID: <sashiko-outbox-221137@kernel.org> (raw)
In-Reply-To: <20261117-mlx5-sd-prep-v1-8-8efd124c7895@nvidia.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] RDMA/mlx5: type confusion in
  UVERBS_HANDLER(MLX5_IB_METHOD_DM_MAP_OP_ADDR)() [1]
--

commit 9b620675534530ff6a87e491bd8226b49883a88b
Author: Akiva Goldberger <agoldberger@nvidia.com>

RDMA/mlx5: Resolve core device from ucontext for DEVX resources

This commit introduces a uctx_to_mdev() helper to resolve the mlx5_core_dev
from the user context for DEVX resources and removes redundant mdev
pointers from struct devx_umem and struct mlx5_ib_pp.

[ ... ]

> diff --git a/drivers/infiniband/hw/mlx5/dm.c b/drivers/infiniband/hw/mlx5/dm.c
> index fbb46d821865b..31a7c0f72b40f 100644
> --- a/drivers/infiniband/hw/mlx5/dm.c
> +++ b/drivers/infiniband/hw/mlx5/dm.c
> @@ -209,6 +209,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DM_MAP_OP_ADDR)(
>  {
>  	struct ib_uobject *uobj = uverbs_attr_get_uobject(
>  		attrs, MLX5_IB_ATTR_DM_MAP_OP_ADDR_REQ_HANDLE);
> +	struct mlx5_ib_ucontext *c = to_mucontext(uobj->context);
>  	struct mlx5_ib_dev *dev = to_dev(uobj->context->device);
>  	struct ib_dm *ibdm = uobj->object;
>  	struct mlx5_ib_dm_memic *dm = to_memic(ibdm);
> @@ -223,7 +224,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DM_MAP_OP_ADDR)(
>  	if (op >= BITS_PER_TYPE(u32))
>  		return -EOPNOTSUPP;
>  
> -	if (!(MLX5_CAP_DEV_MEM(dev->mdev, memic_operations) & BIT(op)))
> +	if (!(MLX5_CAP_DEV_MEM(uctx_to_mdev(c), memic_operations) & BIT(op)))
>  		return -EOPNOTSUPP;
>  
>  	mutex_lock(&dm->ops_xa_lock);

[Severity: High]
This problem wasn't introduced by this patch, but can
UVERBS_HANDLER(MLX5_IB_METHOD_DM_MAP_OP_ADDR)() cause type confusion when
called on a non-MEMIC DM handle [1]?

The handler casts ibdm to struct mlx5_ib_dm_memic via to_memic() without
verifying that to_mdm(ibdm)->type is MLX5_IB_UAPI_DM_TYPE_MEMIC.  When
userspace allocates a software ICM object such as
MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM, handle_alloc_dm_sw_icm() allocates
the smaller struct mlx5_ib_dm_icm instead, so accessing dm->ops_xa_lock,
dm->ops, and dm->ref writes past the end of the allocation and corrupts
adjacent slab memory.

[1] https://sashiko.dev/#/bug/linux-56314797-6963-404a-8cb9-efc7a99eb571

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-mlx5-sd-prep-v1-0-8efd124c7895@nvidia.com?part=8

  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
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 [this message]
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-221137@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox