Skip to content

Commit d434ab6

Browse files
isilenceaxboe
authored andcommitted
io_uring: drop mm and files after task_work_run
__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: [email protected] # 5.9+ Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d9d0521 commit d434ab6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/io_uring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7056,6 +7056,7 @@ static int io_sq_thread(void *data)
70567056

70577057
if (sqt_spin || !time_after(jiffies, timeout)) {
70587058
io_run_task_work();
7059+
io_sq_thread_drop_mm_files();
70597060
cond_resched();
70607061
if (sqt_spin)
70617062
timeout = jiffies + sqd->sq_thread_idle;
@@ -7093,6 +7094,7 @@ static int io_sq_thread(void *data)
70937094
}
70947095

70957096
io_run_task_work();
7097+
io_sq_thread_drop_mm_files();
70967098

70977099
if (cur_css)
70987100
io_sq_thread_unassociate_blkcg();

0 commit comments

Comments
 (0)