Commit 8d894ade authored by Li Lingfeng's avatar Li Lingfeng Committed by Jialin Zhang
Browse files

Revert "[Backport] io_uring: don't keep looping for more events if we can't flush overflow"

Offering: HULK
hulk inclusion
category: feature
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I6BTWC



-------------------------------

This reverts commit da4cb346.

We need to apply patch 788d0824269bef (io_uring: import 5.15-stable
io_uring) to move io_uring to separate directory and solve
the problem of CVE-2023-0240.
This patch can be reverted since patch 788d0824269bef contains it.

Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarWang Weiyang <wangweiyang2@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 2334b1a9
Loading
Loading
Loading
Loading
+3 −11
Original line number Diff line number Diff line
@@ -1718,22 +1718,18 @@ static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force,
	return cqe != NULL;
}

static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force,
static void io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force,
				     struct task_struct *tsk,
				     struct files_struct *files)
{
	bool ret = true;

	if (test_bit(0, &ctx->cq_check_overflow)) {
		/* iopoll syncs against uring_lock, not completion_lock */
		if (ctx->flags & IORING_SETUP_IOPOLL)
			mutex_lock(&ctx->uring_lock);
		ret = __io_cqring_overflow_flush(ctx, force, tsk, files);
		__io_cqring_overflow_flush(ctx, force, tsk, files);
		if (ctx->flags & IORING_SETUP_IOPOLL)
			mutex_unlock(&ctx->uring_lock);
	}

	return ret;
}

static void __io_cqring_fill_event(struct io_kiocb *req, long res,
@@ -7035,11 +7031,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
	iowq.nr_timeouts = atomic_read(&ctx->cq_timeouts);
	trace_io_uring_cqring_wait(ctx, min_events);
	do {
		/* if we can't even flush overflow, don't wait for more */
		if (!io_cqring_overflow_flush(ctx, false, NULL, NULL)) {
			ret = -EBUSY;
			break;
		}
		io_cqring_overflow_flush(ctx, false, NULL, NULL);
		prepare_to_wait_exclusive(&ctx->wait, &iowq.wq,
						TASK_INTERRUPTIBLE);
		/* make sure we run task_work before checking for signals */