Skip to content

Commit 42b12cb

Browse files
committed
io_uring/timeout: annotate data race in io_flush_timeouts()
syzbot correctly reports this as a KCSAN race, as ctx->cached_cq_tail should be read under ->uring_lock. This isn't immediately feasible in io_flush_timeouts(), but as long as we read a stable value, that should be good enough. If two io-wq threads compete on this value, then they will both end up calling io_flush_timeouts() and at least one of them will see the correct value. Reported-by: syzbot+6c48db7d94402407301e@syzkaller.appspotmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8661d0b commit 42b12cb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

io_uring/timeout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ __cold void io_flush_timeouts(struct io_ring_ctx *ctx)
130130
u32 seq;
131131

132132
raw_spin_lock_irq(&ctx->timeout_lock);
133-
seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);
133+
seq = READ_ONCE(ctx->cached_cq_tail) - atomic_read(&ctx->cq_timeouts);
134134

135135
list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) {
136136
struct io_kiocb *req = cmd_to_io_kiocb(timeout);

0 commit comments

Comments
 (0)