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 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h" | 5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_test_runner.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "sandbox/linux/bpf_dsl/policy.h" | 12 #include "sandbox/linux/bpf_dsl/policy.h" |
12 #include "sandbox/linux/seccomp-bpf/die.h" | 13 #include "sandbox/linux/seccomp-bpf/die.h" |
13 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 14 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
14 #include "sandbox/linux/system_headers/linux_filter.h" | 15 #include "sandbox/linux/system_headers/linux_filter.h" |
15 #include "sandbox/linux/tests/unit_tests.h" | 16 #include "sandbox/linux/tests/unit_tests.h" |
16 | 17 |
17 namespace sandbox { | 18 namespace sandbox { |
18 | 19 |
19 SandboxBPFTestRunner::SandboxBPFTestRunner( | 20 SandboxBPFTestRunner::SandboxBPFTestRunner( |
20 BPFTesterDelegate* bpf_tester_delegate) | 21 BPFTesterDelegate* bpf_tester_delegate) |
21 : bpf_tester_delegate_(bpf_tester_delegate) { | 22 : bpf_tester_delegate_(bpf_tester_delegate) { |
22 } | 23 } |
23 | 24 |
24 SandboxBPFTestRunner::~SandboxBPFTestRunner() { | 25 SandboxBPFTestRunner::~SandboxBPFTestRunner() { |
25 } | 26 } |
26 | 27 |
27 void SandboxBPFTestRunner::Run() { | 28 void SandboxBPFTestRunner::Run() { |
28 DCHECK(bpf_tester_delegate_); | 29 DCHECK(bpf_tester_delegate_); |
29 sandbox::Die::EnableSimpleExit(); | 30 sandbox::Die::EnableSimpleExit(); |
30 | 31 |
31 scoped_ptr<bpf_dsl::Policy> policy = | 32 std::unique_ptr<bpf_dsl::Policy> policy = |
32 bpf_tester_delegate_->GetSandboxBPFPolicy(); | 33 bpf_tester_delegate_->GetSandboxBPFPolicy(); |
33 | 34 |
34 if (sandbox::SandboxBPF::SupportsSeccompSandbox( | 35 if (sandbox::SandboxBPF::SupportsSeccompSandbox( |
35 SandboxBPF::SeccompLevel::SINGLE_THREADED)) { | 36 SandboxBPF::SeccompLevel::SINGLE_THREADED)) { |
36 // Initialize and then start the sandbox with our custom policy | 37 // Initialize and then start the sandbox with our custom policy |
37 sandbox::SandboxBPF sandbox(policy.release()); | 38 sandbox::SandboxBPF sandbox(policy.release()); |
38 SANDBOX_ASSERT(sandbox.StartSandbox( | 39 SANDBOX_ASSERT(sandbox.StartSandbox( |
39 sandbox::SandboxBPF::SeccompLevel::SINGLE_THREADED)); | 40 sandbox::SandboxBPF::SeccompLevel::SINGLE_THREADED)); |
40 | 41 |
41 // Run the actual test. | 42 // Run the actual test. |
(...skipping 14 matching lines...) Expand all Loading... |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 bool SandboxBPFTestRunner::ShouldCheckForLeaks() const { | 60 bool SandboxBPFTestRunner::ShouldCheckForLeaks() const { |
60 // LSAN requires being able to use ptrace() and other system calls that could | 61 // LSAN requires being able to use ptrace() and other system calls that could |
61 // be denied. | 62 // be denied. |
62 return false; | 63 return false; |
63 } | 64 } |
64 | 65 |
65 } // namespace sandbox | 66 } // namespace sandbox |
OLD | NEW |