]> Git Repo - J-linux.git/commitdiff
kernel: rerun task_work while freezing in get_signal()
authorPavel Begunkov <[email protected]>
Wed, 10 Jul 2024 17:58:18 +0000 (18:58 +0100)
committerJens Axboe <[email protected]>
Thu, 11 Jul 2024 07:51:44 +0000 (01:51 -0600)
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: https://github.com/systemd/systemd/issues/33626
Fixes: 12db8b690010c ("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]>
kernel/signal.c

index 1f9dd41c04be2202309acbd00c051651e739daf1..60c737e423a18827b537333ad9b954c8ca4c93d4 100644 (file)
@@ -2600,6 +2600,14 @@ static void do_freezer_trap(void)
        spin_unlock_irq(&current->sighand->siglock);
        cgroup_enter_frozen();
        schedule();
+
+       /*
+        * We could've been woken by task_work, run it to clear
+        * TIF_NOTIFY_SIGNAL. The caller will retry if necessary.
+        */
+       clear_notify_signal();
+       if (unlikely(task_work_pending(current)))
+               task_work_run();
 }
 
 static int ptrace_signal(int signr, kernel_siginfo_t *info, enum pid_type type)
This page took 0.056416 seconds and 4 git commands to generate.