Skip to content

Commit ed65a4d

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/ucma: Fix use-after-free access in ucma_close
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: 7521663 ("RDMA/cma: Export rdma cm interface to userspace") Reported-by: <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Sean Hefty <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 2975d5d commit ed65a4d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/infiniband/core/ucma.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
497497
mutex_lock(&mut);
498498
idr_remove(&ctx_idr, ctx->id);
499499
mutex_unlock(&mut);
500+
mutex_lock(&file->mut);
501+
list_del(&ctx->list);
502+
mutex_unlock(&file->mut);
500503
kfree(ctx);
501504
return ret;
502505
}

0 commit comments

Comments
 (0)