Why does a seccomp process always get killed?

此生再无相见时 提交于 2019-12-07 13:48:26

问题


Why does a process that has gone into seccomp mode always get killed on exit?

$ 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

回答1:


From the man page, under PR_SET_SECCOMP, the only allowed system calls are read, write, exit, and sigreturn.

When you call exit(0) in the standard library (in recent Linux), you call the exit_group system call, not exit. This is not allowed, so you get a SIGKILL.

(You can see this if you strace the process...)



来源:https://stackoverflow.com/questions/10114583/why-does-a-seccomp-process-always-get-killed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!