]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.33/rdma-ucma-check-that-device-exists-prior-to-accessing-it.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.33 / rdma-ucma-check-that-device-exists-prior-to-accessing-it.patch
1 From c8d3bcbfc5eab3f01cf373d039af725f3b488813 Mon Sep 17 00:00:00 2001
2 From: Leon Romanovsky <leonro@mellanox.com>
3 Date: Sun, 25 Mar 2018 11:39:05 +0300
4 Subject: RDMA/ucma: Check that device exists prior to accessing it
5
6 From: Leon Romanovsky <leonro@mellanox.com>
7
8 commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream.
9
10 Ensure that device exists prior to accessing its properties.
11
12 Reported-by: <syzbot+71655d44855ac3e76366@syzkaller.appspotmail.com>
13 Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
14 Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
15 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18 ---
19 drivers/infiniband/core/ucma.c | 6 ++++--
20 1 file changed, 4 insertions(+), 2 deletions(-)
21
22 --- a/drivers/infiniband/core/ucma.c
23 +++ b/drivers/infiniband/core/ucma.c
24 @@ -1335,7 +1335,7 @@ static ssize_t ucma_notify(struct ucma_f
25 {
26 struct rdma_ucm_notify cmd;
27 struct ucma_context *ctx;
28 - int ret;
29 + int ret = -EINVAL;
30
31 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
32 return -EFAULT;
33 @@ -1344,7 +1344,9 @@ static ssize_t ucma_notify(struct ucma_f
34 if (IS_ERR(ctx))
35 return PTR_ERR(ctx);
36
37 - ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
38 + if (ctx->cm_id->device)
39 + ret = rdma_notify(ctx->cm_id, (enum ib_event_type)cmd.event);
40 +
41 ucma_put_ctx(ctx);
42 return ret;
43 }