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 <signal.h> | |
8 #include <stdint.h> | 9 #include <stdint.h> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "sandbox/sandbox_export.h" | 12 #include "sandbox/sandbox_export.h" |
12 | 13 |
13 namespace sandbox { | 14 namespace sandbox { |
14 | 15 |
15 // This purely static class can be used to perform system calls with some | 16 // This purely static class can be used to perform system calls with some |
16 // low-level control. | 17 // low-level control. |
17 class SANDBOX_EXPORT Syscall { | 18 class SANDBOX_EXPORT Syscall { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 return Call(nr, p0, p1, 0, 0, 0, 0); | 74 return Call(nr, p0, p1, 0, 0, 0, 0); |
74 } | 75 } |
75 | 76 |
76 template <class T0> | 77 template <class T0> |
77 static inline intptr_t Call(int nr, T0 p0) { | 78 static inline intptr_t Call(int nr, T0 p0) { |
78 return Call(nr, p0, 0, 0, 0, 0, 0); | 79 return Call(nr, p0, 0, 0, 0, 0, 0); |
79 } | 80 } |
80 | 81 |
81 static inline intptr_t Call(int nr) { return Call(nr, 0, 0, 0, 0, 0, 0); } | 82 static inline intptr_t Call(int nr) { return Call(nr, 0, 0, 0, 0, 0, 0); } |
82 | 83 |
84 // Set the registers in |ctx| to match what they would be after a system call | |
85 // returning |ret_val|. |ret_val| must follow the Syscall::Call() convention | |
86 // of being -errno on errors. | |
87 static void PutValueInUcontext(intptr_t ret_val, ucontext_t* ctx); | |
88 | |
83 private: | 89 private: |
84 DISALLOW_IMPLICIT_CONSTRUCTORS(Syscall); | 90 DISALLOW_IMPLICIT_CONSTRUCTORS(Syscall); |
85 }; | 91 }; |
86 | 92 |
93 #if defined(__mips__) | |
94 // This function basically does on MIPS what SandboxSyscall() is doing on | |
95 // other architectures. However, because of specificity of MIPS regarding | |
96 // handelling syscall errors, SandboxSyscall() is made as a wrapper for this | |
97 // function in order for SandboxSyscall() to behave more like on othere | |
98 // architectures on places where return value from SandboxSyscall() is used | |
99 // directly (like in most tests). | |
100 // The syscall "nr" is called with arguments that are set in an array on which | |
101 // pointer "args" points to and an information weather there is an error or no | |
102 // is returned to SandboxSyscall() by err_stat. | |
103 intptr_t SandboxSyscallRaw(int nr, | |
jln (very slow on Chromium)
2014/06/20 00:37:06
Let's add this as a private member of the class in
nedeljko
2014/06/20 14:09:51
Done.
| |
104 const intptr_t* args, | |
105 intptr_t* err_stat); | |
106 #endif // defined(__mips__) | |
107 | |
87 } // namespace sandbox | 108 } // namespace sandbox |
88 | 109 |
89 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 110 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ |
OLD | NEW |