summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-01-04 20:36:35 +0000
committerJens Axboe <axboe@kernel.dk>2021-01-04 15:22:27 -0700
commit81b6d05ccad4f3d8a9dfb091fb46ad6978ee40e4 (patch)
tree436488ee88fa3340b70159db102520917de94cdb /fs
parentb1b6b5a30dce872f500dc43f067cba8e7f86fc7d (diff)
downloadlinux-81b6d05ccad4f3d8a9dfb091fb46ad6978ee40e4.tar.bz2
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index ca46f314640b..5be33fd8b6bc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2126,15 +2126,16 @@ static void io_req_task_cancel(struct callback_head *cb)
static void __io_req_task_submit(struct io_kiocb *req)
{
struct io_ring_ctx *ctx = req->ctx;
+ bool fail;
- if (!__io_sq_thread_acquire_mm(ctx) &&
- !__io_sq_thread_acquire_files(ctx)) {
- mutex_lock(&ctx->uring_lock);
+ fail = __io_sq_thread_acquire_mm(ctx) ||
+ __io_sq_thread_acquire_files(ctx);
+ mutex_lock(&ctx->uring_lock);
+ if (!fail)
__io_queue_sqe(req, NULL);
- mutex_unlock(&ctx->uring_lock);
- } else {
+ else
__io_req_task_cancel(req, -EFAULT);
- }
+ mutex_unlock(&ctx->uring_lock);
}
static void io_req_task_submit(struct callback_head *cb)