| 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 #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 <time.h> | 7 #include <time.h> |
| 8 | 8 |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 13 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 14 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 14 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 15 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 16 #include "sandbox/linux/seccomp-bpf/syscall.h" | 16 #include "sandbox/linux/seccomp-bpf/syscall.h" |
| 17 #include "sandbox/linux/services/linux_syscalls.h" | 17 #include "sandbox/linux/services/linux_syscalls.h" |
| 18 #include "sandbox/linux/tests/unit_tests.h" | 18 #include "sandbox/linux/tests/unit_tests.h" |
| 19 |
| 20 #if !defined(OS_ANDROID) |
| 19 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK | 21 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK |
| 22 #endif |
| 20 | 23 |
| 21 namespace sandbox { | 24 namespace sandbox { |
| 22 | 25 |
| 23 namespace { | 26 namespace { |
| 24 | 27 |
| 25 // NOTE: most of the parameter restrictions are tested in | 28 // NOTE: most of the parameter restrictions are tested in |
| 26 // baseline_policy_unittest.cc as a more end-to-end test. | 29 // baseline_policy_unittest.cc as a more end-to-end test. |
| 27 | 30 |
| 28 using sandbox::bpf_dsl::Allow; | 31 using sandbox::bpf_dsl::Allow; |
| 29 using sandbox::bpf_dsl::ResultExpr; | 32 using sandbox::bpf_dsl::ResultExpr; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 BPF_DEATH_TEST_C(ParameterRestrictions, | 113 BPF_DEATH_TEST_C(ParameterRestrictions, |
| 111 clock_gettime_crash_system_trace, | 114 clock_gettime_crash_system_trace, |
| 112 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 115 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
| 113 RestrictClockIdPolicy) { | 116 RestrictClockIdPolicy) { |
| 114 struct timespec ts; | 117 struct timespec ts; |
| 115 clock_gettime(base::TimeTicks::kClockSystemTrace, &ts); | 118 clock_gettime(base::TimeTicks::kClockSystemTrace, &ts); |
| 116 } | 119 } |
| 117 | 120 |
| 118 #endif // defined(OS_CHROMEOS) | 121 #endif // defined(OS_CHROMEOS) |
| 119 | 122 |
| 123 #if !defined(OS_ANDROID) |
| 120 BPF_DEATH_TEST_C(ParameterRestrictions, | 124 BPF_DEATH_TEST_C(ParameterRestrictions, |
| 121 clock_gettime_crash_cpu_clock, | 125 clock_gettime_crash_cpu_clock, |
| 122 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 126 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
| 123 RestrictClockIdPolicy) { | 127 RestrictClockIdPolicy) { |
| 124 // We can't use clock_getcpuclockid() because it's not implemented in newlib, | 128 // We can't use clock_getcpuclockid() because it's not implemented in newlib, |
| 125 // and it might not work inside the sandbox anyway. | 129 // and it might not work inside the sandbox anyway. |
| 126 const pid_t kInitPID = 1; | 130 const pid_t kInitPID = 1; |
| 127 const clockid_t kInitCPUClockID = | 131 const clockid_t kInitCPUClockID = |
| 128 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED); | 132 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED); |
| 129 | 133 |
| 130 struct timespec ts; | 134 struct timespec ts; |
| 131 clock_gettime(kInitCPUClockID, &ts); | 135 clock_gettime(kInitCPUClockID, &ts); |
| 132 } | 136 } |
| 137 #endif // !defined(OS_ANDROID) |
| 133 | 138 |
| 134 } // namespace | 139 } // namespace |
| 135 | 140 |
| 136 } // namespace sandbox | 141 } // namespace sandbox |
| OLD | NEW |