“3ae970a688f8f8a74d1b489b8646733a830c904b”上不存在“git@gitcode.net:openanolis/cloud-kernel.git”
提交 621fadc2 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

io_uring: don't take files/mm for a dead task

In rare cases a task may be exiting while io_ring_exit_work() trying to
cancel/wait its requests. It's ok for __io_sq_thread_acquire_mm()
because of SQPOLL check, but is not for __io_sq_thread_acquire_files().
Play safe and fail for both of them.

Cc: stable@vger.kernel.org # 5.5+
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 d434ab6d
无相关合并请求
...@@ -1106,6 +1106,9 @@ static void io_sq_thread_drop_mm_files(void) ...@@ -1106,6 +1106,9 @@ static void io_sq_thread_drop_mm_files(void)
static int __io_sq_thread_acquire_files(struct io_ring_ctx *ctx) static int __io_sq_thread_acquire_files(struct io_ring_ctx *ctx)
{ {
if (current->flags & PF_EXITING)
return -EFAULT;
if (!current->files) { if (!current->files) {
struct files_struct *files; struct files_struct *files;
struct nsproxy *nsproxy; struct nsproxy *nsproxy;
...@@ -1133,6 +1136,8 @@ static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx) ...@@ -1133,6 +1136,8 @@ static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx)
{ {
struct mm_struct *mm; struct mm_struct *mm;
if (current->flags & PF_EXITING)
return -EFAULT;
if (current->mm) if (current->mm)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部