summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2018-04-03 15:33:01 -0700
committerSasha Levin <alexander.levin@microsoft.com>2018-05-22 21:36:33 -0400
commit7b662d281baa686269f6d256a7867880eeb4c3ee (patch)
treede8abbc78375d2fc284924d2f204d8828e086305
parent63df8d82efef1be1d8f6c55d8582e4aeaf7ab800 (diff)
RDMA/ucma: Don't allow setting RDMA_OPTION_IB_PATH without an RDMA device
[ Upstream commit 8435168d50e66fa5eae01852769d20a36f9e5e83 ] 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: <stable@vger.kernel.org> Reported-by: <syzbot+a67bc93e14682d92fc2f@syzkaller.appspotmail.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
-rw-r--r--drivers/infiniband/core/ucma.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index aff5f5837372..f7973c0b8a93 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1139,6 +1139,9 @@ static int ucma_set_ib_path(struct ucma_context *ctx,
if (!optlen)
return -EINVAL;
+ if (!ctx->cm_id->device)
+ return -EINVAL;
+
memset(&sa_path, 0, sizeof(sa_path));
sa_path.vlan_id = 0xffff;