Re: [PATCH] RDMA/mlx5: Validate the DEVX command length before setting umem valid bits
From: Leon Romanovsky
Date: Mon Nov 16 2026 - 08:39:41 EST
On Sun, Nov 15, 2026 at 04:46:58PM +0000, Hungyu Lin wrote:
> devx_set_umem_valid() sets the umem valid bits in the command supplied
> by user space, at offsets that depend on the opcode. The DEVX object
> create and modify methods only require the command to be as long as
> general_obj_in_cmd_hdr, which is 16 bytes, so when the command is
> shorter than the layout of its opcode the bits are written past the end
> of the command buffer. For MLX5_CMD_OP_CREATE_QP the modified words are
> 232 and 268 bytes into the command.
>
> The command buffer is allocated with uverbs_alloc(), so the write lands
> either past the internal buffer of the bundle, which normally lives on
> the stack of ib_uverbs_cmd_verbs(), or past a separate allocation.
>
> Fail with -EINVAL when the command does not cover the layout that is
> modified, as devx_handle_mkey_create() already does for
> MLX5_CMD_OP_CREATE_MKEY.
>
> Fixes: ba1a057da2f1 ("IB/mlx5: Set valid umem bit on DEVX")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
> ---
> drivers/infiniband/hw/mlx5/devx.c | 44 ++++++++++++++++++++++++++++++++-------
> 1 file changed, 37 insertions(+), 7 deletions(-)
Thanks for the report. We are aware of this issue and are working on a fix.
Unfortunately, the proposed solution would require DEVX userspace applications
to provide a size that is already known to the kernel, preventing us from
extending these structures in the future.
Thanks