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> |
11 #include <linux/net.h> | 11 #include <linux/net.h> |
12 #include <sched.h> | 12 #include <sched.h> |
13 #include <signal.h> | 13 #include <signal.h> |
14 #include <sys/ioctl.h> | 14 #include <sys/ioctl.h> |
15 #include <sys/mman.h> | 15 #include <sys/mman.h> |
16 #include <sys/prctl.h> | 16 #include <sys/prctl.h> |
17 #include <sys/resource.h> | 17 #include <sys/resource.h> |
18 #include <sys/stat.h> | 18 #include <sys/stat.h> |
19 #include <sys/time.h> | 19 #include <sys/time.h> |
20 #include <sys/types.h> | 20 #include <sys/types.h> |
| 21 #include <time.h> |
21 #include <unistd.h> | 22 #include <unistd.h> |
22 | 23 |
23 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
24 #include "base/logging.h" | 25 #include "base/logging.h" |
25 #include "base/macros.h" | 26 #include "base/macros.h" |
| 27 #include "base/time/time.h" |
26 #include "build/build_config.h" | 28 #include "build/build_config.h" |
27 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 29 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
28 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" | 30 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" |
29 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 31 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
30 | 32 |
31 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
32 | 34 |
33 #include "sandbox/linux/services/android_futex.h" | 35 #include "sandbox/linux/services/android_futex.h" |
34 | 36 |
35 #if !defined(F_DUPFD_CLOEXEC) | 37 #if !defined(F_DUPFD_CLOEXEC) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 242 } |
241 | 243 |
242 ResultExpr RestrictGetSetpriority(pid_t target_pid) { | 244 ResultExpr RestrictGetSetpriority(pid_t target_pid) { |
243 const Arg<int> which(0); | 245 const Arg<int> which(0); |
244 const Arg<int> who(1); | 246 const Arg<int> who(1); |
245 return If(which == PRIO_PROCESS, | 247 return If(which == PRIO_PROCESS, |
246 If(who == 0 || who == target_pid, Allow()).Else(Error(EPERM))) | 248 If(who == 0 || who == target_pid, Allow()).Else(Error(EPERM))) |
247 .Else(CrashSIGSYS()); | 249 .Else(CrashSIGSYS()); |
248 } | 250 } |
249 | 251 |
| 252 ResultExpr RestrictClockID() { |
| 253 COMPILE_ASSERT(4 == sizeof(clockid_t), clockid_is_not_32bit); |
| 254 const Arg<clockid_t> clockid(0); |
| 255 return If( |
| 256 #if defined(OS_CHROMEOS) |
| 257 // Allow the special clock for Chrome OS used by Chrome tracing. |
| 258 clockid == base::TimeTicks::kClockSystemTrace || |
| 259 #endif |
| 260 clockid == CLOCK_MONOTONIC || |
| 261 clockid == CLOCK_PROCESS_CPUTIME_ID || |
| 262 clockid == CLOCK_REALTIME || |
| 263 clockid == CLOCK_THREAD_CPUTIME_ID, |
| 264 Allow()).Else(CrashSIGSYS()); |
| 265 } |
| 266 |
250 } // namespace sandbox. | 267 } // namespace sandbox. |
OLD | NEW |