]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/ucma: Fix use-after-free access in ucma_close
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 19 Mar 2018 12:20:15 +0000 (14:20 +0200)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:33:56 +0000 (21:33 -0400)
[ Upstream commit ed65a4dc22083e73bac599ded6a262318cad7baf ]

The error in ucma_create_id() left ctx in the list of contexts belong
to ucma file descriptor. The attempt to close this file descriptor causes
to use-after-free accesses while iterating over such list.

Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
Reported-by: <syzbot+dcfd344365a56fbebd0f@syzkaller.appspotmail.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/infiniband/core/ucma.c

index 0ba965cb14ed7b8b87a176c1021b1d047961154b..f738ab1c65e61cf9eeb06e748c9b6235c5cb6e74 100644 (file)
@@ -411,6 +411,9 @@ err1:
        mutex_lock(&mut);
        idr_remove(&ctx_idr, ctx->id);
        mutex_unlock(&mut);
+       mutex_lock(&file->mut);
+       list_del(&ctx->list);
+       mutex_unlock(&file->mut);
        kfree(ctx);
        return ret;
 }