Skip to content

Commit

Permalink
io_uring: if we see flush on exit, cancel related tasks
Browse files Browse the repository at this point in the history
Ensure we match tasks that belong to a dead or dying task as well, as we
need to reap those in addition to those belonging to the exiting task.

Cc: [email protected] # 5.9+
Reported-by: Josef Grieb <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jan 25, 2021
1 parent 6ee1d74 commit 84965ff
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,12 @@ static bool io_match_task(struct io_kiocb *head,
{
struct io_kiocb *req;

if (task && head->task != task)
if (task && head->task != task) {
/* in terms of cancelation, always match if req task is dead */
if (head->task->flags & PF_EXITING)
return true;
return false;
}
if (!files)
return true;

Expand Down Expand Up @@ -9136,6 +9140,9 @@ static int io_uring_flush(struct file *file, void *data)
struct io_uring_task *tctx = current->io_uring;
struct io_ring_ctx *ctx = file->private_data;

if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
io_uring_cancel_task_requests(ctx, NULL);

if (!tctx)
return 0;

Expand Down

0 comments on commit 84965ff

Please sign in to comment.