diff options
author | Jens Axboe | 2022-12-23 06:37:08 -0700 |
---|---|---|
committer | Greg Kroah-Hartman | 2023-01-12 12:02:41 +0100 |
commit | 8b2de52126612b6d99f637292fc3aaceb42efc8a (patch) | |
tree | f1349eaf043a5f59fee7e116823a85cb5444e14d /io_uring | |
parent | 9c152189a7e85dac1f759d6ba95f877af91ccf8c (diff) |
io_uring: check for valid register opcode earlier
[ Upstream commit 343190841a1f22b96996d9f8cfab902a4d1bfd0e ]
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 <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring')
-rw-r--r-- | io_uring/io_uring.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 71f1cabb9f3d..1bc68dfda340 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3897,8 +3897,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, return -EEXIST; if (ctx->restricted) { - if (opcode >= IORING_REGISTER_LAST) - return -EINVAL; opcode = array_index_nospec(opcode, IORING_REGISTER_LAST); if (!test_bit(opcode, ctx->restrictions.register_op)) return -EACCES; @@ -4054,6 +4052,9 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode, long ret = -EBADF; struct fd f; + if (opcode >= IORING_REGISTER_LAST) + return -EINVAL; + f = fdget(fd); if (!f.file) return -EBADF; |