Skip to content

Commit bee749b

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix files cancellation
io_uring_cancel_files()'s task check condition mistakenly got flipped. 1. There can't be a request in the inflight list without IO_WQ_WORK_FILES, kill this check to keep the whole condition simpler. 2. Also, don't call the function for files==NULL to not do such a check, all that staff is already handled well by its counter part, __io_uring_cancel_task_requests(). With that just flip the task check. Also, it iowq-cancels all request of current task there, don't forget to set right ->files into struct io_task_cancel. Fixes: c1973b3 ("io_uring: cancel only requests of current task") Reported-by: [email protected] Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ac0648a commit bee749b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/io_uring.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8688,15 +8688,14 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
86888688
struct files_struct *files)
86898689
{
86908690
while (!list_empty_careful(&ctx->inflight_list)) {
8691-
struct io_task_cancel cancel = { .task = task, .files = NULL, };
8691+
struct io_task_cancel cancel = { .task = task, .files = files };
86928692
struct io_kiocb *req;
86938693
DEFINE_WAIT(wait);
86948694
bool found = false;
86958695

86968696
spin_lock_irq(&ctx->inflight_lock);
86978697
list_for_each_entry(req, &ctx->inflight_list, inflight_entry) {
8698-
if (req->task == task &&
8699-
(req->work.flags & IO_WQ_WORK_FILES) &&
8698+
if (req->task != task ||
87008699
req->work.identity->files != files)
87018700
continue;
87028701
found = true;
@@ -8768,10 +8767,11 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
87688767

87698768
io_cancel_defer_files(ctx, task, files);
87708769
io_cqring_overflow_flush(ctx, true, task, files);
8771-
io_uring_cancel_files(ctx, task, files);
87728770

87738771
if (!files)
87748772
__io_uring_cancel_task_requests(ctx, task);
8773+
else
8774+
io_uring_cancel_files(ctx, task, files);
87758775

87768776
if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
87778777
atomic_dec(&task->io_uring->in_idle);

0 commit comments

Comments
 (0)