| 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 19 matching lines...) Expand all Loading... |
| 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) | 38 #if defined(USE_OZONE) |
| 39 #include <drm.h> | 39 #include <drm.h> |
| 40 #include <libdrm/i915_drm.h> |
| 40 #endif | 41 #endif |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
| 44 | 45 |
| 45 #if !defined(F_DUPFD_CLOEXEC) | 46 #if !defined(F_DUPFD_CLOEXEC) |
| 46 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) | 47 #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 // https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/priv
ate/bionic_prctl.h | 50 // https://android.googlesource.com/platform/bionic/+/lollipop-release/libc/priv
ate/bionic_prctl.h |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 #else | 160 #else |
| 160 auto reference_type = TCGETS; | 161 auto reference_type = TCGETS; |
| 161 #endif | 162 #endif |
| 162 const Arg<decltype(reference_type)> request(1); | 163 const Arg<decltype(reference_type)> request(1); |
| 163 return Switch(request) | 164 return Switch(request) |
| 164 .CASES(((decltype(reference_type))TCGETS, FIONREAD), Allow()) | 165 .CASES(((decltype(reference_type))TCGETS, FIONREAD), Allow()) |
| 165 #if defined(USE_OZONE) | 166 #if defined(USE_OZONE) |
| 166 .CASES((DRM_IOCTL_MODE_DESTROY_DUMB, DRM_IOCTL_MODE_MAP_DUMB, | 167 .CASES((DRM_IOCTL_MODE_DESTROY_DUMB, DRM_IOCTL_MODE_MAP_DUMB, |
| 167 DRM_IOCTL_PRIME_FD_TO_HANDLE), | 168 DRM_IOCTL_PRIME_FD_TO_HANDLE), |
| 168 Allow()) | 169 Allow()) |
| 170 .CASES((DRM_IOCTL_GEM_CLOSE, |
| 171 DRM_IOCTL_PRIME_FD_TO_HANDLE, |
| 172 DRM_IOCTL_PRIME_HANDLE_TO_FD, |
| 173 DRM_IOCTL_I915_GEM_GET_APERTURE, |
| 174 DRM_IOCTL_I915_GEM_BUSY, |
| 175 DRM_IOCTL_I915_GEM_MADVISE, |
| 176 DRM_IOCTL_I915_GEM_CREATE, |
| 177 DRM_IOCTL_I915_GEM_USERPTR, |
| 178 DRM_IOCTL_GEM_OPEN, |
| 179 DRM_IOCTL_I915_GEM_GET_TILING, |
| 180 DRM_IOCTL_GEM_CLOSE, |
| 181 DRM_IOCTL_I915_GEM_MMAP, |
| 182 DRM_IOCTL_I915_GEM_SET_DOMAIN, |
| 183 DRM_IOCTL_I915_GEM_MMAP_GTT, |
| 184 DRM_IOCTL_I915_GEM_SET_DOMAIN, |
| 185 DRM_IOCTL_I915_GEM_SW_FINISH, |
| 186 DRM_IOCTL_I915_GEM_USERPTR, |
| 187 DRM_IOCTL_I915_GEM_PWRITE, |
| 188 DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, |
| 189 DRM_IOCTL_I915_GEM_PREAD, |
| 190 DRM_IOCTL_I915_GEM_WAIT, |
| 191 DRM_IOCTL_I915_GEM_SET_DOMAIN, |
| 192 DRM_IOCTL_I915_GEM_GET_TILING, |
| 193 DRM_IOCTL_GEM_FLINK, |
| 194 DRM_IOCTL_I915_GETPARAM, |
| 195 DRM_IOCTL_GEM_CLOSE, |
| 196 DRM_IOCTL_MODE_OBJ_GETPROPERTIES), Allow()) |
| 197 // Above IOCTL codes were sufficient 3 months ago, but now other codes |
| 198 // are needed. I guess mini GBM implementation began using others. |
| 199 // mini GBM is moving target, so it's difficult for Chromium |
| 200 // to white-list IOCTL codes completely. |
| 201 .Default(Allow()); |
| 202 #else |
| 203 .Default(CrashSIGSYSIoctl()); |
| 169 #endif | 204 #endif |
| 170 .Default(CrashSIGSYSIoctl()); | |
| 171 } | 205 } |
| 172 | 206 |
| 173 ResultExpr RestrictMmapFlags() { | 207 ResultExpr RestrictMmapFlags() { |
| 174 // The flags you see are actually the allowed ones, and the variable is a | 208 // The flags you see are actually the allowed ones, and the variable is a |
| 175 // "denied" mask because of the negation operator. | 209 // "denied" mask because of the negation operator. |
| 176 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as | 210 // Significantly, we don't permit MAP_HUGETLB, or the newer flags such as |
| 177 // MAP_POPULATE. | 211 // MAP_POPULATE. |
| 178 // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. | 212 // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. |
| 179 const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | | 213 const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | |
| 180 MAP_STACK | MAP_NORESERVE | MAP_FIXED | | 214 MAP_STACK | MAP_NORESERVE | MAP_FIXED | |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 clockid == CLOCK_MONOTONIC || | 359 clockid == CLOCK_MONOTONIC || |
| 326 clockid == CLOCK_MONOTONIC_COARSE || | 360 clockid == CLOCK_MONOTONIC_COARSE || |
| 327 clockid == CLOCK_PROCESS_CPUTIME_ID || | 361 clockid == CLOCK_PROCESS_CPUTIME_ID || |
| 328 clockid == CLOCK_REALTIME || | 362 clockid == CLOCK_REALTIME || |
| 329 clockid == CLOCK_REALTIME_COARSE || | 363 clockid == CLOCK_REALTIME_COARSE || |
| 330 clockid == CLOCK_THREAD_CPUTIME_ID, | 364 clockid == CLOCK_THREAD_CPUTIME_ID, |
| 331 Allow()).Else(CrashSIGSYS()); | 365 Allow()).Else(CrashSIGSYS()); |
| 332 } | 366 } |
| 333 | 367 |
| 334 } // namespace sandbox. | 368 } // namespace sandbox. |
| OLD | NEW |