Chromium Code Reviews| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 | 106 | 
| 106 template <class T0> | 107 template <class T0> | 
| 107 static inline intptr_t Call(int nr, T0 p0) { | 108 static inline intptr_t Call(int nr, T0 p0) { | 
| 108 return Call(nr, p0, 0, 0, 0, 0, 0, 0, 0); | 109 return Call(nr, p0, 0, 0, 0, 0, 0, 0, 0); | 
| 109 } | 110 } | 
| 110 | 111 | 
| 111 static inline intptr_t Call(int nr) { | 112 static inline intptr_t Call(int nr) { | 
| 112 return Call(nr, 0, 0, 0, 0, 0, 0, 0, 0); | 113 return Call(nr, 0, 0, 0, 0, 0, 0, 0, 0); | 
| 113 } | 114 } | 
| 114 | 115 | 
| 116 // Set the registers in |ctx| to match what they would be after a system call | |
| 117 // returning |ret_val|. |ret_val| must follow the Syscall::Call() convention | |
| 118 // of being -errno on errors. | |
| 119 static void PutValueInUcontext(intptr_t ret_val, ucontext_t* ctx); | |
| 120 | |
| 115 private: | 121 private: | 
| 116 // This performs system call |nr| with the arguments p0 to p7 from a constant | 122 // This performs system call |nr| with the arguments p0 to p7 from a constant | 
| 117 // userland address, which is for instance observable by seccomp-bpf filters. | 123 // userland address, which is for instance observable by seccomp-bpf filters. | 
| 118 // The constant userland address from which these system calls are made will | 124 // The constant userland address from which these system calls are made will | 
| 119 // be returned if |nr| is passed as -1. | 125 // be returned if |nr| is passed as -1. | 
| 120 // On error, this function will return a value between -1 and -4095 which | 126 // On error, this function will return a value between -1 and -4095 which | 
| 121 // should be interpreted as -errno. | 127 // should be interpreted as -errno. | 
| 122 static intptr_t Call(int nr, | 128 static intptr_t Call(int nr, | 
| 123 intptr_t p0, | 129 intptr_t p0, | 
| 124 intptr_t p1, | 130 intptr_t p1, | 
| 125 intptr_t p2, | 131 intptr_t p2, | 
| 126 intptr_t p3, | 132 intptr_t p3, | 
| 127 intptr_t p4, | 133 intptr_t p4, | 
| 128 intptr_t p5, | 134 intptr_t p5, | 
| 129 intptr_t p6, | 135 intptr_t p6, | 
| 130 intptr_t p7); | 136 intptr_t p7); | 
| 131 | 137 | 
| 138 #if defined(__mips__) | |
| 139 // This function basically does on MIPS what SandboxSyscall() is doing on | |
| 140 // other architectures. However, because of specificity of MIPS regarding | |
| 141 // handelling syscall errors, SandboxSyscall() is made as a wrapper for this | |
| 
 
mdempsky
2014/07/14 18:10:51
typo: handling
 
nedeljko
2014/07/15 15:22:16
Done.
 
 | |
| 142 // function in order for SandboxSyscall() to behave more like on othere | |
| 
 
mdempsky
2014/07/14 18:10:51
typo: other
 
nedeljko
2014/07/15 15:22:16
Done.
 
 | |
| 143 // architectures on places where return value from SandboxSyscall() is used | |
| 144 // directly (like in most tests). | |
| 145 // The syscall "nr" is called with arguments that are set in an array on which | |
| 146 // pointer "args" points to and an information weather there is an error or no | |
| 147 // is returned to SandboxSyscall() by err_stat. | |
| 148 static intptr_t SandboxSyscallRaw(int nr, | |
| 149 const intptr_t* args, | |
| 150 intptr_t* err_stat); | |
| 151 #endif // defined(__mips__) | |
| 152 | |
| 132 DISALLOW_IMPLICIT_CONSTRUCTORS(Syscall); | 153 DISALLOW_IMPLICIT_CONSTRUCTORS(Syscall); | 
| 133 }; | 154 }; | 
| 134 | 155 | 
| 135 } // namespace sandbox | 156 } // namespace sandbox | 
| 136 | 157 | 
| 137 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 158 #endif // SANDBOX_LINUX_SECCOMP_BPF_SYSCALL_H__ | 
| OLD | NEW |