OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 namespace playground2 { | 10 namespace sandbox { |
11 | 11 |
12 // We have to make sure that we have a single "magic" return address for | 12 // We have to make sure that we have a single "magic" return address for |
13 // our system calls, which we can check from within a BPF filter. This | 13 // our system calls, which we can check from within a BPF filter. This |
14 // works by writing a little bit of asm() code that a) enters the kernel, and | 14 // works by writing a little bit of asm() code that a) enters the kernel, and |
15 // that also b) can be invoked in a way that computes this return address. | 15 // that also b) can be invoked in a way that computes this return address. |
16 // Passing "nr" as "-1" computes the "magic" return address. Passing any | 16 // Passing "nr" as "-1" computes the "magic" return address. Passing any |
17 // other value invokes the appropriate system call. | 17 // other value invokes the appropriate system call. |
18 intptr_t SandboxSyscall(int nr, | 18 intptr_t SandboxSyscall(int nr, |
19 intptr_t p0, | 19 intptr_t p0, |
20 intptr_t p1, | 20 intptr_t p1, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return SandboxSyscall(nr, p0, 0, 0, 0, 0, 0); | 126 return SandboxSyscall(nr, p0, 0, 0, 0, 0, 0); |
127 } | 127 } |
128 | 128 |
129 inline intptr_t SandboxSyscall(int nr) __attribute__((always_inline)); | 129 inline intptr_t SandboxSyscall(int nr) __attribute__((always_inline)); |
130 inline intptr_t SandboxSyscall(int nr) { | 130 inline intptr_t SandboxSyscall(int nr) { |
131 return SandboxSyscall(nr, 0, 0, 0, 0, 0, 0); | 131 return SandboxSyscall(nr, 0, 0, 0, 0, 0, 0); |
132 } | 132 } |
133 | 133 |
134 #endif // Pre-C++11 | 134 #endif // Pre-C++11 |
135 | 135 |
136 } // namespace | 136 } // namespace sandbox |
137 | 137 |
138 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 138 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ |
OLD | NEW |