diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-07-30 18:43:47 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-07-30 11:42:21 -0600 |
commit | b2bd1cf99f3e7c8fbf12ea07af2c6998e1209e25 (patch) | |
tree | dc16e00563bdc1880c78dddfa067d78e10e11cbe | |
parent | 81b68a5ca0ab5d92229a7b76332b9ce88bd6dbd1 (diff) |
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 <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 11f4ab87e08f..6e2322525da6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7847,10 +7847,9 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx, clear_bit(0, &ctx->cq_check_overflow); ctx->rings->sq_flags &= ~IORING_SQ_CQ_OVERFLOW; } - spin_unlock_irq(&ctx->completion_lock); - WRITE_ONCE(ctx->rings->cq_overflow, atomic_inc_return(&ctx->cached_cq_overflow)); + spin_unlock_irq(&ctx->completion_lock); /* * Put inflight ref and overflow ref. If that's |