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 <sys/syscall.h> | 5 #include <sys/syscall.h> |
6 #include <sys/utsname.h> | 6 #include <sys/utsname.h> |
7 | 7 |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 11 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
12 #include "sandbox/linux/seccomp-bpf/syscall.h" | 12 #include "sandbox/linux/seccomp-bpf/syscall.h" |
13 #include "sandbox/linux/seccomp-bpf/verifier.h" | 13 #include "sandbox/linux/seccomp-bpf/verifier.h" |
14 #include "sandbox/linux/services/broker_process.h" | 14 #include "sandbox/linux/services/broker_process.h" |
15 #include "sandbox/linux/services/linux_syscalls.h" | 15 #include "sandbox/linux/services/linux_syscalls.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
| 18 // Workaround for Android's prctl.h file. |
| 19 #if !defined(PR_CAPBSET_READ) |
| 20 #define PR_CAPBSET_READ 23 |
| 21 #define PR_CAPBSET_DROP 24 |
| 22 #endif |
| 23 |
18 using namespace playground2; | 24 using namespace playground2; |
19 using sandbox::BrokerProcess; | 25 using sandbox::BrokerProcess; |
20 | 26 |
21 namespace { | 27 namespace { |
22 | 28 |
23 const int kExpectedReturnValue = 42; | 29 const int kExpectedReturnValue = 42; |
24 | 30 |
25 // This test should execute no matter whether we have kernel support. So, | 31 // This test should execute no matter whether we have kernel support. So, |
26 // we make it a TEST() instead of a BPF_TEST(). | 32 // we make it a TEST() instead of a BPF_TEST(). |
27 TEST(SandboxBpf, CallSupports) { | 33 TEST(SandboxBpf, CallSupports) { |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 DEATH_MESSAGE("Unexpected 64bit argument detected"), | 961 DEATH_MESSAGE("Unexpected 64bit argument detected"), |
956 EqualityWithNegativeArgumentsPolicy) { | 962 EqualityWithNegativeArgumentsPolicy) { |
957 // When expecting a 32bit system call argument, we look at the MSB of the | 963 // When expecting a 32bit system call argument, we look at the MSB of the |
958 // 64bit value and allow both "0" and "-1". But the latter is allowed only | 964 // 64bit value and allow both "0" and "-1". But the latter is allowed only |
959 // iff the LSB was negative. So, this death test should error out. | 965 // iff the LSB was negative. So, this death test should error out. |
960 BPF_ASSERT(SandboxSyscall(__NR_uname, 0xFFFFFFFF00000000ll) == -1); | 966 BPF_ASSERT(SandboxSyscall(__NR_uname, 0xFFFFFFFF00000000ll) == -1); |
961 } | 967 } |
962 #endif | 968 #endif |
963 | 969 |
964 } // namespace | 970 } // namespace |
OLD | NEW |