Closed tr-intel closed 1 year ago
OK, I've found an explanation for this behaviour.
The only signals that can be sent to process ID 1, the init process, are those for which init has explicitly installed signal handlers. This is done to assure the system is not brought down accidentally.
The default configuration setting for nsjail is to have clone_newpid set to true. This means that when a new PID (Process ID) namespace is created, the sandboxed process becomes the sole process within it and is assigned PID 1. This configuration may lead the Linux kernel to incorrectly perceive our sandboxed process as the init process.
Simply setting clone_newpid to false, solves this issue.
SIGTERM default action should be process termination.
However, when running under nsjail, SIGTERM’s default handler SIG_DFL(0) is not doing anything! I have a simple POC indicating the signal handler is not SIG_IGN(1) and the signal is not blocked.
Attacked are two files: signal.c test.sh signal_issue.zip
Following is the test.sh POC output:
AFAICT, the same issue happens with all other default-terminate-action signals (e.g., SIGUSR1 )