summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorHao Xu <haoxu@linux.alibaba.com>2021-11-25 17:21:02 +0800
committerJens Axboe <axboe@kernel.dk>2021-11-25 09:00:42 -0700
commite302f1046f4c209291b07ff7bc4d15ca26891f16 (patch)
treefc871b3af2c22a0ae6cce0de9e2c685558442449 /fs/io_uring.c
parent5562a8d71aa32ea27133d8b10406b3dcd57c01a5 (diff)
downloadlinux-e302f1046f4c209291b07ff7bc4d15ca26891f16.tar.gz
linux-e302f1046f4c209291b07ff7bc4d15ca26891f16.tar.bz2
linux-e302f1046f4c209291b07ff7bc4d15ca26891f16.zip
io_uring: fix no lock protection for ctx->cq_extra
ctx->cq_extra should be protected by completion lock so that the req_need_defer() does the right check. Cc: stable@vger.kernel.org Signed-off-by: Hao Xu <haoxu@linux.alibaba.com> Link: https://lore.kernel.org/r/20211125092103.224502-2-haoxu@linux.alibaba.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index f666a0e7f5e8..ae9534382b26 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6537,12 +6537,15 @@ static __cold void io_drain_req(struct io_kiocb *req)
u32 seq = io_get_sequence(req);
/* Still need defer if there is pending req in defer list. */
+ spin_lock(&ctx->completion_lock);
if (!req_need_defer(req, seq) && list_empty_careful(&ctx->defer_list)) {
+ spin_unlock(&ctx->completion_lock);
queue:
ctx->drain_active = false;
io_req_task_queue(req);
return;
}
+ spin_unlock(&ctx->completion_lock);
ret = io_req_prep_async(req);
if (ret) {