OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <errno.h> | 5 #include <errno.h> |
6 #include <pthread.h> | 6 #include <pthread.h> |
7 #include <sched.h> | 7 #include <sched.h> |
8 #include <sys/prctl.h> | 8 #include <sys/prctl.h> |
9 #include <sys/syscall.h> | 9 #include <sys/syscall.h> |
10 #include <sys/time.h> | 10 #include <sys/time.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 #include <sys/utsname.h> | 12 #include <sys/utsname.h> |
13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 #include <sys/socket.h> |
14 | 15 |
15 #if defined(ANDROID) | 16 #if defined(ANDROID) |
16 // Work-around for buggy headers in Android's NDK | 17 // Work-around for buggy headers in Android's NDK |
17 #define __user | 18 #define __user |
18 #endif | 19 #endif |
19 #include <linux/futex.h> | 20 #include <linux/futex.h> |
20 | 21 |
21 #include <ostream> | 22 #include <ostream> |
22 | 23 |
23 #include "base/bind.h" | 24 #include "base/bind.h" |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 644 |
644 BPF_TEST_C(SandboxBPF, SigBus, RedirectAllSyscallsPolicy) { | 645 BPF_TEST_C(SandboxBPF, SigBus, RedirectAllSyscallsPolicy) { |
645 // We use the SIGBUS bit in the signal mask as a thread-local boolean | 646 // We use the SIGBUS bit in the signal mask as a thread-local boolean |
646 // value in the implementation of UnsafeTrap(). This is obviously a bit | 647 // value in the implementation of UnsafeTrap(). This is obviously a bit |
647 // of a hack that could conceivably interfere with code that uses SIGBUS | 648 // of a hack that could conceivably interfere with code that uses SIGBUS |
648 // in more traditional ways. This test verifies that basic functionality | 649 // in more traditional ways. This test verifies that basic functionality |
649 // of SIGBUS is not impacted, but it is certainly possibly to construe | 650 // of SIGBUS is not impacted, but it is certainly possibly to construe |
650 // more complex uses of signals where our use of the SIGBUS mask is not | 651 // more complex uses of signals where our use of the SIGBUS mask is not |
651 // 100% transparent. This is expected behavior. | 652 // 100% transparent. This is expected behavior. |
652 int fds[2]; | 653 int fds[2]; |
653 BPF_ASSERT(pipe(fds) == 0); | 654 BPF_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == 0); |
654 bus_handler_fd_ = fds[1]; | 655 bus_handler_fd_ = fds[1]; |
655 struct sigaction sa = {}; | 656 struct sigaction sa = {}; |
656 sa.sa_sigaction = SigBusHandler; | 657 sa.sa_sigaction = SigBusHandler; |
657 sa.sa_flags = SA_SIGINFO; | 658 sa.sa_flags = SA_SIGINFO; |
658 BPF_ASSERT(sigaction(SIGBUS, &sa, NULL) == 0); | 659 BPF_ASSERT(sigaction(SIGBUS, &sa, NULL) == 0); |
659 raise(SIGBUS); | 660 raise(SIGBUS); |
660 char c = '\000'; | 661 char c = '\000'; |
661 BPF_ASSERT(read(fds[0], &c, 1) == 1); | 662 BPF_ASSERT(read(fds[0], &c, 1) == 1); |
662 BPF_ASSERT(close(fds[0]) == 0); | 663 BPF_ASSERT(close(fds[0]) == 0); |
663 BPF_ASSERT(close(fds[1]) == 0); | 664 BPF_ASSERT(close(fds[1]) == 0); |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 PthreadTest(); | 1905 PthreadTest(); |
1905 } | 1906 } |
1906 | 1907 |
1907 BPF_TEST_C(SandboxBPF, PthreadBitMask, PthreadPolicyBitMask) { | 1908 BPF_TEST_C(SandboxBPF, PthreadBitMask, PthreadPolicyBitMask) { |
1908 PthreadTest(); | 1909 PthreadTest(); |
1909 } | 1910 } |
1910 | 1911 |
1911 } // namespace | 1912 } // namespace |
1912 | 1913 |
1913 } // namespace sandbox | 1914 } // namespace sandbox |
OLD | NEW |