summaryrefslogtreecommitdiffstats
path: root/samples/seccomp
diff options
context:
space:
mode:
authorRicky Zhou <rickyz@chromium.org>2016-10-13 13:34:08 -0400
committerKees Cook <keescook@chromium.org>2016-11-01 11:58:10 -0400
commit1ff120504f8c322a03fbce035d99e29e741da725 (patch)
tree08c14543552cc15c4bd918ea0bd062483b6cfeda /samples/seccomp
parent0af04ba5640dd6318f117a9fcbfde886516a0220 (diff)
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: Ricky Zhou <rickyz@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'samples/seccomp')
-rw-r--r--samples/seccomp/dropper.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/samples/seccomp/dropper.c b/samples/seccomp/dropper.c
index c69c347c7011..68325ca5e71c 100644
--- a/samples/seccomp/dropper.c
+++ b/samples/seccomp/dropper.c
@@ -11,7 +11,6 @@
11 * When run, returns the specified errno for the specified 11 * When run, returns the specified errno for the specified
12 * system call number against the given architecture. 12 * system call number against the given architecture.
13 * 13 *
14 * Run this one as root as PR_SET_NO_NEW_PRIVS is not called.
15 */ 14 */
16 15
17#include <errno.h> 16#include <errno.h>
@@ -42,8 +41,12 @@ static int install_filter(int nr, int arch, int error)
42 .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])), 41 .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
43 .filter = filter, 42 .filter = filter,
44 }; 43 };
44 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
45 perror("prctl(NO_NEW_PRIVS)");
46 return 1;
47 }
45 if (prctl(PR_SET_SECCOMP, 2, &prog)) { 48 if (prctl(PR_SET_SECCOMP, 2, &prog)) {
46 perror("prctl"); 49 perror("prctl(PR_SET_SECCOMP)");
47 return 1; 50 return 1;
48 } 51 }
49 return 0; 52 return 0;