summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2018-03-25 11:39:05 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-08 14:26:28 +0200
commit4fbf77d7a9fed2f53d0e77cd959987b977f13dec (patch)
tree19487c8677eefbe71b79904deb808b127fe9ffd6
parent4dba68fd1dfefc4dfbf3f6f5fcda99c13668c671 (diff)
downloadlinux-stable-4fbf77d7a9fed2f53d0e77cd959987b977f13dec.tar.gz
linux-stable-4fbf77d7a9fed2f53d0e77cd959987b977f13dec.tar.bz2
linux-stable-4fbf77d7a9fed2f53d0e77cd959987b977f13dec.zip
RDMA/ucma: Check that device exists prior to accessing it
commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream. Ensure that device exists prior to accessing its properties. Reported-by: <syzbot+71655d44855ac3e76366@syzkaller.appspotmail.com> Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/infiniband/core/ucma.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index 87f5f35e0793..6cd51274ba21 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -1335,7 +1335,7 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
{
struct rdma_ucm_notify cmd;
struct ucma_context *ctx;
- int ret;
+ int ret = -EINVAL;
if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
return -EFAULT;
@@ -1344,7 +1344,9 @@ static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
if (IS_ERR(ctx))
return PTR_ERR(ctx);
- ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
+ if (ctx->cm_id->device)
+ ret = rdma_notify(ctx->cm_id, (enum ib_event_type)cmd.event);
+
ucma_put_ctx(ctx);
return ret;
}