* [PATCH] io_uring/wait: clamp min_events as unsigned
@ 2026-11-24 5:54 Yichong Chen
0 siblings, 0 replies; only message in thread
From: Yichong Chen @ 2026-11-24 5:54 UTC (permalink / raw)
To: Jens Axboe, io-uring; +Cc: Pavel Begunkov, linux-kernel, Yichong Chen
io_cqring_wait() clamps min_events with min_t(int, ...), but
io_uring_enter() passes the u32 min_complete straight in. Anything above
INT_MAX is negative by then, so the clamp is a no-op and
io_should_wake() reads cq.tail + min_events as a positive distance from
cq.tail. The wait returns 0 with no events available instead of blocking
for the clamped count; min_complete = 0xffffffff returns immediately,
while 1 and INT_MAX block for the timeout as expected. Clamp as unsigned,
as io_iopoll_check() already does.
Fixes: 816619782bdc ("io_uring: move min_events sanitisation")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
io_uring/wait.c | 4 ++--
io_uring/wait.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/io_uring/wait.c b/io_uring/wait.c
index fb1c082993a7..074cdf073ca7 100644
--- a/io_uring/wait.c
+++ b/io_uring/wait.c
@@ -204,7 +204,7 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
* Wait until events become available, if we don't already have some. The
* application must reap them itself, as they reside on the shared cq ring.
*/
-int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
+int io_cqring_wait(struct io_ring_ctx *ctx, unsigned int min_events, u32 flags,
struct ext_arg *ext_arg)
{
struct io_wait_queue iowq;
@@ -212,7 +212,7 @@ int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
ktime_t start_time;
int ret, nr_wait;
- min_events = min_t(int, min_events, ctx->cq_entries);
+ min_events = min(min_events, ctx->cq_entries);
if (!io_allowed_run_tw(ctx))
return -EEXIST;
diff --git a/io_uring/wait.h b/io_uring/wait.h
index eb5ae8a6fc94..07e1e9ea03cd 100644
--- a/io_uring/wait.h
+++ b/io_uring/wait.h
@@ -38,7 +38,7 @@ struct ext_arg {
bool iowait;
};
-int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
+int io_cqring_wait(struct io_ring_ctx *ctx, unsigned int min_events, u32 flags,
struct ext_arg *ext_arg);
int io_run_task_work_sig(struct io_ring_ctx *ctx);
void io_cqring_do_overflow_flush(struct io_ring_ctx *ctx);
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 5:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 5:54 [PATCH] io_uring/wait: clamp min_events as unsigned Yichong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®