[PATCH rdma-next] RDMA/mlx4: Restrict external umem for CQ when copy_to_user() is used

Leon Romanovsky posted 1 patch 1 week, 1 day ago
drivers/infiniband/hw/mlx4/cq.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH rdma-next] RDMA/mlx4: Restrict external umem for CQ when copy_to_user() is used
Posted by Leon Romanovsky 1 week, 1 day ago
From: Leon Romanovsky <leonro@nvidia.com>

When the mlx4 firmware reports the MLX4_DEV_CAP_FLAG2_SW_CQ_INIT capability,
libmlx4 from the rdma-core package expects the driver to initialize memory
at the address provided in the buf_addr parameter of ucmd.

This behavior cannot be supported by any external umem implementation, so
restrict it accordingly.

Fixes: f45f195af521 ("RDMA/mlx4: Introduce a modern CQ creation interface")
Reported-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx4/cq.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index b391883aa4004..6fef3f1724eb9 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -173,6 +173,10 @@ int mlx4_ib_create_user_cq(struct ib_cq *ibcq,
 		goto err_cq;
 	}
 
+	if (ibcq->umem &&
+	    (dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SW_CQ_INIT))
+		return -EOPNOTSUPP;
+
 	buf_addr = (void *)(unsigned long)ucmd.buf_addr;
 
 	if (!ibcq->umem)

---
base-commit: 05eec2a60c7909acfbe5b6c5fbb64790d5a3ff1c
change-id: 20260325-fix-mlx4-external-umem-9e8214de61f0

Best regards,
--  
Leon Romanovsky <leonro@nvidia.com>

Re: [PATCH rdma-next] RDMA/mlx4: Restrict external umem for CQ when copy_to_user() is used
Posted by Leon Romanovsky 3 days, 9 hours ago
On Wed, 25 Mar 2026 20:16:03 +0200, Leon Romanovsky wrote:
> When the mlx4 firmware reports the MLX4_DEV_CAP_FLAG2_SW_CQ_INIT capability,
> libmlx4 from the rdma-core package expects the driver to initialize memory
> at the address provided in the buf_addr parameter of ucmd.
> 
> This behavior cannot be supported by any external umem implementation, so
> restrict it accordingly.
> 
> [...]

Applied, thanks!

[1/1] RDMA/mlx4: Restrict external umem for CQ when copy_to_user() is used
      https://git.kernel.org/rdma/rdma/c/1c47f6aa0a13d1

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>