| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 #include <time.h> | 12 #include <time.h> |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 22 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 22 #include "sandbox/linux/bpf_dsl/policy.h" | 23 #include "sandbox/linux/bpf_dsl/policy.h" |
| 23 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 24 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
| 24 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 25 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 25 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 26 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 BPF_TEST_C(ParameterRestrictions, | 158 BPF_TEST_C(ParameterRestrictions, |
| 158 sched_getparam_allowed, | 159 sched_getparam_allowed, |
| 159 RestrictSchedPolicy) { | 160 RestrictSchedPolicy) { |
| 160 base::WaitableEvent thread_run( | 161 base::WaitableEvent thread_run( |
| 161 base::WaitableEvent::ResetPolicy::MANUAL, | 162 base::WaitableEvent::ResetPolicy::MANUAL, |
| 162 base::WaitableEvent::InitialState::NOT_SIGNALED); | 163 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 163 // Run the actual test in a new thread so that the current pid and tid are | 164 // Run the actual test in a new thread so that the current pid and tid are |
| 164 // different. | 165 // different. |
| 165 base::Thread getparam_thread("sched_getparam_thread"); | 166 base::Thread getparam_thread("sched_getparam_thread"); |
| 166 BPF_ASSERT(getparam_thread.Start()); | 167 BPF_ASSERT(getparam_thread.Start()); |
| 167 getparam_thread.message_loop()->PostTask( | 168 getparam_thread.task_runner()->PostTask( |
| 168 FROM_HERE, base::Bind(&SchedGetParamThread, &thread_run)); | 169 FROM_HERE, base::Bind(&SchedGetParamThread, &thread_run)); |
| 169 BPF_ASSERT(thread_run.TimedWait(base::TimeDelta::FromMilliseconds(5000))); | 170 BPF_ASSERT(thread_run.TimedWait(base::TimeDelta::FromMilliseconds(5000))); |
| 170 getparam_thread.Stop(); | 171 getparam_thread.Stop(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 BPF_DEATH_TEST_C(ParameterRestrictions, | 174 BPF_DEATH_TEST_C(ParameterRestrictions, |
| 174 sched_getparam_crash_non_zero, | 175 sched_getparam_crash_non_zero, |
| 175 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 176 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
| 176 RestrictSchedPolicy) { | 177 RestrictSchedPolicy) { |
| 177 const pid_t kInitPID = 1; | 178 const pid_t kInitPID = 1; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 getrusage_crash_not_self, | 233 getrusage_crash_not_self, |
| 233 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 234 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
| 234 RestrictGetrusagePolicy) { | 235 RestrictGetrusagePolicy) { |
| 235 struct rusage usage; | 236 struct rusage usage; |
| 236 getrusage(RUSAGE_CHILDREN, &usage); | 237 getrusage(RUSAGE_CHILDREN, &usage); |
| 237 } | 238 } |
| 238 | 239 |
| 239 } // namespace | 240 } // namespace |
| 240 | 241 |
| 241 } // namespace sandbox | 242 } // namespace sandbox |
| OLD | NEW |