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

Side by Side Diff: components/nacl/loader/nonsfi/nonsfi_sandbox_unittest.cc

Issue 307033002: Non-SFI NaCl: CLOCK_SYSTEM_TRACE fails gracefully on Chrome OS Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use only OS_LINUX to decide whether we define kClockSystemTrace Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // ASan internally uses some syscalls which non-SFI NaCl disallows. 5 // ASan internally uses some syscalls which non-SFI NaCl disallows.
6 // Seccomp-BPF tests die under TSan v2. See http://crbug.com/356588 6 // Seccomp-BPF tests die under TSan v2. See http://crbug.com/356588
7 #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) 7 #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER)
8 8
9 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" 9 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h"
10 10
(...skipping 13 matching lines...) Expand all
24 #include <sys/wait.h> 24 #include <sys/wait.h>
25 #include <time.h> 25 #include <time.h>
26 #include <unistd.h> 26 #include <unistd.h>
27 27
28 #include "base/bind.h" 28 #include "base/bind.h"
29 #include "base/callback.h" 29 #include "base/callback.h"
30 #include "base/compiler_specific.h" 30 #include "base/compiler_specific.h"
31 #include "base/files/scoped_file.h" 31 #include "base/files/scoped_file.h"
32 #include "base/logging.h" 32 #include "base/logging.h"
33 #include "base/posix/eintr_wrapper.h" 33 #include "base/posix/eintr_wrapper.h"
34 #include "base/time/time.h"
34 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" 35 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
35 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 36 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
37 #include "sandbox/linux/services/linux_syscalls.h"
36 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK 38 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK
37 39
38 namespace { 40 namespace {
39 41
40 void DoPipe(base::ScopedFD* fds) { 42 void DoPipe(base::ScopedFD* fds) {
41 int tmp_fds[2]; 43 int tmp_fds[2];
42 BPF_ASSERT_EQ(0, pipe(tmp_fds)); 44 BPF_ASSERT_EQ(0, pipe(tmp_fds));
43 fds[0].reset(tmp_fds[0]); 45 fds[0].reset(tmp_fds[0]);
44 fds[1].reset(tmp_fds[1]); 46 fds[1].reset(tmp_fds[1]);
45 } 47 }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 413 }
412 414
413 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 415 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
414 clock_gettime_crash_monotonic_raw, 416 clock_gettime_crash_monotonic_raw,
415 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 417 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
416 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 418 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
417 struct timespec ts; 419 struct timespec ts;
418 clock_gettime(CLOCK_MONOTONIC_RAW, &ts); 420 clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
419 } 421 }
420 422
423 #if defined(OS_CHROMEOS)
424 BPF_TEST_C(NaClNonSfiSandboxTest,
425 clock_gettime_eperm_system_trace,
426 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
427 struct timespec ts = {};
428 BPF_ASSERT_EQ(-1, clock_gettime(base::TimeTicks::kClockSystemTrace, &ts));
429 BPF_ASSERT_EQ(EPERM, errno);
430 }
431 #else
432 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
433 clock_gettime_crash_system_trace,
434 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
435 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
436 struct timespec ts;
437 clock_gettime(base::TimeTicks::kClockSystemTrace, &ts);
438 }
439 #endif
440
421 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 441 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
422 clock_gettime_crash_cpu_clock, 442 clock_gettime_crash_cpu_clock,
423 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 443 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
424 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 444 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
425 // We can't use clock_getcpuclockid() because it's not implemented in newlib, 445 // We can't use clock_getcpuclockid() because it's not implemented in newlib,
426 // and it might not work inside the sandbox anyway. 446 // and it might not work inside the sandbox anyway.
427 const pid_t kInitPID = 1; 447 const pid_t kInitPID = 1;
428 const clockid_t kInitCPUClockID = 448 const clockid_t kInitCPUClockID =
429 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED); 449 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED);
430 450
(...skipping 27 matching lines...) Expand all
458 RESTRICT_SYSCALL_EPERM_TEST(open); 478 RESTRICT_SYSCALL_EPERM_TEST(open);
459 RESTRICT_SYSCALL_EPERM_TEST(ptrace); 479 RESTRICT_SYSCALL_EPERM_TEST(ptrace);
460 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); 480 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list);
461 #if defined(__i386__) || defined(__x86_64__) 481 #if defined(__i386__) || defined(__x86_64__)
462 RESTRICT_SYSCALL_EPERM_TEST(time); 482 RESTRICT_SYSCALL_EPERM_TEST(time);
463 #endif 483 #endif
464 484
465 } // namespace 485 } // namespace
466 486
467 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER 487 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER
OLDNEW
« no previous file with comments | « components/nacl/loader/nonsfi/nonsfi_sandbox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698