| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ | 5 #ifndef CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ |
| 6 #define CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ | 6 #define CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" | 12 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" |
| 13 | 13 |
| 14 namespace sandbox { | 14 namespace sandbox { |
| 15 namespace syscall_broker { | 15 namespace syscall_broker { |
| 16 class BrokerFilePermission; |
| 16 class BrokerProcess; | 17 class BrokerProcess; |
| 17 } | 18 } |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 class GpuProcessPolicy : public SandboxBPFBasePolicy { | 23 class GpuProcessPolicy : public SandboxBPFBasePolicy { |
| 23 public: | 24 public: |
| 24 GpuProcessPolicy(); | 25 GpuProcessPolicy(); |
| 25 explicit GpuProcessPolicy(bool allow_mincore); | 26 explicit GpuProcessPolicy(bool allow_mincore); |
| 26 ~GpuProcessPolicy() override; | 27 ~GpuProcessPolicy() override; |
| 27 | 28 |
| 28 sandbox::bpf_dsl::ResultExpr EvaluateSyscall( | 29 sandbox::bpf_dsl::ResultExpr EvaluateSyscall( |
| 29 int system_call_number) const override; | 30 int system_call_number) const override; |
| 30 | 31 |
| 31 bool PreSandboxHook() override; | 32 bool PreSandboxHook() override; |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 // Start a broker process to handle open() inside the sandbox. | 35 // Start a broker process to handle open() inside the sandbox. |
| 35 // |broker_sandboxer_allocator| is a function pointer which can allocate a | 36 // |broker_sandboxer_allocator| is a function pointer which can allocate a |
| 36 // suitable sandbox policy for the broker process itself. | 37 // suitable sandbox policy for the broker process itself. |
| 37 // |read_whitelist_extra| and |write_whitelist_extra| are lists of file | 38 // |permissions_extra| is a list of file permissions |
| 38 // names that should be whitelisted by the broker process, in addition to | 39 // that should be whitelisted by the broker process, in addition to |
| 39 // the basic ones. | 40 // the basic ones. |
| 40 void InitGpuBrokerProcess( | 41 void InitGpuBrokerProcess( |
| 41 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), | 42 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), |
| 42 const std::vector<std::string>& read_whitelist_extra, | 43 const std::vector<sandbox::syscall_broker::BrokerFilePermission>& |
| 43 const std::vector<std::string>& write_whitelist_extra); | 44 permissions_extra); |
| 44 | 45 |
| 45 sandbox::syscall_broker::BrokerProcess* broker_process() { | 46 sandbox::syscall_broker::BrokerProcess* broker_process() { |
| 46 return broker_process_; | 47 return broker_process_; |
| 47 } | 48 } |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 // A BrokerProcess is a helper that is started before the sandbox is engaged | 51 // A BrokerProcess is a helper that is started before the sandbox is engaged |
| 51 // and will serve requests to access files over an IPC channel. The client of | 52 // and will serve requests to access files over an IPC channel. The client of |
| 52 // this runs from a SIGSYS handler triggered by the seccomp-bpf sandbox. | 53 // this runs from a SIGSYS handler triggered by the seccomp-bpf sandbox. |
| 53 // This should never be destroyed, as after the sandbox is started it is | 54 // This should never be destroyed, as after the sandbox is started it is |
| 54 // vital to the process. | 55 // vital to the process. |
| 55 // This is allocated by InitGpuBrokerProcess, called from PreSandboxHook(), | 56 // This is allocated by InitGpuBrokerProcess, called from PreSandboxHook(), |
| 56 // which executes iff the sandbox is going to be enabled afterwards. | 57 // which executes iff the sandbox is going to be enabled afterwards. |
| 57 sandbox::syscall_broker::BrokerProcess* broker_process_; | 58 sandbox::syscall_broker::BrokerProcess* broker_process_; |
| 58 | 59 |
| 59 // eglCreateWindowSurface() needs mincore(). | 60 // eglCreateWindowSurface() needs mincore(). |
| 60 bool allow_mincore_; | 61 bool allow_mincore_; |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(GpuProcessPolicy); | 63 DISALLOW_COPY_AND_ASSIGN(GpuProcessPolicy); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 } // namespace content | 66 } // namespace content |
| 66 | 67 |
| 67 #endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ | 68 #endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_ |
| OLD | NEW |