Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: experimental/webtry/seccomp_bpf.h

Issue 231663002: too aggressive on seccomp cleanup (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove exe Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | experimental/webtry/webtry.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * seccomp example for x86 (32-bit and 64-bit) with BPF macros 2 * seccomp example for x86 (32-bit and 64-bit) with BPF macros
3 * 3 *
4 * Copyright (c) 2012 The Chromium OS Authors <chromium-os-dev@chromium.org> 4 * Copyright (c) 2012 The Chromium OS Authors <chromium-os-dev@chromium.org>
5 * Authors: 5 * Authors:
6 * Will Drewry <wad@chromium.org> 6 * Will Drewry <wad@chromium.org>
7 * Kees Cook <keescook@chromium.org> 7 * Kees Cook <keescook@chromium.org>
8 * 8 *
9 * Use of this source code is governed by a BSD-style license that can be 9 * Use of this source code is governed by a BSD-style license that can be
10 * found in the LICENSE file. 10 * found in the LICENSE file.
11 * 11 *
12 * A stripped down version of the file found in this tutorial: http://outflux.ne t/teach-seccomp/. 12 * A stripped down version of the file found in this tutorial: http://outflux.ne t/teach-seccomp/.
13 */ 13 */
14 #ifndef _SECCOMP_BPF_H_ 14 #ifndef _SECCOMP_BPF_H_
15 #define _SECCOMP_BPF_H_ 15 #define _SECCOMP_BPF_H_
16 16
17 #define _GNU_SOURCE 1 17 #define _GNU_SOURCE 1
18 #include <stdio.h> 18 #include <stdio.h>
19 #include <stddef.h> 19 #include <stddef.h>
20 #include <stdlib.h> 20 #include <stdlib.h>
21 #include <errno.h> 21 #include <errno.h>
22 #include <signal.h> 22 #include <signal.h>
23 #include <string.h> 23 #include <string.h>
24 #include <unistd.h> 24 #include <unistd.h>
25 25
26 #include <sys/prctl.h> 26 #include <sys/prctl.h>
27 #ifndef PR_SET_NO_NEW_PRIVS
28 # define PR_SET_NO_NEW_PRIVS 38
29 #endif
27 30
28 #include <linux/unistd.h> 31 #include <linux/unistd.h>
29 #include <linux/audit.h> 32 #include <linux/audit.h>
30 #include <linux/filter.h> 33 #include <linux/filter.h>
31 #include <linux/seccomp.h> 34 #ifdef HAVE_LINUX_SECCOMP_H
35 # include <linux/seccomp.h>
36 #endif
37 #ifndef SECCOMP_MODE_FILTER
38 # define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */
39 # define SECCOMP_RET_KILL 0x00000000U /* kill the task immediately */
40 # define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
41 # define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
42 struct seccomp_data {
43 int nr;
44 __u32 arch;
45 __u64 instruction_pointer;
46 __u64 args[6];
47 };
48 #endif
49 #ifndef SYS_SECCOMP
50 # define SYS_SECCOMP 1
51 #endif
32 52
33 #define syscall_nr (offsetof(struct seccomp_data, nr)) 53 #define syscall_nr (offsetof(struct seccomp_data, nr))
34 54
35 #define EXAMINE_SYSCALL \ 55 #define EXAMINE_SYSCALL \
36 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr) 56 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr)
37 57
38 #define ALLOW_SYSCALL(name) \ 58 #define ALLOW_SYSCALL(name) \
39 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \ 59 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \
40 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW) 60 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW)
41 61
42 #define KILL_PROCESS \ 62 #define KILL_PROCESS \
43 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL) 63 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
44 64
45 #endif /* _SECCOMP_BPF_H_ */ 65 #endif /* _SECCOMP_BPF_H_ */
OLDNEW
« no previous file with comments | « no previous file | experimental/webtry/webtry.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698