Skip to content

Commit

Permalink
RDMA/ucma: Check that device exists prior to accessing it
Browse files Browse the repository at this point in the history
commit c8d3bcb upstream.

Ensure that device exists prior to accessing its properties.

Reported-by: <syzbot+71655d44855ac3e76366@syzkaller.appspotmail.com>
Fixes: 7521663 ("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: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
Leon Romanovsky authored and Ben Hutchings committed Jun 16, 2018
1 parent c8ca6d9 commit 6f55695
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,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;
Expand All @@ -1238,7 +1238,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;
}
Expand Down

0 comments on commit 6f55695

Please sign in to comment.