io_uring: fix no lock protection for ctx->cq_extra

[ Upstream commit e302f1046f ]

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>
This commit is contained in:
Hao Xu 2021-11-25 17:21:02 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 384d1b1138
Коммит 1bd12b7aae
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -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 */