diff options
| author | Jens Axboe <axboe@kernel.dk> | 2025-09-18 10:21:14 -0600 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-09-25 11:00:09 +0200 |
| commit | abc9f859a9ea3d24ccaab2a2f4b1850084d6900f (patch) | |
| tree | 37f99fa24f7379e1ac2cf4b7896fb646d8bb002a /io_uring/io_uring.c | |
| parent | c8e69b783bc47ad64a22d1acdd8240b593d58b92 (diff) | |
| download | linux-abc9f859a9ea3d24ccaab2a2f4b1850084d6900f.tar.gz linux-abc9f859a9ea3d24ccaab2a2f4b1850084d6900f.tar.bz2 linux-abc9f859a9ea3d24ccaab2a2f4b1850084d6900f.zip | |
io_uring: include dying ring in task_work "should cancel" state
Commit 3539b1467e94336d5854ebf976d9627bfb65d6c3 upstream.
When running task_work for an exiting task, rather than perform the
issue retry attempt, the task_work is canceled. However, this isn't
done for a ring that has been closed. This can lead to requests being
successfully completed post the ring being closed, which is somewhat
confusing and surprising to an application.
Rather than just check the task exit state, also include the ring
ref state in deciding whether or not to terminate a given request when
run from task_work.
Cc: stable@vger.kernel.org # 6.1+
Link: https://github.com/axboe/liburing/discussions/1459
Reported-by: Benedek Thaler <thaler@thaler.hu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring/io_uring.c')
| -rw-r--r-- | io_uring/io_uring.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index d18985476654..07a5824ad98d 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1459,8 +1459,10 @@ static void io_req_task_cancel(struct io_kiocb *req, struct io_tw_state *ts) void io_req_task_submit(struct io_kiocb *req, struct io_tw_state *ts) { - io_tw_lock(req->ctx, ts); - if (unlikely(io_should_terminate_tw())) + struct io_ring_ctx *ctx = req->ctx; + + io_tw_lock(ctx, ts); + if (unlikely(io_should_terminate_tw(ctx))) io_req_defer_failed(req, -EFAULT); else if (req->flags & REQ_F_FORCE_ASYNC) io_queue_iowq(req); |
