sandlock
sandlock copied to clipboard
sandbox: descendants outlive a SIGKILLed supervisor
PR_SET_PDEATHSIG is set on the first child only and is not inherited across fork, so when the supervisor is killed with SIGKILL its grandchildren keep running:
timeout -s KILL 4 sandlock run ... -- sh -c 'echo abc | gzip | gunzip' # when it hangs
ps: gzip -d, reparented, NoNewPrivs=1, Seccomp=2, still alive
They stay confined by Landlock and the seccomp filter, but every notified syscall now returns ENOSYS ("cannot open shared object file: Error 38"), and they keep the caller's pipes open, which blocks whoever is reading the sandbox's output.
Proposed fix: make the whole tree die with the supervisor, for example by having the supervisor kill the sandbox's process group from a SIGKILL-proof place (a small reaper parent, or PR_SET_PDEATHSIG re-armed in the fork handler for each new child).