为什么seccomp进程总是被杀死?

eng*_*gie 3 c linux seccomp

为什么进入seccomp模式的进程总是在退出时被杀死?

$ cat simple.c 
#include <stdio.h>
#include <stdlib.h>
#include <linux/prctl.h>

int main( int argc, char **argv )
{
    printf("Starting\n");
    prctl(PR_SET_SECCOMP, 1);
    printf("Running\n");
    exit(0);
}
$ cc -o simple simple.c
$ ./simple || echo "Returned $?"
Starting
Running
Killed
Returned 137
Run Code Online (Sandbox Code Playgroud)

ant*_*oft 5

在手册页的PR_SET_SECCOMP下,仅允许读取,写入,退出和sigreturn系统调用。

当您在标准库中(在最近的Linux中)调用exit(0)时,您将调用exit_group系统调用,而不是退出。这是不允许的,所以您会收到SIGKILL。

(如果您跟踪流程,则可以看到此信息...)