Skip to content

Commit b2bd1cf

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix racy overflow count reporting
All ->cq_overflow modifications should be under completion_lock, otherwise it can report a wrong number to the userspace. Fix it in io_uring_cancel_files(). Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 81b68a5 commit b2bd1cf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/io_uring.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7847,10 +7847,9 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
78477847
clear_bit(0, &ctx->cq_check_overflow);
78487848
ctx->rings->sq_flags &= ~IORING_SQ_CQ_OVERFLOW;
78497849
}
7850-
spin_unlock_irq(&ctx->completion_lock);
7851-
78527850
WRITE_ONCE(ctx->rings->cq_overflow,
78537851
atomic_inc_return(&ctx->cached_cq_overflow));
7852+
spin_unlock_irq(&ctx->completion_lock);
78547853

78557854
/*
78567855
* Put inflight ref and overflow ref. If that's

0 commit comments

Comments
 (0)