提交 801dd57b 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

io_uring: cancel by ->task not pid

For an exiting process it tries to cancel all its inflight requests. Use
req->task to match such instead of work.pid. We always have req->task
set, and it will be valid because we're matching only current exiting
task.

Also, remove work.pid and everything related, it's useless now.
Reported-by: NEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 4dd2824d
...@@ -90,7 +90,6 @@ struct io_wq_work { ...@@ -90,7 +90,6 @@ struct io_wq_work {
const struct cred *creds; const struct cred *creds;
struct fs_struct *fs; struct fs_struct *fs;
unsigned flags; unsigned flags;
pid_t task_pid;
}; };
static inline struct io_wq_work *wq_next_work(struct io_wq_work *work) static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
......
...@@ -1063,8 +1063,6 @@ static inline void io_req_work_grab_env(struct io_kiocb *req, ...@@ -1063,8 +1063,6 @@ static inline void io_req_work_grab_env(struct io_kiocb *req,
} }
spin_unlock(&current->fs->lock); spin_unlock(&current->fs->lock);
} }
if (!req->work.task_pid)
req->work.task_pid = task_pid_vnr(current);
} }
static inline void io_req_work_drop_env(struct io_kiocb *req) static inline void io_req_work_drop_env(struct io_kiocb *req)
...@@ -7451,11 +7449,12 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx, ...@@ -7451,11 +7449,12 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
} }
} }
static bool io_cancel_pid_cb(struct io_wq_work *work, void *data) static bool io_cancel_task_cb(struct io_wq_work *work, void *data)
{ {
pid_t pid = (pid_t) (unsigned long) data; struct io_kiocb *req = container_of(work, struct io_kiocb, work);
struct task_struct *task = data;
return work->task_pid == pid; return req->task == task;
} }
static int io_uring_flush(struct file *file, void *data) static int io_uring_flush(struct file *file, void *data)
...@@ -7467,11 +7466,8 @@ static int io_uring_flush(struct file *file, void *data) ...@@ -7467,11 +7466,8 @@ static int io_uring_flush(struct file *file, void *data)
/* /*
* If the task is going away, cancel work it may have pending * If the task is going away, cancel work it may have pending
*/ */
if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) { if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
void *data = (void *) (unsigned long)task_pid_vnr(current); io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, current, true);
io_wq_cancel_cb(ctx->io_wq, io_cancel_pid_cb, data, true);
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册