Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 -1
+1 -1
io_uring/timeout.c
··· 130 130 u32 seq; 131 131 132 132 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); 134 134 135 135 list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) { 136 136 struct io_kiocb *req = cmd_to_io_kiocb(timeout);