Skip to content

Commit 621fadc

Browse files
isilenceaxboe
authored andcommitted
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: [email protected] # 5.5+ Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d434ab6 commit 621fadc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/io_uring.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,9 @@ static void io_sq_thread_drop_mm_files(void)
11061106

11071107
static int __io_sq_thread_acquire_files(struct io_ring_ctx *ctx)
11081108
{
1109+
if (current->flags & PF_EXITING)
1110+
return -EFAULT;
1111+
11091112
if (!current->files) {
11101113
struct files_struct *files;
11111114
struct nsproxy *nsproxy;
@@ -1133,6 +1136,8 @@ static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx)
11331136
{
11341137
struct mm_struct *mm;
11351138

1139+
if (current->flags & PF_EXITING)
1140+
return -EFAULT;
11361141
if (current->mm)
11371142
return 0;
11381143

0 commit comments

Comments
 (0)