| @@ -677,16 +677,20 @@ static void __io_cqring_overflow_flush(struct io_ring_ctx *ctx) · 676 unmodified lines |
| 677 | 677 | io_cq_unlock_post(ctx); |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | +static void io_cqring_do_overflow_flush(struct io_ring_ctx *ctx) |
| 681 | +{ |
| 682 | + /* iopoll syncs against uring_lock, not completion_lock */ |
| 683 | + if (ctx->flags & IORING_SETUP_IOPOLL) |
| 684 | + mutex_lock(&ctx->uring_lock); |
| 685 | + __io_cqring_overflow_flush(ctx); |
| 686 | + if (ctx->flags & IORING_SETUP_IOPOLL) |
| 687 | + mutex_unlock(&ctx->uring_lock); |
| 688 | +} |
| 689 | + |
| 680 | 690 | static void io_cqring_overflow_flush(struct io_ring_ctx *ctx) |
| 681 | 691 | { |
| 682 | | − if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) { |
| 683 | | − /* iopoll syncs against uring_lock, not completion_lock */ |
| 684 | | − if (ctx->flags & IORING_SETUP_IOPOLL) |
| 685 | | − mutex_lock(&ctx->uring_lock); |
| 686 | | − __io_cqring_overflow_flush(ctx); |
| 687 | | − if (ctx->flags & IORING_SETUP_IOPOLL) |
| 688 | | − mutex_unlock(&ctx->uring_lock); |
| 689 | | − } |
| 692 | + if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) |
| 693 | + io_cqring_do_overflow_flush(ctx); |
| 690 | 694 | } |
| 691 | 695 | |
| 692 | 696 | void __io_put_task(struct task_struct *task, int nr) |
| @@ -2549,7 +2553,10 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, · 1856 unmodified lines |
| 2549 | 2553 | |
| 2550 | 2554 | trace_io_uring_cqring_wait(ctx, min_events); |
| 2551 | 2555 | do { |
| 2552 | | − io_cqring_overflow_flush(ctx); |
| 2556 | + if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) { |
| 2557 | + finish_wait(&ctx->cq_wait, &iowq.wq); |
| 2558 | + io_cqring_do_overflow_flush(ctx); |
| 2559 | + } |
| 2553 | 2560 | prepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq, |
| 2554 | 2561 | TASK_INTERRUPTIBLE); |
| 2555 | 2562 | ret = io_cqring_wait_schedule(ctx, &iowq, timeout); |
| @@ -4013,8 +4020,6 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, · 1457 unmodified lines |
| 4013 | 4020 | return -EEXIST; |
| 4014 | 4021 | |
| 4015 | 4022 | if (ctx->restricted) { |
| 4016 | | − if (opcode >= IORING_REGISTER_LAST) |
| 4017 | | − return -EINVAL; |
| 4018 | 4023 | opcode = array_index_nospec(opcode, IORING_REGISTER_LAST); |
| 4019 | 4024 | if (!test_bit(opcode, ctx->restrictions.register_op)) |
| 4020 | 4025 | return -EACCES; |
| @@ -4170,6 +4175,9 @@ SYSCALL_DEFINE4(io_uring_register, unsigned int, fd, unsigned int, opcode, · 149 unmodified lines |
| 4170 | 4175 | long ret = -EBADF; |
| 4171 | 4176 | struct fd f; |
| 4172 | 4177 | |
| 4178 | + if (opcode >= IORING_REGISTER_LAST) |
| 4179 | + return -EINVAL; |
| 4180 | + |
| 4173 | 4181 | f = fdget(fd); |
| 4174 | 4182 | if (!f.file) |
| 4175 | 4183 | return -EBADF; |