OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 5 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <linux/futex.h> | 10 #include <linux/futex.h> |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "sandbox/linux/services/linux_syscalls.h" | 33 #include "sandbox/linux/services/linux_syscalls.h" |
34 | 34 |
35 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
36 | 36 |
37 #include "sandbox/linux/services/android_futex.h" | 37 #include "sandbox/linux/services/android_futex.h" |
38 | 38 |
39 #if !defined(F_DUPFD_CLOEXEC) | 39 #if !defined(F_DUPFD_CLOEXEC) |
40 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) | 40 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) |
41 #endif | 41 #endif |
42 | 42 |
| 43 // https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/priv
ate/bionic_prctl.h |
| 44 #if !defined(PR_SET_VMA) |
| 45 #define PR_SET_VMA 0x53564d41 |
| 46 #endif |
| 47 |
| 48 // https://android.googlesource.com/platform/system/core/+/lollipop-release/libc
utils/sched_policy.c |
| 49 #if !defined(PR_SET_TIMERSLACK_PID) |
| 50 #define PR_SET_TIMERSLACK_PID 41 |
| 51 #endif |
| 52 |
43 #endif // defined(OS_ANDROID) | 53 #endif // defined(OS_ANDROID) |
44 | 54 |
45 #if defined(__arm__) && !defined(MAP_STACK) | 55 #if defined(__arm__) && !defined(MAP_STACK) |
46 #define MAP_STACK 0x20000 // Daisy build environment has old headers. | 56 #define MAP_STACK 0x20000 // Daisy build environment has old headers. |
47 #endif | 57 #endif |
48 | 58 |
49 #if defined(__mips__) && !defined(MAP_STACK) | 59 #if defined(__mips__) && !defined(MAP_STACK) |
50 #define MAP_STACK 0x40000 | 60 #define MAP_STACK 0x40000 |
51 #endif | 61 #endif |
52 namespace { | 62 namespace { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 .Else(CrashSIGSYSClone()); | 132 .Else(CrashSIGSYSClone()); |
123 } | 133 } |
124 | 134 |
125 ResultExpr RestrictPrctl() { | 135 ResultExpr RestrictPrctl() { |
126 // Will need to add seccomp compositing in the future. PR_SET_PTRACER is | 136 // Will need to add seccomp compositing in the future. PR_SET_PTRACER is |
127 // used by breakpad but not needed anymore. | 137 // used by breakpad but not needed anymore. |
128 const Arg<int> option(0); | 138 const Arg<int> option(0); |
129 return Switch(option) | 139 return Switch(option) |
130 .CASES((PR_GET_NAME, PR_SET_NAME, PR_GET_DUMPABLE, PR_SET_DUMPABLE), | 140 .CASES((PR_GET_NAME, PR_SET_NAME, PR_GET_DUMPABLE, PR_SET_DUMPABLE), |
131 Allow()) | 141 Allow()) |
| 142 #if defined(OS_ANDROID) |
| 143 .CASES((PR_SET_VMA, PR_SET_TIMERSLACK_PID), Allow()) |
| 144 #endif |
132 .Default(CrashSIGSYSPrctl()); | 145 .Default(CrashSIGSYSPrctl()); |
133 } | 146 } |
134 | 147 |
135 ResultExpr RestrictIoctl() { | 148 ResultExpr RestrictIoctl() { |
136 const Arg<int> request(1); | 149 const Arg<int> request(1); |
137 return Switch(request).CASES((TCGETS, FIONREAD), Allow()).Default( | 150 return Switch(request).CASES((TCGETS, FIONREAD), Allow()).Default( |
138 CrashSIGSYSIoctl()); | 151 CrashSIGSYSIoctl()); |
139 } | 152 } |
140 | 153 |
141 ResultExpr RestrictMmapFlags() { | 154 ResultExpr RestrictMmapFlags() { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 return CrashSIGSYS(); | 298 return CrashSIGSYS(); |
286 } | 299 } |
287 } | 300 } |
288 | 301 |
289 ResultExpr RestrictPrlimit64(pid_t target_pid) { | 302 ResultExpr RestrictPrlimit64(pid_t target_pid) { |
290 const Arg<pid_t> pid(0); | 303 const Arg<pid_t> pid(0); |
291 return If(pid == 0 || pid == target_pid, Allow()).Else(CrashSIGSYS()); | 304 return If(pid == 0 || pid == target_pid, Allow()).Else(CrashSIGSYS()); |
292 } | 305 } |
293 | 306 |
294 } // namespace sandbox. | 307 } // namespace sandbox. |
OLD | NEW |