--- zzzz-none-000/linux-4.9.279/kernel/signal.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/kernel/signal.c 2023-02-08 10:58:16.000000000 +0000 @@ -34,6 +34,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -1035,6 +1036,37 @@ } #endif +static void avm_trace_critical_init_signals(siginfo_t *info, + struct task_struct *t) +{ + /* + * HAX: Busybox init shuts down the system on some signals. + * Take note of processes that are sending such signals. + * + * This really should be handled in user space, but... user space on a + * Fritzbox has currently no means by itself to write persistent logs, + * traversing parent processes is a pain outside the kernel, and it's + * just simpler to maintain here rather than in the busybox init. + */ + + if (!IS_ENABLED(CONFIG_AVM_TRACE_INIT_SIGNALS)) + return; + + if (likely(!is_global_init(t))) + return; + + switch (info->si_signo) { + case SIGTERM: + case SIGUSR1: + case SIGUSR2: + case SIGPWR: + pr_notice("Task (pid %d) is sending signal #%d to init!\n", + task_pid_nr(current), + info->si_signo); + show_parent_tasks_cmdlines(current); + } +} + static int __send_signal(int sig, struct siginfo *info, struct task_struct *t, int group, int from_ancestor_ns) { @@ -1136,6 +1168,7 @@ complete_signal(sig, t, group); ret: trace_signal_generate(sig, info, t, group, result); + avm_trace_critical_init_signals(info, t); return ret; } @@ -1627,6 +1660,7 @@ result = TRACE_SIGNAL_DELIVERED; out: trace_signal_generate(sig, &q->info, t, group, result); + avm_trace_critical_init_signals(&q->info, t); unlock_task_sighand(t, &flags); ret: return ret;