Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions_unittests.cc

Issue 684993005: Linux sandbox: start adding syscall wrappers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More dependencies. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/syscall.h> 9 #include <sys/syscall.h>
10 #include <time.h> 10 #include <time.h>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" 19 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
20 #include "sandbox/linux/bpf_dsl/policy.h" 20 #include "sandbox/linux/bpf_dsl/policy.h"
21 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" 21 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
22 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 22 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
23 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 23 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
24 #include "sandbox/linux/seccomp-bpf/syscall.h" 24 #include "sandbox/linux/seccomp-bpf/syscall.h"
25 #include "sandbox/linux/services/linux_syscalls.h" 25 #include "sandbox/linux/services/linux_syscalls.h"
26 #include "sandbox/linux/services/syscall_wrappers.h"
26 #include "sandbox/linux/tests/unit_tests.h" 27 #include "sandbox/linux/tests/unit_tests.h"
27 28
28 #if !defined(OS_ANDROID) 29 #if !defined(OS_ANDROID)
29 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK 30 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK
30 #endif 31 #endif
31 32
32 namespace sandbox { 33 namespace sandbox {
33 34
34 namespace { 35 namespace {
35 36
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 157 }
157 } 158 }
158 }; 159 };
159 160
160 void CheckSchedGetParam(pid_t pid, struct sched_param* param) { 161 void CheckSchedGetParam(pid_t pid, struct sched_param* param) {
161 BPF_ASSERT_EQ(0, sched_getparam(pid, param)); 162 BPF_ASSERT_EQ(0, sched_getparam(pid, param));
162 } 163 }
163 164
164 void SchedGetParamThread(base::WaitableEvent* thread_run) { 165 void SchedGetParamThread(base::WaitableEvent* thread_run) {
165 const pid_t pid = getpid(); 166 const pid_t pid = getpid();
166 const pid_t tid = syscall(__NR_gettid); 167 const pid_t tid = sys_gettid();
167 BPF_ASSERT_NE(pid, tid); 168 BPF_ASSERT_NE(pid, tid);
168 169
169 struct sched_param current_pid_param; 170 struct sched_param current_pid_param;
170 CheckSchedGetParam(pid, &current_pid_param); 171 CheckSchedGetParam(pid, &current_pid_param);
171 172
172 struct sched_param zero_param; 173 struct sched_param zero_param;
173 CheckSchedGetParam(0, &zero_param); 174 CheckSchedGetParam(0, &zero_param);
174 175
175 struct sched_param tid_param; 176 struct sched_param tid_param;
176 CheckSchedGetParam(tid, &tid_param); 177 CheckSchedGetParam(tid, &tid_param);
(...skipping 27 matching lines...) Expand all
204 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), 205 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()),
205 RestrictSchedPolicy) { 206 RestrictSchedPolicy) {
206 const pid_t kInitPID = 1; 207 const pid_t kInitPID = 1;
207 struct sched_param param; 208 struct sched_param param;
208 sched_getparam(kInitPID, &param); 209 sched_getparam(kInitPID, &param);
209 } 210 }
210 211
211 } // namespace 212 } // namespace
212 213
213 } // namespace sandbox 214 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698