OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SERVICES_SYSCALL_WRAPPERS_H_ | 5 #ifndef SANDBOX_LINUX_SERVICES_SYSCALL_WRAPPERS_H_ |
6 #define SANDBOX_LINUX_SERVICES_SYSCALL_WRAPPERS_H_ | 6 #define SANDBOX_LINUX_SERVICES_SYSCALL_WRAPPERS_H_ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include "sandbox/sandbox_export.h" | 10 #include "sandbox/sandbox_export.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // |regs| is not supported and must be passed as nullptr. |child_stack| must be | 27 // |regs| is not supported and must be passed as nullptr. |child_stack| must be |
28 // nullptr, since otherwise this function cannot safely return. As a | 28 // nullptr, since otherwise this function cannot safely return. As a |
29 // consequence, this function does not support CLONE_VM. | 29 // consequence, this function does not support CLONE_VM. |
30 SANDBOX_EXPORT long sys_clone(unsigned long flags, | 30 SANDBOX_EXPORT long sys_clone(unsigned long flags, |
31 decltype(nullptr) child_stack, | 31 decltype(nullptr) child_stack, |
32 pid_t* ptid, | 32 pid_t* ptid, |
33 pid_t* ctid, | 33 pid_t* ctid, |
34 decltype(nullptr) regs); | 34 decltype(nullptr) regs); |
35 | 35 |
36 // A wrapper for clone with fork-like behavior, meaning that it returns the | |
37 // child's pid in the parent and 0 in the child. |flags|, |ptid|, and |ctid| are | |
38 // as in the clone system call (the CLONE_VM flag is not supported). | |
39 // | |
40 // This function uses the libc clone wrapper (which updates libc's pid cache) | |
41 // internally, so callers may expect things like getpid() to work correctly | |
42 // after in both the child and parent. An exception is when this code is run | |
43 // under Valgrind. Valgrind does not support the libc clone wrapper, so the libc | |
44 // pid cache may be incorrect after this function is called under Valgrind. | |
45 SANDBOX_EXPORT pid_t | |
46 ForkWithFlags(unsigned long flags, pid_t* ptid, pid_t* ctid); | |
47 | |
48 SANDBOX_EXPORT void sys_exit_group(int status); | 36 SANDBOX_EXPORT void sys_exit_group(int status); |
49 | 37 |
50 // The official system call takes |args| as void* (in order to be extensible), | 38 // The official system call takes |args| as void* (in order to be extensible), |
51 // but add more typing for the cases that are currently used. | 39 // but add more typing for the cases that are currently used. |
52 SANDBOX_EXPORT int sys_seccomp(unsigned int operation, | 40 SANDBOX_EXPORT int sys_seccomp(unsigned int operation, |
53 unsigned int flags, | 41 unsigned int flags, |
54 const struct sock_fprog* args); | 42 const struct sock_fprog* args); |
55 | 43 |
56 // Some libcs do not expose a prlimit64 wrapper. | 44 // Some libcs do not expose a prlimit64 wrapper. |
57 SANDBOX_EXPORT int sys_prlimit64(pid_t pid, | 45 SANDBOX_EXPORT int sys_prlimit64(pid_t pid, |
58 int resource, | 46 int resource, |
59 const struct rlimit64* new_limit, | 47 const struct rlimit64* new_limit, |
60 struct rlimit64* old_limit); | 48 struct rlimit64* old_limit); |
61 | 49 |
62 } // namespace sandbox | 50 } // namespace sandbox |
63 | 51 |
64 #endif // SANDBOX_LINUX_SERVICES_SYSCALL_WRAPPERS_H_ | 52 #endif // SANDBOX_LINUX_SERVICES_SYSCALL_WRAPPERS_H_ |
OLD | NEW |