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/net.h> | 10 #include <linux/net.h> |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "sandbox/linux/bpf_dsl/seccomp_macros.h" | 28 #include "sandbox/linux/bpf_dsl/seccomp_macros.h" |
29 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 29 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
30 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 30 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
31 #include "sandbox/linux/system_headers/linux_futex.h" | 31 #include "sandbox/linux/system_headers/linux_futex.h" |
32 #include "sandbox/linux/system_headers/linux_syscalls.h" | 32 #include "sandbox/linux/system_headers/linux_syscalls.h" |
33 #include "sandbox/linux/system_headers/linux_time.h" | 33 #include "sandbox/linux/system_headers/linux_time.h" |
34 | 34 |
35 // PNaCl toolchain does not provide sys/ioctl.h header. | 35 // PNaCl toolchain does not provide sys/ioctl.h header. |
36 #if !defined(OS_NACL_NONSFI) | 36 #if !defined(OS_NACL_NONSFI) |
37 #include <sys/ioctl.h> | 37 #include <sys/ioctl.h> |
| 38 #if defined(USE_OZONE) |
| 39 #include <drm.h> |
| 40 #endif |
38 #endif | 41 #endif |
39 | 42 |
40 #if defined(OS_ANDROID) | 43 #if defined(OS_ANDROID) |
41 | 44 |
42 #if !defined(F_DUPFD_CLOEXEC) | 45 #if !defined(F_DUPFD_CLOEXEC) |
43 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) | 46 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) |
44 #endif | 47 #endif |
45 | 48 |
46 // https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/priv
ate/bionic_prctl.h | 49 // https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/priv
ate/bionic_prctl.h |
47 #if !defined(PR_SET_VMA) | 50 #if !defined(PR_SET_VMA) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return Switch(option) | 146 return Switch(option) |
144 .CASES((PR_GET_NAME, PR_SET_NAME, PR_GET_DUMPABLE, PR_SET_DUMPABLE), | 147 .CASES((PR_GET_NAME, PR_SET_NAME, PR_GET_DUMPABLE, PR_SET_DUMPABLE), |
145 Allow()) | 148 Allow()) |
146 #if defined(OS_ANDROID) | 149 #if defined(OS_ANDROID) |
147 .CASES((PR_SET_VMA, PR_SET_TIMERSLACK_PID), Allow()) | 150 .CASES((PR_SET_VMA, PR_SET_TIMERSLACK_PID), Allow()) |
148 #endif | 151 #endif |
149 .Default(CrashSIGSYSPrctl()); | 152 .Default(CrashSIGSYSPrctl()); |
150 } | 153 } |
151 | 154 |
152 ResultExpr RestrictIoctl() { | 155 ResultExpr RestrictIoctl() { |
153 const Arg<int> request(1); | 156 // The type of DRM_IOCTL_XXX macro is long unsigned int. |
154 return Switch(request).CASES((TCGETS, FIONREAD), Allow()).Default( | 157 #if defined(USE_OZONE) |
155 CrashSIGSYSIoctl()); | 158 auto reference_type = DRM_IOCTL_MODE_MAP_DUMB; |
| 159 #else |
| 160 auto reference_type = TCGETS; |
| 161 #endif |
| 162 const Arg<decltype(reference_type)> request(1); |
| 163 return Switch(request) |
| 164 .CASES(((decltype(reference_type))TCGETS, FIONREAD), Allow()) |
| 165 #if defined(USE_OZONE) |
| 166 .CASES((DRM_IOCTL_MODE_DESTROY_DUMB, DRM_IOCTL_MODE_MAP_DUMB, |
| 167 DRM_IOCTL_PRIME_FD_TO_HANDLE), |
| 168 Allow()) |
| 169 #endif |
| 170 .Default(CrashSIGSYSIoctl()); |
156 } | 171 } |
157 | 172 |
158 ResultExpr RestrictMmapFlags() { | 173 ResultExpr RestrictMmapFlags() { |
159 // The flags you see are actually the allowed ones, and the variable is a | 174 // The flags you see are actually the allowed ones, and the variable is a |
160 // "denied" mask because of the negation operator. | 175 // "denied" mask because of the negation operator. |
161 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as | 176 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as |
162 // MAP_POPULATE. | 177 // MAP_POPULATE. |
163 // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. | 178 // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. |
164 const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | | 179 const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | |
165 MAP_STACK | MAP_NORESERVE | MAP_FIXED | | 180 MAP_STACK | MAP_NORESERVE | MAP_FIXED | |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 clockid == CLOCK_MONOTONIC || | 325 clockid == CLOCK_MONOTONIC || |
311 clockid == CLOCK_MONOTONIC_COARSE || | 326 clockid == CLOCK_MONOTONIC_COARSE || |
312 clockid == CLOCK_PROCESS_CPUTIME_ID || | 327 clockid == CLOCK_PROCESS_CPUTIME_ID || |
313 clockid == CLOCK_REALTIME || | 328 clockid == CLOCK_REALTIME || |
314 clockid == CLOCK_REALTIME_COARSE || | 329 clockid == CLOCK_REALTIME_COARSE || |
315 clockid == CLOCK_THREAD_CPUTIME_ID, | 330 clockid == CLOCK_THREAD_CPUTIME_ID, |
316 Allow()).Else(CrashSIGSYS()); | 331 Allow()).Else(CrashSIGSYS()); |
317 } | 332 } |
318 | 333 |
319 } // namespace sandbox. | 334 } // namespace sandbox. |
OLD | NEW |