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

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

Issue 298163008: Non-SFI NaCl: Allow CLOCK_SYSTEM_TRACE on Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment update 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 BPF_ASSERT_LE(0, ts.tv_nsec); 403 BPF_ASSERT_LE(0, ts.tv_nsec);
402 } 404 }
403 405
404 BPF_TEST_C(NaClNonSfiSandboxTest, 406 BPF_TEST_C(NaClNonSfiSandboxTest,
405 clock_gettime_allowed, 407 clock_gettime_allowed,
406 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 408 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
407 CheckClock(CLOCK_MONOTONIC); 409 CheckClock(CLOCK_MONOTONIC);
408 CheckClock(CLOCK_PROCESS_CPUTIME_ID); 410 CheckClock(CLOCK_PROCESS_CPUTIME_ID);
409 CheckClock(CLOCK_REALTIME); 411 CheckClock(CLOCK_REALTIME);
410 CheckClock(CLOCK_THREAD_CPUTIME_ID); 412 CheckClock(CLOCK_THREAD_CPUTIME_ID);
413 #if defined(OS_CHROMEOS)
414 CheckClock(base::TimeTicks::kClockSystemTrace);
415 #endif
411 } 416 }
412 417
413 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 418 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
414 clock_gettime_crash_monotonic_raw, 419 clock_gettime_crash_monotonic_raw,
415 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 420 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
416 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 421 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
417 struct timespec ts; 422 struct timespec ts;
418 clock_gettime(CLOCK_MONOTONIC_RAW, &ts); 423 clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
419 } 424 }
420 425
426 #if !defined(OS_CHROMEOS)
427 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
428 clock_gettime_crash_system_trace,
429 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
430 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
431 struct timespec ts;
432 clock_gettime(base::TimeTicks::kClockSystemTrace, &ts);
433 }
434 #endif
435
421 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 436 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
422 clock_gettime_crash_cpu_clock, 437 clock_gettime_crash_cpu_clock,
423 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 438 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
424 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 439 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
425 // We can't use clock_getcpuclockid() because it's not implemented in newlib, 440 // We can't use clock_getcpuclockid() because it's not implemented in newlib,
426 // and it might not work inside the sandbox anyway. 441 // and it might not work inside the sandbox anyway.
427 const pid_t kInitPID = 1; 442 const pid_t kInitPID = 1;
428 const clockid_t kInitCPUClockID = 443 const clockid_t kInitCPUClockID =
429 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED); 444 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED);
430 445
(...skipping 27 matching lines...) Expand all
458 RESTRICT_SYSCALL_EPERM_TEST(open); 473 RESTRICT_SYSCALL_EPERM_TEST(open);
459 RESTRICT_SYSCALL_EPERM_TEST(ptrace); 474 RESTRICT_SYSCALL_EPERM_TEST(ptrace);
460 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); 475 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list);
461 #if defined(__i386__) || defined(__x86_64__) 476 #if defined(__i386__) || defined(__x86_64__)
462 RESTRICT_SYSCALL_EPERM_TEST(time); 477 RESTRICT_SYSCALL_EPERM_TEST(time);
463 #endif 478 #endif
464 479
465 } // namespace 480 } // namespace
466 481
467 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER 482 #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