OLD | NEW |
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 #ifndef SK_UNSAFE_BUILD_DESKTOP_ONLY |
| 18 |
17 #define _GNU_SOURCE 1 | 19 #define _GNU_SOURCE 1 |
18 #include <stdio.h> | 20 #include <stdio.h> |
19 #include <stddef.h> | 21 #include <stddef.h> |
20 #include <stdlib.h> | 22 #include <stdlib.h> |
21 #include <errno.h> | 23 #include <errno.h> |
22 #include <signal.h> | 24 #include <signal.h> |
23 #include <string.h> | 25 #include <string.h> |
24 #include <unistd.h> | 26 #include <unistd.h> |
25 | 27 |
26 #include <sys/prctl.h> | 28 #include <sys/prctl.h> |
(...skipping 28 matching lines...) Expand all Loading... |
55 #define EXAMINE_SYSCALL \ | 57 #define EXAMINE_SYSCALL \ |
56 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr) | 58 BPF_STMT(BPF_LD+BPF_W+BPF_ABS, syscall_nr) |
57 | 59 |
58 #define ALLOW_SYSCALL(name) \ | 60 #define ALLOW_SYSCALL(name) \ |
59 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \ | 61 BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, __NR_##name, 0, 1), \ |
60 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW) | 62 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW) |
61 | 63 |
62 #define KILL_PROCESS \ | 64 #define KILL_PROCESS \ |
63 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL) | 65 BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL) |
64 | 66 |
| 67 #endif /* SK_UNSAFE_BUILD_DESKTOP_ONLY */ |
| 68 |
65 #endif /* _SECCOMP_BPF_H_ */ | 69 #endif /* _SECCOMP_BPF_H_ */ |
OLD | NEW |