Skip to contentSkip to conversation

io_uring: fix bad free in io_sqe_files_register

PATCH In review Dan Robertson 2 participants 4 messages Apr 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover io_uring: fix bad free in io_sqe_files_register

If io_sqe_files_register is called but returns EFAULT or EBADF the io_ring_ctx user_files member is cleaned up, but a following call to io_sqe_files_unregister will double-free.

Dan Robertson (1):
io_uring: fix bad free in io_sqe_files_register

 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 io_uring: fix bad free in io_sqe_files_register

Given bad input to the io_uring_register syscall the io_ring_ctx user_files member is cleaned up in io_sqe_files_register, but a following call to io_uring_release will result in a double-free.

---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)
fs/io_uring.c +1 -0
index bbdbd56cf2ac..07d6ef195d05 100644
@@ -2215,6 +2215,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
 			fput(ctx->user_files[i]);
 
 		kfree(ctx->user_files);
+		ctx->user_files = NULL;
 		ctx->nr_user_files = 0;
 		return ret;
 	}
Signature · 1 line
2.21.0
maintainer
#2 lore raw
Quoted 3 lines · Dan Robertson

Given bad input to the io_uring_register syscall the io_ring_ctx user_files member is cleaned up in io_sqe_files_register, but a following call to io_uring_release will result in a double-free.

This was already fixed for -rc5 last week, in this commit:

commit 25adf50fe25d506d3fc12070a5ff4be858a1ac1b

Author: Jens Axboe <[email protected]>
Date:   Wed Apr 3 09:52:40 2019 -0600

io_uring: fix double free in case of fileset regitration failure

Signature · 1 line
Jens Axboe