OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 6 |
| 7 using playground2::Die; |
| 8 using playground2::Sandbox; |
| 9 |
| 10 namespace sandbox { |
| 11 |
| 12 void BpfTests::TestWrapper(void *void_arg) { |
| 13 TestArgs *arg = reinterpret_cast<TestArgs *>(void_arg); |
| 14 Die::EnableSimpleExit(); |
| 15 if (Sandbox::supportsSeccompSandbox(-1) == |
| 16 Sandbox::STATUS_AVAILABLE) { |
| 17 // Ensure the the sandbox is actually available at this time |
| 18 int proc_fd; |
| 19 BPF_ASSERT((proc_fd = open("/proc", O_RDONLY|O_DIRECTORY)) >= 0); |
| 20 BPF_ASSERT(Sandbox::supportsSeccompSandbox(proc_fd) == |
| 21 Sandbox::STATUS_AVAILABLE); |
| 22 |
| 23 // Initialize and then start the sandbox with our custom policy |
| 24 Sandbox::setProcFd(proc_fd); |
| 25 Sandbox::setSandboxPolicy(arg->policy(), NULL); |
| 26 Sandbox::startSandbox(); |
| 27 arg->test()(); |
| 28 } else { |
| 29 // TODO(markus): (crbug.com/141545) Call the compiler and verify the |
| 30 // policy. That's the least we can do, if we don't have kernel support. |
| 31 Sandbox::setSandboxPolicy(arg->policy(), NULL); |
| 32 } |
| 33 } |
| 34 |
| 35 } // namespace |
OLD | NEW |