Skip to content

Commit 81b6d05

Browse files
isilenceaxboe
authored andcommitted
io_uring: synchronise IOPOLL on task_submit fail
io_req_task_submit() might be called for IOPOLL, do the fail path under uring_lock to comply with IOPOLL synchronisation based solely on it. Cc: stable@vger.kernel.org # 5.5+ Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b1b6b5a commit 81b6d05

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

fs/io_uring.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,15 +2126,16 @@ static void io_req_task_cancel(struct callback_head *cb)
21262126
static void __io_req_task_submit(struct io_kiocb *req)
21272127
{
21282128
struct io_ring_ctx *ctx = req->ctx;
2129+
bool fail;
21292130

2130-
if (!__io_sq_thread_acquire_mm(ctx) &&
2131-
!__io_sq_thread_acquire_files(ctx)) {
2132-
mutex_lock(&ctx->uring_lock);
2131+
fail = __io_sq_thread_acquire_mm(ctx) ||
2132+
__io_sq_thread_acquire_files(ctx);
2133+
mutex_lock(&ctx->uring_lock);
2134+
if (!fail)
21332135
__io_queue_sqe(req, NULL);
2134-
mutex_unlock(&ctx->uring_lock);
2135-
} else {
2136+
else
21362137
__io_req_task_cancel(req, -EFAULT);
2137-
}
2138+
mutex_unlock(&ctx->uring_lock);
21382139
}
21392140

21402141
static void io_req_task_submit(struct callback_head *cb)

0 commit comments

Comments
 (0)