Commit 1ff12050 authored by Ricky Zhou's avatar Ricky Zhou Committed by Kees Cook

samples/seccomp: Enable PR_SET_NO_NEW_PRIVS in dropper

Either CAP_SYS_ADMIN or PR_SET_NO_NEW_PRIVS is required to enable
seccomp. This allows samples/seccomp/dropper to be run without
CAP_SYS_ADMIN.
Signed-off-by: default avatarRicky Zhou <rickyz@chromium.org>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 0af04ba5
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* When run, returns the specified errno for the specified * When run, returns the specified errno for the specified
* system call number against the given architecture. * system call number against the given architecture.
* *
* Run this one as root as PR_SET_NO_NEW_PRIVS is not called.
*/ */
#include <errno.h> #include <errno.h>
...@@ -42,8 +41,12 @@ static int install_filter(int nr, int arch, int error) ...@@ -42,8 +41,12 @@ static int install_filter(int nr, int arch, int error)
.len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
.filter = filter, .filter = filter,
}; };
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
perror("prctl(NO_NEW_PRIVS)");
return 1;
}
if (prctl(PR_SET_SECCOMP, 2, &prog)) { if (prctl(PR_SET_SECCOMP, 2, &prog)) {
perror("prctl"); perror("prctl(PR_SET_SECCOMP)");
return 1; return 1;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment