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

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

Issue 313053004: Revert "Non-SFI NaCl: Allow CLOCK_SYSTEM_TRACE on Chrome OS" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
35 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" 34 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h"
36 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 35 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
37 #include "sandbox/linux/services/linux_syscalls.h"
38 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK 36 #include "third_party/lss/linux_syscall_support.h" // for MAKE_PROCESS_CPUCLOCK
39 37
40 namespace { 38 namespace {
41 39
42 void DoPipe(base::ScopedFD* fds) { 40 void DoPipe(base::ScopedFD* fds) {
43 int tmp_fds[2]; 41 int tmp_fds[2];
44 BPF_ASSERT_EQ(0, pipe(tmp_fds)); 42 BPF_ASSERT_EQ(0, pipe(tmp_fds));
45 fds[0].reset(tmp_fds[0]); 43 fds[0].reset(tmp_fds[0]);
46 fds[1].reset(tmp_fds[1]); 44 fds[1].reset(tmp_fds[1]);
47 } 45 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 BPF_ASSERT_LE(0, ts.tv_nsec); 401 BPF_ASSERT_LE(0, ts.tv_nsec);
404 } 402 }
405 403
406 BPF_TEST_C(NaClNonSfiSandboxTest, 404 BPF_TEST_C(NaClNonSfiSandboxTest,
407 clock_gettime_allowed, 405 clock_gettime_allowed,
408 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 406 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
409 CheckClock(CLOCK_MONOTONIC); 407 CheckClock(CLOCK_MONOTONIC);
410 CheckClock(CLOCK_PROCESS_CPUTIME_ID); 408 CheckClock(CLOCK_PROCESS_CPUTIME_ID);
411 CheckClock(CLOCK_REALTIME); 409 CheckClock(CLOCK_REALTIME);
412 CheckClock(CLOCK_THREAD_CPUTIME_ID); 410 CheckClock(CLOCK_THREAD_CPUTIME_ID);
413 #if defined(OS_CHROMEOS)
414 CheckClock(base::TimeTicks::kClockSystemTrace);
415 #endif
416 } 411 }
417 412
418 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 413 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
419 clock_gettime_crash_monotonic_raw, 414 clock_gettime_crash_monotonic_raw,
420 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 415 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
421 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 416 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
422 struct timespec ts; 417 struct timespec ts;
423 clock_gettime(CLOCK_MONOTONIC_RAW, &ts); 418 clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
424 } 419 }
425 420
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
436 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, 421 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest,
437 clock_gettime_crash_cpu_clock, 422 clock_gettime_crash_cpu_clock,
438 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()), 423 DEATH_MESSAGE(sandbox::GetErrorMessageContentForTests()),
439 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { 424 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) {
440 // We can't use clock_getcpuclockid() because it's not implemented in newlib, 425 // We can't use clock_getcpuclockid() because it's not implemented in newlib,
441 // and it might not work inside the sandbox anyway. 426 // and it might not work inside the sandbox anyway.
442 const pid_t kInitPID = 1; 427 const pid_t kInitPID = 1;
443 const clockid_t kInitCPUClockID = 428 const clockid_t kInitCPUClockID =
444 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED); 429 MAKE_PROCESS_CPUCLOCK(kInitPID, CPUCLOCK_SCHED);
445 430
(...skipping 27 matching lines...) Expand all
473 RESTRICT_SYSCALL_EPERM_TEST(open); 458 RESTRICT_SYSCALL_EPERM_TEST(open);
474 RESTRICT_SYSCALL_EPERM_TEST(ptrace); 459 RESTRICT_SYSCALL_EPERM_TEST(ptrace);
475 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); 460 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list);
476 #if defined(__i386__) || defined(__x86_64__) 461 #if defined(__i386__) || defined(__x86_64__)
477 RESTRICT_SYSCALL_EPERM_TEST(time); 462 RESTRICT_SYSCALL_EPERM_TEST(time);
478 #endif 463 #endif
479 464
480 } // namespace 465 } // namespace
481 466
482 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER 467 #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