Skip to content

Commit 943ad0b

Browse files
isilenceaxboe
authored andcommitted
kernel: rerun task_work while freezing in get_signal()
io_uring can asynchronously add a task_work while the task is getting freezed. TIF_NOTIFY_SIGNAL will prevent the task from sleeping in do_freezer_trap(), and since the get_signal()'s relock loop doesn't retry task_work, the task will spin there not being able to sleep until the freezing is cancelled / the task is killed / etc. Run task_works in the freezer path. Keep the patch small and simple so it can be easily back ported, but we might need to do some cleaning after and look if there are other places with similar problems. Cc: [email protected] Link: systemd/systemd#33626 Fixes: 12db8b6 ("entry: Add support for TIF_NOTIFY_SIGNAL") Reported-by: Julian Orth <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Acked-by: Tejun Heo <[email protected]> Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/89ed3a52933370deaaf61a0a620a6ac91f1e754d.1720634146.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 0453aad commit 943ad0b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/signal.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,6 +2600,14 @@ static void do_freezer_trap(void)
26002600
spin_unlock_irq(&current->sighand->siglock);
26012601
cgroup_enter_frozen();
26022602
schedule();
2603+
2604+
/*
2605+
* We could've been woken by task_work, run it to clear
2606+
* TIF_NOTIFY_SIGNAL. The caller will retry if necessary.
2607+
*/
2608+
clear_notify_signal();
2609+
if (unlikely(task_work_pending(current)))
2610+
task_work_run();
26032611
}
26042612

26052613
static int ptrace_signal(int signr, kernel_siginfo_t *info, enum pid_type type)

0 commit comments

Comments
 (0)