Skip to content

Commit

Permalink
io_uring: fix no lock protection for ctx->cq_extra
Browse files Browse the repository at this point in the history
[ Upstream commit e302f10 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Hao Xu authored and gregkh committed Mar 8, 2022
1 parent 384d1b1 commit 1bd12b7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/io_uring.c
Expand Up @@ -6573,11 +6573,14 @@ static bool io_drain_req(struct io_kiocb *req)
}

/* Still need defer if there is pending req in defer list. */
spin_lock(&ctx->completion_lock);
if (likely(list_empty_careful(&ctx->defer_list) &&
!(req->flags & REQ_F_IO_DRAIN))) {
spin_unlock(&ctx->completion_lock);
ctx->drain_active = false;
return false;
}
spin_unlock(&ctx->completion_lock);

seq = io_get_sequence(req);
/* Still a chance to pass the sequence check */
Expand Down

0 comments on commit 1bd12b7

Please sign in to comment.