| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| 11 #include <memory> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | 18 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" |
| 19 #include "sandbox/linux/bpf_dsl/policy.h" | 19 #include "sandbox/linux/bpf_dsl/policy.h" |
| 20 #include "sandbox/linux/bpf_dsl/seccomp_macros.h" | 20 #include "sandbox/linux/bpf_dsl/seccomp_macros.h" |
| 21 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" | 21 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 22 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 23 #include "sandbox/linux/syscall_broker/broker_file_permission.h" | 23 #include "sandbox/linux/syscall_broker/broker_file_permission.h" |
| 24 #include "sandbox/linux/syscall_broker/broker_process.h" | 24 #include "sandbox/linux/syscall_broker/broker_process.h" |
| 25 #include "sandbox/linux/system_headers/linux_syscalls.h" | 25 #include "sandbox/linux/system_headers/linux_syscalls.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 | 56 |
| 57 initialized_ = true; | 57 initialized_ = true; |
| 58 } | 58 } |
| 59 bool initialized() { return initialized_; } | 59 bool initialized() { return initialized_; } |
| 60 class syscall_broker::BrokerProcess* broker_process() { | 60 class syscall_broker::BrokerProcess* broker_process() { |
| 61 return broker_process_.get(); | 61 return broker_process_.get(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 bool initialized_; | 65 bool initialized_; |
| 66 scoped_ptr<class syscall_broker::BrokerProcess> broker_process_; | 66 std::unique_ptr<class syscall_broker::BrokerProcess> broker_process_; |
| 67 DISALLOW_COPY_AND_ASSIGN(InitializedOpenBroker); | 67 DISALLOW_COPY_AND_ASSIGN(InitializedOpenBroker); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 intptr_t BrokerOpenTrapHandler(const struct arch_seccomp_data& args, | 70 intptr_t BrokerOpenTrapHandler(const struct arch_seccomp_data& args, |
| 71 void* aux) { | 71 void* aux) { |
| 72 BPF_ASSERT(aux); | 72 BPF_ASSERT(aux); |
| 73 syscall_broker::BrokerProcess* broker_process = | 73 syscall_broker::BrokerProcess* broker_process = |
| 74 static_cast<syscall_broker::BrokerProcess*>(aux); | 74 static_cast<syscall_broker::BrokerProcess*>(aux); |
| 75 switch (args.nr) { | 75 switch (args.nr) { |
| 76 case __NR_faccessat: // access is a wrapper of faccessat in android | 76 case __NR_faccessat: // access is a wrapper of faccessat in android |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 BPF_ASSERT(cpu_info_access == 0); | 173 BPF_ASSERT(cpu_info_access == 0); |
| 174 int cpu_info_fd = open("/proc/cpuinfo", O_RDONLY); | 174 int cpu_info_fd = open("/proc/cpuinfo", O_RDONLY); |
| 175 BPF_ASSERT(cpu_info_fd >= 0); | 175 BPF_ASSERT(cpu_info_fd >= 0); |
| 176 char buf[1024]; | 176 char buf[1024]; |
| 177 BPF_ASSERT(read(cpu_info_fd, buf, sizeof(buf)) > 0); | 177 BPF_ASSERT(read(cpu_info_fd, buf, sizeof(buf)) > 0); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace | 180 } // namespace |
| 181 | 181 |
| 182 } // namespace sandbox | 182 } // namespace sandbox |
| OLD | NEW |