]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.16.4/rdma-ucma-don-t-allow-setting-rdma_option_ib_path-without-an-rdma-device.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.16.4 / rdma-ucma-don-t-allow-setting-rdma_option_ib_path-without-an-rdma-device.patch
1 From 8435168d50e66fa5eae01852769d20a36f9e5e83 Mon Sep 17 00:00:00 2001
2 From: Roland Dreier <roland@purestorage.com>
3 Date: Tue, 3 Apr 2018 15:33:01 -0700
4 Subject: RDMA/ucma: Don't allow setting RDMA_OPTION_IB_PATH without an RDMA device
5
6 From: Roland Dreier <roland@purestorage.com>
7
8 commit 8435168d50e66fa5eae01852769d20a36f9e5e83 upstream.
9
10 Check to make sure that ctx->cm_id->device is set before we use it.
11 Otherwise userspace can trigger a NULL dereference by doing
12 RDMA_USER_CM_CMD_SET_OPTION on an ID that is not bound to a device.
13
14 Cc: <stable@vger.kernel.org>
15 Reported-by: <syzbot+a67bc93e14682d92fc2f@syzkaller.appspotmail.com>
16 Signed-off-by: Roland Dreier <roland@purestorage.com>
17 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 drivers/infiniband/core/ucma.c | 3 +++
22 1 file changed, 3 insertions(+)
23
24 --- a/drivers/infiniband/core/ucma.c
25 +++ b/drivers/infiniband/core/ucma.c
26 @@ -1241,6 +1241,9 @@ static int ucma_set_ib_path(struct ucma_
27 if (!optlen)
28 return -EINVAL;
29
30 + if (!ctx->cm_id->device)
31 + return -EINVAL;
32 +
33 memset(&sa_path, 0, sizeof(sa_path));
34
35 sa_path.rec_type = SA_PATH_REC_TYPE_IB;