Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] RDMA/mlx5: user-triggerable WARN_ON(!page_size) in
  alloc_cacheable_mr()
--

commit 3a4c35010e9f8b10e62196ece5aade6e6065212c
Author: Yishai Hadas <[email protected]>

RDMA/mlx5: Try pinned revocable dmabuf import by default

This commit attempts a pinned, revocable dma-buf attachment by default
when registering a dma-buf MR so that the mkey can be sized exactly,
falling back to a movable ODP import only when the exporter does not
grant it.

> diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
> index 3c59cfbbbd19f..0ba82356963dd 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
> @@ -443,7 +443,7 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd 
> *pd,
>       struct mlx5_ib_mr *mr;
>       unsigned long page_size;
>  
> -     if (umem->is_dmabuf)
> +     if (umem->is_dmabuf && !to_ib_umem_dmabuf(umem)->pinned)
>               page_size = mlx5_umem_dmabuf_default_pgsz(umem, iova);
>       else
>               page_size = mlx5_umem_mkc_find_best_pgsz(pd_to_mdev(pd), umem,

[Severity: Medium]
Can userspace trigger WARN_ON(!page_size) right below this when
registering a pinned dma-buf MR?

Previously all dma-buf MRs took the mlx5_umem_dmabuf_default_pgsz()
branch here and checked mlx5_umem_dmabuf_find_best_pgsz() later in
mlx5_ib_dmabuf_mr_update_pas(), which returns -EINVAL without a warning
when page_size is 0.  Now pinned dma-buf MRs call
mlx5_umem_mkc_find_best_pgsz() -> ib_umem_find_best_pgsz() in
alloc_cacheable_mr().  Because UVERBS_METHOD_REG_DMABUF_MR only checks
that offset and iova share the same sub-page alignment, a user-supplied
iova where iova + umem->length - 1 overflows u64 causes
ib_umem_find_best_pgsz() to return 0 and hit WARN_ON(!page_size).

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20261129-mlx5-pinned-revocable-dmabuf-v2-0-830a412a3...@nvidia.com?part=3

Reply via email to