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 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 } | 193 } |
194 | 194 |
195 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 195 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
196 prctl_SET_DUMPABLE, | 196 prctl_SET_DUMPABLE, |
197 DEATH_SEGV_MESSAGE( | 197 DEATH_SEGV_MESSAGE( |
198 sandbox::GetPrctlErrorMessageContentForTests()), | 198 sandbox::GetPrctlErrorMessageContentForTests()), |
199 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 199 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
200 syscall(__NR_prctl, PR_SET_DUMPABLE, 1UL); | 200 syscall(__NR_prctl, PR_SET_DUMPABLE, 1UL); |
201 } | 201 } |
202 | 202 |
203 #if defined(OS_NACL_NONSFI) | 203 #if defined(OS_NACL_NONSFI) || defined(__x86_64__) || defined(__arm__) |
204 BPF_DEATH_TEST_C(NaClNonsfiSandboxTest, | 204 BPF_DEATH_TEST_C(NaClNonsfiSandboxTest, |
205 socketpair, | 205 socketpair, |
Mark Seaborn
2015/05/27 21:40:35
Rather than your current change...
Maybe rename t
Sam Clegg
2015/05/27 22:30:20
Done.
| |
206 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 206 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
207 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 207 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
208 int tmp_fds[2]; | 208 int tmp_fds[2]; |
209 socketpair(AF_UNIX, SOCK_STREAM, 0, tmp_fds); | 209 socketpair(AF_UNIX, SOCK_STREAM, 0, tmp_fds); |
210 } | 210 } |
211 #else | 211 #endif |
212 | |
213 #if !defined(OS_NACL_NONSFI) | |
212 BPF_TEST_C(NaClNonSfiSandboxTest, | 214 BPF_TEST_C(NaClNonSfiSandboxTest, |
213 socketcall_allowed, | 215 socketcall_allowed, |
214 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 216 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
215 base::ScopedFD fds[2]; | 217 base::ScopedFD fds[2]; |
216 struct msghdr msg = {}; | 218 struct msghdr msg = {}; |
217 struct iovec iov; | 219 struct iovec iov; |
218 std::string payload("foo"); | 220 std::string payload("foo"); |
219 iov.iov_base = &payload[0]; | 221 iov.iov_base = &payload[0]; |
220 iov.iov_len = payload.size(); | 222 iov.iov_len = payload.size(); |
221 msg.msg_iov = &iov; | 223 msg.msg_iov = &iov; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 388 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
387 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 389 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
388 #if defined(__i386__) | 390 #if defined(__i386__) |
389 uintptr_t args[] = {0, 0, 0}; | 391 uintptr_t args[] = {0, 0, 0}; |
390 syscall(__NR_socketcall, SYS_SOCKET, args); | 392 syscall(__NR_socketcall, SYS_SOCKET, args); |
391 #else | 393 #else |
392 syscall(__NR_socket, 0, 0, 0); | 394 syscall(__NR_socket, 0, 0, 0); |
393 #endif | 395 #endif |
394 } | 396 } |
395 | 397 |
396 #if defined(__x86_64__) || defined(__arm__) | |
Mark Seaborn
2015/05/27 21:40:35
Maybe add comment to explain background:
The argu
Sam Clegg
2015/05/27 22:30:20
Done.
| |
397 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | |
398 socketpair, | |
Mark Seaborn
2015/05/27 21:40:35
Maybe rename to socketpair_af_inet_disallowed, to
Sam Clegg
2015/05/27 22:30:20
Done.
| |
399 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | |
400 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | |
401 int fds[2]; | |
402 socketpair(AF_INET, SOCK_STREAM, 0, fds); | |
403 } | |
404 #endif | |
405 | |
406 BPF_TEST_C(NaClNonSfiSandboxTest, | 398 BPF_TEST_C(NaClNonSfiSandboxTest, |
407 fcntl_SETFD_allowed, | 399 fcntl_SETFD_allowed, |
408 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { | 400 nacl::nonsfi::NaClNonSfiBPFSandboxPolicy) { |
409 base::ScopedFD fds[2]; | 401 base::ScopedFD fds[2]; |
410 DoPipe(fds); | 402 DoPipe(fds); |
411 BPF_ASSERT_EQ(0, fcntl(fds[0].get(), F_SETFD, FD_CLOEXEC)); | 403 BPF_ASSERT_EQ(0, fcntl(fds[0].get(), F_SETFD, FD_CLOEXEC)); |
412 } | 404 } |
413 | 405 |
414 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, | 406 BPF_DEATH_TEST_C(NaClNonSfiSandboxTest, |
415 fcntl_SETFD, | 407 fcntl_SETFD, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 RESTRICT_SYSCALL_EPERM_TEST(ptrace); | 666 RESTRICT_SYSCALL_EPERM_TEST(ptrace); |
675 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); | 667 RESTRICT_SYSCALL_EPERM_TEST(set_robust_list); |
676 #if defined(__i386__) || defined(__x86_64__) | 668 #if defined(__i386__) || defined(__x86_64__) |
677 RESTRICT_SYSCALL_EPERM_TEST(time); | 669 RESTRICT_SYSCALL_EPERM_TEST(time); |
678 #endif | 670 #endif |
679 | 671 |
680 } // namespace | 672 } // namespace |
681 | 673 |
682 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER && | 674 #endif // !ADDRESS_SANITIZER && !THREAD_SANITIZER && |
683 // !MEMORY_SANITIZER && !LEAK_SANITIZER | 675 // !MEMORY_SANITIZER && !LEAK_SANITIZER |
OLD | NEW |