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/baseline_policy.h" | 5 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/futex.h> | 9 #include <linux/futex.h> |
10 #include <sched.h> | 10 #include <sched.h> |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 BPF_TEST_C(BaselinePolicy, EPERM_getcwd, BaselinePolicy) { | 208 BPF_TEST_C(BaselinePolicy, EPERM_getcwd, BaselinePolicy) { |
209 errno = 0; | 209 errno = 0; |
210 char buf[1024]; | 210 char buf[1024]; |
211 char* cwd = getcwd(buf, sizeof(buf)); | 211 char* cwd = getcwd(buf, sizeof(buf)); |
212 BPF_ASSERT_EQ(NULL, cwd); | 212 BPF_ASSERT_EQ(NULL, cwd); |
213 BPF_ASSERT_EQ(EPERM, errno); | 213 BPF_ASSERT_EQ(EPERM, errno); |
214 } | 214 } |
215 | 215 |
216 // TODO(jorgelo): re-enable this after crbug.com/424973 is fixed. | |
217 #if !defined(OS_CHROMEOS) | |
218 BPF_DEATH_TEST_C(BaselinePolicy, | 216 BPF_DEATH_TEST_C(BaselinePolicy, |
219 SIGSYS_InvalidSyscall, | 217 SIGSYS_InvalidSyscall, |
220 DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()), | 218 DEATH_SEGV_MESSAGE(GetErrorMessageContentForTests()), |
221 BaselinePolicy) { | 219 BaselinePolicy) { |
222 Syscall::InvalidCall(); | 220 Syscall::InvalidCall(); |
223 } | 221 } |
224 #endif | |
225 | 222 |
226 // A failing test using this macro could be problematic since we perform | 223 // A failing test using this macro could be problematic since we perform |
227 // system calls by passing "0" as every argument. | 224 // system calls by passing "0" as every argument. |
228 // The kernel could SIGSEGV the process or the system call itself could reboot | 225 // The kernel could SIGSEGV the process or the system call itself could reboot |
229 // the machine. Some thoughts have been given when hand-picking the system | 226 // the machine. Some thoughts have been given when hand-picking the system |
230 // calls below to limit any potential side effects outside of the current | 227 // calls below to limit any potential side effects outside of the current |
231 // process. | 228 // process. |
232 #define TEST_BASELINE_SIGSYS(sysno) \ | 229 #define TEST_BASELINE_SIGSYS(sysno) \ |
233 BPF_DEATH_TEST_C(BaselinePolicy, \ | 230 BPF_DEATH_TEST_C(BaselinePolicy, \ |
234 SIGSYS_##sysno, \ | 231 SIGSYS_##sysno, \ |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 ClockGettimeWithDisallowedClockCrashes, | 342 ClockGettimeWithDisallowedClockCrashes, |
346 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 343 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
347 BaselinePolicy) { | 344 BaselinePolicy) { |
348 struct timespec ts; | 345 struct timespec ts; |
349 clock_gettime(CLOCK_MONOTONIC_RAW, &ts); | 346 clock_gettime(CLOCK_MONOTONIC_RAW, &ts); |
350 } | 347 } |
351 | 348 |
352 } // namespace | 349 } // namespace |
353 | 350 |
354 } // namespace sandbox | 351 } // namespace sandbox |
OLD | NEW |