提交 7f7b2926 编写于 作者: P Pavel Begunkov 提交者: Zheng Zengkai

io_uring: drop mm and files after task_work_run

stable inclusion
from stable-5.10.9
commit f7f32822a44af3b09a1641d26803a8fea714ff88
bugzilla: 47457

--------------------------------

[ Upstream commit d434ab6d ]

__io_req_task_submit() run by task_work can set mm and files, but
io_sq_thread() in some cases, and because __io_sq_thread_acquire_mm()
and __io_sq_thread_acquire_files() do a simple current->mm/files check
it may end up submitting IO with mm/files of another task.

We also need to drop it after in the end to drop potentially grabbed
references to them.

Cc: stable@vger.kernel.org # 5.9+
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 14447cfe
......@@ -6841,6 +6841,7 @@ static int io_sq_thread(void *data)
if (ret & SQT_SPIN) {
io_run_task_work();
io_sq_thread_drop_mm();
cond_resched();
} else if (ret == SQT_IDLE) {
if (kthread_should_park())
......@@ -6855,6 +6856,7 @@ static int io_sq_thread(void *data)
}
io_run_task_work();
io_sq_thread_drop_mm();
if (cur_css)
io_sq_thread_unassociate_blkcg();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册