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 // Sanitizers internally use some syscalls which non-SFI NaCl disallows. | 5 // Sanitizers internally use some syscalls which non-SFI NaCl disallows. |
6 #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) && \ | 6 #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) && \ |
7 !defined(MEMORY_SANITIZER) && !defined(LEAK_SANITIZER) | 7 !defined(MEMORY_SANITIZER) && !defined(LEAK_SANITIZER) |
8 | 8 |
9 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" | 9 #include "components/nacl/loader/nonsfi/nonsfi_sandbox.h" |
10 | 10 |
11 #include <errno.h> | 11 #include <errno.h> |
12 #include <fcntl.h> | 12 #include <fcntl.h> |
13 #include <linux/net.h> | 13 #include <linux/net.h> |
14 #include <pthread.h> | 14 #include <pthread.h> |
15 #include <sched.h> | 15 #include <sched.h> |
16 #include <signal.h> | 16 #include <signal.h> |
17 #include <stdlib.h> | 17 #include <stdlib.h> |
18 #include <string.h> | 18 #include <string.h> |
19 #include <sys/mman.h> | 19 #include <sys/mman.h> |
20 #include <sys/prctl.h> | 20 #include <sys/prctl.h> |
21 #include <sys/socket.h> | 21 #include <sys/socket.h> |
22 #include <sys/syscall.h> | 22 #include <sys/syscall.h> |
23 #include <sys/types.h> | 23 #include <sys/types.h> |
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/at_exit.h" |
28 #include "base/bind.h" | 29 #include "base/bind.h" |
29 #include "base/callback.h" | 30 #include "base/callback.h" |
30 #include "base/compiler_specific.h" | 31 #include "base/compiler_specific.h" |
31 #include "base/files/scoped_file.h" | 32 #include "base/files/scoped_file.h" |
32 #include "base/logging.h" | 33 #include "base/logging.h" |
33 #include "base/posix/eintr_wrapper.h" | 34 #include "base/posix/eintr_wrapper.h" |
34 #include "base/sys_info.h" | 35 #include "base/sys_info.h" |
35 #include "base/threading/thread.h" | 36 #include "base/threading/thread.h" |
36 #include "base/time/time.h" | 37 #include "base/time/time.h" |
37 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" | 38 #include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" |
38 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 39 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
39 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 40 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
40 #include "sandbox/linux/seccomp-bpf/syscall.h" | 41 #include "sandbox/linux/seccomp-bpf/syscall.h" |
41 #include "sandbox/linux/system_headers/linux_futex.h" | 42 #include "sandbox/linux/system_headers/linux_futex.h" |
42 #include "sandbox/linux/system_headers/linux_signal.h" | 43 #include "sandbox/linux/system_headers/linux_signal.h" |
43 #include "sandbox/linux/system_headers/linux_syscalls.h" | 44 #include "sandbox/linux/system_headers/linux_syscalls.h" |
44 | 45 |
| 46 // These defines are for PNaCl toolchain build. |
| 47 #if !defined(F_DUPFD_CLOEXEC) |
| 48 #define F_DUPFD_CLOEXEC 1030 |
| 49 #endif |
| 50 |
| 51 #if !defined(MAP_POPULATE) |
| 52 #define MAP_POPULATE 0x8000 |
| 53 #endif |
| 54 |
| 55 #if !defined(PROT_GROWSDOWN) |
| 56 #define PROT_GROWSDOWN 0x01000000 |
| 57 #endif |
| 58 |
| 59 #if !defined(CLOCK_MONOTONIC_RAW) |
| 60 #define CLOCK_MONOTONIC_RAW 4 |
| 61 #endif |
| 62 |
| 63 #if !defined(AF_INET) |
| 64 #define AF_INET 2 |
| 65 #endif |
| 66 |
| 67 #if defined(__i386__) |
| 68 |
| 69 #if !defined(SYS_SOCKET) |
| 70 #define SYS_SOCKET 1 |
| 71 #endif |
| 72 |
| 73 #if !defined(SYS_BIND) |
| 74 #define SYS_BIND 2 |
| 75 #endif |
| 76 |
| 77 #if !defined(SYS_CONNECT) |
| 78 #define SYS_CONNECT 3 |
| 79 #endif |
| 80 |
| 81 #if !defined(SYS_LISTEN) |
| 82 #define SYS_LISTEN 4 |
| 83 #endif |
| 84 |
| 85 #if !defined(SYS_ACCEPT) |
| 86 #define SYS_ACCEPT 5 |
| 87 #endif |
| 88 |
| 89 #if !defined(SYS_GETSOCKNAME) |
| 90 #define SYS_GETSOCKNAME 6 |
| 91 #endif |
| 92 |
| 93 #if !defined(SYS_GETPEERNAME) |
| 94 #define SYS_GETPEERNAME 7 |
| 95 #endif |
| 96 |
| 97 #if !defined(SYS_SETSOCKOPT) |
| 98 #define SYS_SETSOCKOPT 14 |
| 99 #endif |
| 100 |
| 101 #if !defined(SYS_GETSOCKOPT) |
| 102 #define SYS_GETSOCKOPT 15 |
| 103 #endif |
| 104 |
| 105 #endif // defined(__i386__) |
| 106 |
45 namespace { | 107 namespace { |
46 | 108 |
47 void DoPipe(base::ScopedFD* fds) { | 109 void DoPipe(base::ScopedFD* fds) { |
48 int tmp_fds[2]; | 110 int tmp_fds[2]; |
49 BPF_ASSERT_EQ(0, pipe(tmp_fds)); | 111 BPF_ASSERT_EQ(0, pipe(tmp_fds)); |
50 fds[0].reset(tmp_fds[0]); | 112 fds[0].reset(tmp_fds[0]); |
51 fds[1].reset(tmp_fds[1]); | 113 fds[1].reset(tmp_fds[1]); |
52 } | 114 } |
53 | 115 |
54 void DoSocketpair(base::ScopedFD* fds) { | 116 void DoSocketpair(base::ScopedFD* fds) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 423 |
362 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 424 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
363 fcntl_GETFL_SETFL, | 425 fcntl_GETFL_SETFL, |
364 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 426 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
365 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 427 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
366 base::ScopedFD fds[2]; | 428 base::ScopedFD fds[2]; |
367 DoSocketpair(fds); | 429 DoSocketpair(fds); |
368 fcntl(fds[0].get(), F_SETFL, O_APPEND); | 430 fcntl(fds[0].get(), F_SETFL, O_APPEND); |
369 } | 431 } |
370 | 432 |
| 433 void DoFcntl(int fd, int cmd) { |
| 434 // fcntl in PNaCl toolchain returns an error without calling actual system |
| 435 // call for unknown |cmd|. So, instead, here we use syscall(). |
| 436 #if defined(OS_NACL_NONSFI) |
| 437 syscall(__NR_fcntl64, fd, cmd); |
| 438 #else |
| 439 fcntl(fd, cmd); |
| 440 #endif |
| 441 } |
| 442 |
371 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 443 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
372 fcntl_DUPFD, | 444 fcntl_DUPFD, |
373 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 445 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
374 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 446 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
375 fcntl(0, F_DUPFD); | 447 DoFcntl(0, F_DUPFD); |
376 } | 448 } |
377 | 449 |
378 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 450 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
379 fcntl_DUPFD_CLOEXEC, | 451 fcntl_DUPFD_CLOEXEC, |
380 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 452 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
381 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 453 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
382 fcntl(0, F_DUPFD_CLOEXEC); | 454 DoFcntl(0, F_DUPFD_CLOEXEC); |
383 } | 455 } |
384 | 456 |
385 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 457 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
386 FutexWithRequeuePriorityInheritence, | 458 FutexWithRequeuePriorityInheritence, |
387 DEATH_SEGV_MESSAGE( | 459 DEATH_SEGV_MESSAGE( |
388 sandbox::GetFutexErrorMessageContentForTests()), | 460 sandbox::GetFutexErrorMessageContentForTests()), |
389 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 461 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
390 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI, 0, NULL, NULL, 0); | 462 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI, 0, NULL, NULL, 0); |
391 _exit(1); | 463 _exit(1); |
392 } | 464 } |
393 | 465 |
394 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 466 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
395 FutexWithRequeuePriorityInheritencePrivate, | 467 FutexWithRequeuePriorityInheritencePrivate, |
396 DEATH_SEGV_MESSAGE( | 468 DEATH_SEGV_MESSAGE( |
397 sandbox::GetFutexErrorMessageContentForTests()), | 469 sandbox::GetFutexErrorMessageContentForTests()), |
398 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 470 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
399 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI_PRIVATE, 0, NULL, NULL, 0); | 471 syscall(__NR_futex, NULL, FUTEX_CMP_REQUEUE_PI_PRIVATE, 0, NULL, NULL, 0); |
400 _exit(1); | 472 _exit(1); |
401 } | 473 } |
402 | 474 |
403 BPF_TEST_C(NaClNonSfiSandboxTest, | 475 BPF_TEST_C(NaClNonSfiSandboxTest, |
404 StartingAndJoiningThreadWorks, | 476 StartingAndJoiningThreadWorks, |
405 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 477 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
| 478 #if defined(OS_NACL_NONSFI) |
| 479 // base::Thread internally uses LazyInstance, which registers a callback to |
| 480 // AtExitManager. However, in PNaCl toolchain build, it is not instantiated |
| 481 // by the test runner, unlike host toolchain build (nacl_loader_unittests). |
| 482 // Hence, declare it here so that the LazyInstance will work properly. |
| 483 base::AtExitManager at_exit; |
| 484 #endif |
| 485 |
406 base::Thread thread("sandbox_tests"); | 486 base::Thread thread("sandbox_tests"); |
407 BPF_ASSERT(thread.Start()); | 487 BPF_ASSERT(thread.Start()); |
408 // |thread|'s destructor will join the thread. | 488 // |thread|'s destructor will join the thread. |
409 } | 489 } |
410 | 490 |
411 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 491 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
412 FutexWithUnlockPIPrivate, | 492 FutexWithUnlockPIPrivate, |
413 DEATH_SEGV_MESSAGE( | 493 DEATH_SEGV_MESSAGE( |
414 sandbox::GetFutexErrorMessageContentForTests()), | 494 sandbox::GetFutexErrorMessageContentForTests()), |
415 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 495 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
416 syscall(__NR_futex, NULL, FUTEX_UNLOCK_PI_PRIVATE, 0, NULL, NULL, 0); | 496 syscall(__NR_futex, NULL, FUTEX_UNLOCK_PI_PRIVATE, 0, NULL, NULL, 0); |
417 _exit(1); | 497 _exit(1); |
418 } | 498 } |
419 | 499 |
| 500 void* DoMmap(int prot, int flags) { |
| 501 #if defined(OS_NACL_NONSFI) |
| 502 // When PROT_EXEC is set, PNaCl toolchain's mmap() system call wrapper uses |
| 503 // two system calls mmap2(2) and mprotect(2), so that we cannot test |
| 504 // sandbox with the wrapper. Instead, here we use syscall(). |
| 505 return reinterpret_cast<void*>( |
| 506 syscall(__NR_mmap2, NULL, getpagesize(), prot, flags, -1, 0)); |
| 507 #else |
| 508 return mmap(NULL, getpagesize(), prot, flags, -1, 0); |
| 509 #endif |
| 510 } |
| 511 |
420 void* DoAllowedAnonymousMmap() { | 512 void* DoAllowedAnonymousMmap() { |
421 return mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, | 513 return DoMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED); |
422 MAP_ANONYMOUS | MAP_SHARED, -1, 0); | |
423 } | 514 } |
424 | 515 |
425 BPF_TEST_C(NaClNonSfiSandboxTest, | 516 BPF_TEST_C(NaClNonSfiSandboxTest, |
426 mmap_allowed, | 517 mmap_allowed, |
427 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 518 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
428 void* ptr = DoAllowedAnonymousMmap(); | 519 void* ptr = DoAllowedAnonymousMmap(); |
429 BPF_ASSERT_NE(MAP_FAILED, ptr); | 520 BPF_ASSERT_NE(MAP_FAILED, ptr); |
430 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize())); | 521 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize())); |
431 } | 522 } |
432 | 523 |
433 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 524 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
434 mmap_unallowed_flag, | 525 mmap_unallowed_flag, |
435 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 526 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
436 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 527 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
437 mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, | 528 DoMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_POPULATE); |
438 MAP_ANONYMOUS | MAP_POPULATE, -1, 0); | |
439 } | 529 } |
440 | 530 |
441 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 531 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
442 mmap_unallowed_prot, | 532 mmap_unallowed_prot, |
443 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 533 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
444 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 534 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
445 mmap(NULL, getpagesize(), PROT_READ | PROT_GROWSDOWN, | 535 DoMmap(PROT_READ | PROT_GROWSDOWN, MAP_ANONYMOUS); |
446 MAP_ANONYMOUS, -1, 0); | |
447 } | 536 } |
448 | 537 |
449 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 538 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
450 mmap_exec, | 539 mmap_exec, |
451 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 540 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
452 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 541 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
453 mmap(NULL, getpagesize(), PROT_EXEC, MAP_ANONYMOUS, -1, 0); | 542 DoMmap(PROT_EXEC, MAP_ANONYMOUS); |
454 } | 543 } |
455 | 544 |
456 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 545 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
457 mmap_read_exec, | 546 mmap_read_exec, |
458 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 547 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
459 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 548 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
460 mmap(NULL, getpagesize(), PROT_READ | PROT_EXEC, MAP_ANONYMOUS, -1, 0); | 549 DoMmap(PROT_READ | PROT_EXEC, MAP_ANONYMOUS); |
461 } | 550 } |
462 | 551 |
463 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 552 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
464 mmap_write_exec, | 553 mmap_write_exec, |
465 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 554 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
466 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 555 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
467 mmap(NULL, getpagesize(), PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS, -1, 0); | 556 DoMmap(PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS); |
468 } | 557 } |
469 | 558 |
470 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 559 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
471 mmap_read_write_exec, | 560 mmap_read_write_exec, |
472 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 561 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
473 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 562 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
474 mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC, | 563 DoMmap(PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS); |
475 MAP_ANONYMOUS, -1, 0); | |
476 } | 564 } |
477 | 565 |
478 BPF_TEST_C(NaClNonSfiSandboxTest, | 566 BPF_TEST_C(NaClNonSfiSandboxTest, |
479 mprotect_allowed, | 567 mprotect_allowed, |
480 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 568 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
481 void* ptr = DoAllowedAnonymousMmap(); | 569 void* ptr = DoAllowedAnonymousMmap(); |
482 BPF_ASSERT_NE(MAP_FAILED, ptr); | 570 BPF_ASSERT_NE(MAP_FAILED, ptr); |
483 BPF_ASSERT_EQ(0, mprotect(ptr, getpagesize(), PROT_READ)); | 571 BPF_ASSERT_EQ(0, mprotect(ptr, getpagesize(), PROT_READ)); |
484 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize())); | 572 BPF_ASSERT_EQ(0, munmap(ptr, getpagesize())); |
485 } | 573 } |
(...skipping 10 matching lines...) Expand all Loading... |
496 mprotect(ptr, getpagesize(), PROT_READ | PROT_GROWSDOWN); | 584 mprotect(ptr, getpagesize(), PROT_READ | PROT_GROWSDOWN); |
497 } | 585 } |
498 | 586 |
499 BPF_TEST_C(NaClNonSfiSandboxTest, | 587 BPF_TEST_C(NaClNonSfiSandboxTest, |
500 brk, | 588 brk, |
501 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 589 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
502 char* next_brk = static_cast<char*>(sbrk(0)) + getpagesize(); | 590 char* next_brk = static_cast<char*>(sbrk(0)) + getpagesize(); |
503 // The kernel interface must return zero for brk. | 591 // The kernel interface must return zero for brk. |
504 BPF_ASSERT_EQ(0, syscall(__NR_brk, next_brk)); | 592 BPF_ASSERT_EQ(0, syscall(__NR_brk, next_brk)); |
505 // The libc wrapper translates it to ENOMEM. | 593 // The libc wrapper translates it to ENOMEM. |
| 594 |
| 595 // Note: PNaCl toolchain does not provide brk() system call wrapper. |
| 596 #if !defined(OS_NACL_NONSFI) |
506 errno = 0; | 597 errno = 0; |
507 BPF_ASSERT_EQ(-1, brk(next_brk)); | 598 BPF_ASSERT_EQ(-1, brk(next_brk)); |
508 BPF_ASSERT_EQ(ENOMEM, errno); | 599 BPF_ASSERT_EQ(ENOMEM, errno); |
| 600 #endif |
509 } | 601 } |
510 | 602 |
511 // clockid restrictions are mostly tested in sandbox/ with the | 603 // clockid restrictions are mostly tested in sandbox/ with the |
512 // RestrictClockID() unittests. Some basic tests are duplicated here as | 604 // RestrictClockID() unittests. Some basic tests are duplicated here as |
513 // a precaution. | 605 // a precaution. |
514 | 606 |
515 void CheckClock(clockid_t clockid) { | 607 void CheckClock(clockid_t clockid) { |
516 struct timespec ts; | 608 struct timespec ts; |
517 ts.tv_sec = ts.tv_nsec = -1; | 609 ts.tv_sec = ts.tv_nsec = -1; |
518 BPF_ASSERT_EQ(0, clock_gettime(clockid, &ts)); | 610 BPF_ASSERT_EQ(0, clock_gettime(clockid, &ts)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 RESTRICT_SYSCALL_EPERM_TEST(ptrace); | 664 RESTRICT_SYSCALL_EPERM_TEST(ptrace); |
573 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); | 665 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); |
574 #if defined(__i386__) || defined(__x86_64__) | 666 #if defined(__i386__) || defined(__x86_64__) |
575 RESTRICT_SYSCALL_EPERM_TEST(time); | 667 RESTRICT_SYSCALL_EPERM_TEST(time); |
576 #endif | 668 #endif |
577 | 669 |
578 } // namespace | 670 } // namespace |
579 | 671 |
580 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER && | 672 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER && |
581 // !MEMORY_SANITIZER && !LEAK_SANITIZER | 673 // !MEMORY_SANITIZER && !LEAK_SANITIZER |
OLD | NEW |