Skip to content

Commit f9309dc

Browse files
axboegregkh
authored andcommitted
io_uring: check for valid register opcode earlier
[ Upstream commit 3431908 ] 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>
1 parent 4df413d commit f9309dc

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
@@ -10895,8 +10895,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
1089510895
return -ENXIO;
1089610896

1089710897
if (ctx->restricted) {
10898-
if (opcode >= IORING_REGISTER_LAST)
10899-
return -EINVAL;
1090010898
opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
1090110899
if (!test_bit(opcode, ctx->restrictions.register_op))
1090210900
return -EACCES;
@@ -11028,6 +11026,9 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode,
1102811026
long ret = -EBADF;
1102911027
struct fd f;
1103011028

11029+
if (opcode >= IORING_REGISTER_LAST)
11030+
return -EINVAL;
11031+
1103111032
f = fdget(fd);
1103211033
if (!f.file)
1103311034
return -EBADF;

0 commit comments

Comments
 (0)