Skip to content

Commit 2f076a4

Browse files
calebsanderaxboe
authored andcommitted
io_uring/rsrc: respect submitter_task in io_register_clone_buffers()
io_ring_ctx's enabled with IORING_SETUP_SINGLE_ISSUER are only allowed a single task submitting to the ctx. Although the documentation only mentions this restriction applying to io_uring_enter() syscalls, commit d7cce96 ("io_uring: limit registration w/ SINGLE_ISSUER") extends it to io_uring_register(). Ensuring only one task interacts with the io_ring_ctx will be important to allow this task to avoid taking the uring_lock. There is, however, one gap in these checks: io_register_clone_buffers() may take the uring_lock on a second (source) io_ring_ctx, but __io_uring_register() only checks the current thread against the *destination* io_ring_ctx's submitter_task. Fail the IORING_REGISTER_CLONE_BUFFERS with -EEXIST if the source io_ring_ctx has a registered submitter_task other than the current task. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5d4c52b commit 2f076a4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

io_uring/rsrc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,10 +1300,17 @@ int io_register_clone_buffers(struct io_ring_ctx *ctx, void __user *arg)
13001300
if (src_ctx != ctx) {
13011301
mutex_unlock(&ctx->uring_lock);
13021302
lock_two_rings(ctx, src_ctx);
1303+
1304+
if (src_ctx->submitter_task &&
1305+
src_ctx->submitter_task != current) {
1306+
ret = -EEXIST;
1307+
goto out;
1308+
}
13031309
}
13041310

13051311
ret = io_clone_buffers(ctx, src_ctx, &buf);
13061312

1313+
out:
13071314
if (src_ctx != ctx)
13081315
mutex_unlock(&src_ctx->uring_lock);
13091316

0 commit comments

Comments
 (0)