Skip to content

Commit 3431908

Browse files
committed
io_uring: check for valid register opcode earlier
We only check the register opcode value inside the restricted ring section, move it into the main io_uring_register() function instead and check it up front. Signed-off-by: Jens Axboe <[email protected]>
1 parent 23fffb2 commit 3431908

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

io_uring/io_uring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,8 +4020,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
40204020
return -EEXIST;
40214021

40224022
if (ctx->restricted) {
4023-
if (opcode >= IORING_REGISTER_LAST)
4024-
return -EINVAL;
40254023
opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
40264024
if (!test_bit(opcode, ctx->restrictions.register_op))
40274025
return -EACCES;
@@ -4177,6 +4175,9 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode,
41774175
long ret = -EBADF;
41784176
struct fd f;
41794177

4178+
if (opcode >= IORING_REGISTER_LAST)
4179+
return -EINVAL;
4180+
41804181
f = fdget(fd);
41814182
if (!f.file)
41824183
return -EBADF;

0 commit comments

Comments
 (0)