diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-10-12 11:53:29 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-10-12 14:59:32 -0600 |
commit | ff7d2874b5e51d2bc056d60e06cee56403fe02ff (patch) | |
tree | f0954f0a22050c9d9b7a3a406c98d350a786517a | |
parent | 70b225d0a8ca1242e8a75ded86b806070ec71b2f (diff) |
io_uring: don't run task work on an exiting task
commit 6200b0ae4ea28a4bfd8eb434e33e6201b7a6a282 upstream.
This isn't safe, and isn't needed either. We are guaranteed that any
work we queue is on a live task (and will be run), or it goes to
our backup io-wq threads if the task is exiting.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index ebc3586b1879..d5d0d274e64a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1762,6 +1762,12 @@ static int io_put_kbuf(struct io_kiocb *req) static inline bool io_run_task_work(void) { + /* + * Not safe to run on exiting task, and the task_work handling will + * not add work to such a task. + */ + if (unlikely(current->flags & PF_EXITING)) + return false; if (current->task_works) { __set_current_state(TASK_RUNNING); task_work_run(); @@ -7791,6 +7797,8 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx, io_put_req(cancel_req); } + /* cancellations _may_ trigger task work */ + io_run_task_work(); schedule(); finish_wait(&ctx->inflight_wait, &wait); } |