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 d5740621fb40d604a240c4d889b540a19d43d88d 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 dma-buf MRs so the mkey can be sized exactly, falling back to movable ODP dma-buf import when the exporter does not support it. > diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c > index 4bd911e0596c6..55e6d8656692e 100644 > --- a/drivers/infiniband/hw/mlx5/mr.c > +++ b/drivers/infiniband/hw/mlx5/mr.c > @@ -430,7 +430,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(dev, umem, iova, [Severity: Medium] Can an unprivileged user trigger the WARN_ON(!page_size) right below this in alloc_cacheable_mr() when registering a pinned dmabuf MR? UVERBS_METHOD_REG_DMABUF_MR only checks that offset and iova share the same sub-page alignment, and ib_umem_dmabuf_get_pinned_revocable_and_lock() validates offset + size against the dmabuf size without checking iova. Previously, dmabuf MRs used mlx5_umem_dmabuf_default_pgsz() here and checked mlx5_umem_dmabuf_find_best_pgsz() later in mlx5_ib_dmabuf_mr_update_pas(), which returns -EINVAL without warning when page_size is 0. With pinned dmabuf MRs now calling mlx5_umem_mkc_find_best_pgsz() -> ib_umem_find_best_pgsz() in alloc_cacheable_mr(), a user-supplied iova where iova + length - 1 overflows u64 causes ib_umem_find_best_pgsz() to return 0 and hit WARN_ON(!page_size) (likewise if KSM alignment constraints clear the page-size bitmap). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20261128-mlx5-pinned-revocable-dmabuf-v1-0-a4cde143a...@nvidia.com?part=3
