Skip to content

Commit be7cab4

Browse files
isilenceaxboe
authored andcommitted
io_uring: protect mem region deregistration
io_create_region_mmap_safe() protects publishing of a region against concurrent mmap calls, however we should also protect against it when removing a region. There is a gap io_register_mem_region() where it safely publishes a region, but then copy_to_user goes wrong and it unsafely frees the region. Cc: stable@vger.kernel.org Fixes: 087f997 ("io_uring/memmap: implement mmap for regions") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 927069c commit be7cab4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

io_uring/register.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ static int io_register_mem_region(struct io_ring_ctx *ctx, void __user *uarg)
613613
if (ret)
614614
return ret;
615615
if (copy_to_user(rd_uptr, &rd, sizeof(rd))) {
616+
guard(mutex)(&ctx->mmap_lock);
616617
io_free_region(ctx, &ctx->param_region);
617618
return -EFAULT;
618619
}

0 commit comments

Comments
 (0)