Skip to content

Commit fb46d13

Browse files
jakemoronigregkh
authored andcommitted
RDMA/irdma: Prevent rereg_mr for non-mem regions
[ Upstream commit a846aec ] When a QP/CQ/SRQ is created, a two step process is used where the buffer is allocated in userspace and explicitly registered with the normal reg_mr mechanism prior to creating the actual QP/CQ/SRQ object. These special registrations are indicated via an ABI field so the driver knows that they do not have a valid mkey and to skip the actual CQP command submission. Since these are real MR objects from the core's perspective, it is possible for a user application to invoke rereg_mr on them and cause a real CQP op to be emitted with the zero-initialized mkey value of 0. Fix this by preventing rereg_mr on these special regions. Fixes: 5ac388d ("RDMA/irdma: Add support to re-register a memory region") Signed-off-by: Jacob Moroni <jmoroni@google.com> Reviewed-by: David Hu <xuehaohu@google.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0ccb86d commit fb46d13

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/infiniband/hw/irdma/verbs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,6 +3251,9 @@ static struct ib_mr *irdma_rereg_user_mr(struct ib_mr *ib_mr, int flags,
32513251
if (flags & ~(IB_MR_REREG_TRANS | IB_MR_REREG_PD | IB_MR_REREG_ACCESS))
32523252
return ERR_PTR(-EOPNOTSUPP);
32533253

3254+
if (iwmr->type != IRDMA_MEMREG_TYPE_MEM)
3255+
return ERR_PTR(-EINVAL);
3256+
32543257
ret = ib_umem_check_rereg(iwmr->region, flags, new_access);
32553258
if (ret)
32563259
return ERR_PTR(ret);

0 commit comments

Comments
 (0)