cgroup.kill fails to kill a process whose thread group leader has exited while other threads are still running, leaving the cgroup populated. This can be used by a process in a container to survive the container being killed, including the case of a container with a private PID namespace, where such a process is the container's init.
Patch 1 fixes __cgroup_kill() to walk all threads and to send a thread-group-directed SIGKILL. Patch 2 adds selftests for both scenarios described in patch 1; they fail without the fix. Tested on v7.3-rc7 (x86_64 VM): test_kill passes (30 runs), other cgroup selftests show no changes compared to the unpatched kernel. The issue was found in crun, see patch 1 for details. Signed-off-by: Kir Kolyshkin <[email protected]> --- Kir Kolyshkin (2): cgroup: fix cgroup.kill for exited thread group leader selftests/cgroup: test cgroup.kill with an exited thread group leader kernel/cgroup/cgroup.c | 4 +- tools/testing/selftests/cgroup/test_kill.c | 158 +++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 2 deletions(-) --- base-commit: f909e534f5e34feb2ea2701d54df63e21aa506fc change-id: 20261018-cgroup-kill-exited-leader-a15159e8c230 Best regards, -- Kir Kolyshkin <[email protected]>

