]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
IB/mlx5: Properly support implicit ODP rereg_mr
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 4 Jun 2026 01:27:42 +0000 (22:27 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 8 Jun 2026 17:32:42 +0000 (14:32 -0300)
Due to all the child mkeys in the implicit ODP configuration we cannot
change anything in place for the parent mkey. Instead the whole thing
needs to be rebuilt if any change is requested. If the user does not
specify a translation then force the implicit values which will then fall
through the logic into mlx5_ib_reg_user_mr() to allocate a completely new
MR.

Since implicit children were also touching the mr->pd, this removes
another case where the access was racy.

Fixes: ef3642c4f54d ("RDMA/mlx5: Fix error unwinds for rereg_mr")
Link: https://sashiko.dev/#/patchset/20260427-security-bug-fixes-v3-0-4621fa52de0e%40nvidia.com?part=4
Link: https://patch.msgid.link/r/3-v1-29ebd2c229b5+fd5-ib_mr_pd_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx5/mr.c

index e75a3aa3e2782a2f68860f6c57beeb17c95b0dbb..17902a643ce58d351eda3c4141c276d32401e0e6 100644 (file)
@@ -1188,6 +1188,21 @@ struct ib_mr *mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
        if (!(flags & IB_MR_REREG_PD))
                new_pd = ib_mr->pd;
 
+       if (mr->is_odp_implicit && !(flags & IB_MR_REREG_TRANS)) {
+               if (!(new_access_flags & IB_ACCESS_ON_DEMAND))
+                       return ERR_PTR(-EOPNOTSUPP);
+
+               /*
+                * Due to all the child mkeys we cannot actually change an
+                * implicit MR in place. If the user did not specify a new
+                * translation then force the fixed implicit MR values.
+                */
+               start = 0;
+               iova = 0;
+               length = U64_MAX;
+               flags |= IB_MR_REREG_TRANS;
+       }
+
        if (!(flags & IB_MR_REREG_TRANS)) {
                struct ib_umem *umem;