Skip to content

Commit b140d94

Browse files
rolanddgregkh
authored andcommitted
RDMA/ucma: Don't allow setting RDMA_OPTION_IB_PATH without an RDMA device
commit 8435168 upstream. Check to make sure that ctx->cm_id->device is set before we use it. Otherwise userspace can trigger a NULL dereference by doing RDMA_USER_CM_CMD_SET_OPTION on an ID that is not bound to a device. Cc: <[email protected]> Reported-by: <[email protected]> Signed-off-by: Roland Dreier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 79fbd05 commit b140d94

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/infiniband/core/ucma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,9 @@ static int ucma_set_ib_path(struct ucma_context *ctx,
12411241
if (!optlen)
12421242
return -EINVAL;
12431243

1244+
if (!ctx->cm_id->device)
1245+
return -EINVAL;
1246+
12441247
memset(&sa_path, 0, sizeof(sa_path));
12451248

12461249
sa_path.rec_type = SA_PATH_REC_TYPE_IB;

0 commit comments

Comments
 (0)