mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
UPSTREAM: io_uring: check for valid register opcode earlier
[ Upstream commit343190841a] 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. Change-Id: I4b5f782dad48eb0e7f04d5956cc087494e02b2ec Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org> Bug: 268174392 (cherry picked from commit78e8151f04) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
committed by
Treehugger Robot
parent
1b735b5eb2
commit
0dfe72e890
@@ -10815,8 +10815,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
|
|||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
if (ctx->restricted) {
|
if (ctx->restricted) {
|
||||||
if (opcode >= IORING_REGISTER_LAST)
|
|
||||||
return -EINVAL;
|
|
||||||
opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
|
opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
|
||||||
if (!test_bit(opcode, ctx->restrictions.register_op))
|
if (!test_bit(opcode, ctx->restrictions.register_op))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
@@ -10948,6 +10946,9 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode,
|
|||||||
long ret = -EBADF;
|
long ret = -EBADF;
|
||||||
struct fd f;
|
struct fd f;
|
||||||
|
|
||||||
|
if (opcode >= IORING_REGISTER_LAST)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
f = fdget(fd);
|
f = fdget(fd);
|
||||||
if (!f.file)
|
if (!f.file)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|||||||
Reference in New Issue
Block a user