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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_
11 #include "base/callback_forward.h"
12 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
15 namespace syscall_broker
{
16 class BrokerFilePermission
;
23 class GpuProcessPolicy
: public SandboxBPFBasePolicy
{
26 explicit GpuProcessPolicy(bool allow_mincore
);
27 ~GpuProcessPolicy() override
;
29 sandbox::bpf_dsl::ResultExpr
EvaluateSyscall(
30 int system_call_number
) const override
;
32 bool PreSandboxHook() override
;
35 // Start a broker process to handle open() inside the sandbox.
36 // |broker_sandboxer_allocator| is a function pointer which can allocate a
37 // suitable sandbox policy for the broker process itself.
38 // |permissions_extra| is a list of file permissions
39 // that should be whitelisted by the broker process, in addition to
41 void InitGpuBrokerProcess(
42 sandbox::bpf_dsl::Policy
* (*broker_sandboxer_allocator
)(void),
43 const std::vector
<sandbox::syscall_broker::BrokerFilePermission
>&
46 sandbox::syscall_broker::BrokerProcess
* broker_process() {
47 return broker_process_
;
51 // A BrokerProcess is a helper that is started before the sandbox is engaged
52 // and will serve requests to access files over an IPC channel. The client of
53 // this runs from a SIGSYS handler triggered by the seccomp-bpf sandbox.
54 // This should never be destroyed, as after the sandbox is started it is
55 // vital to the process.
56 // This is allocated by InitGpuBrokerProcess, called from PreSandboxHook(),
57 // which executes iff the sandbox is going to be enabled afterwards.
58 sandbox::syscall_broker::BrokerProcess
* broker_process_
;
60 // eglCreateWindowSurface() needs mincore().
63 DISALLOW_COPY_AND_ASSIGN(GpuProcessPolicy
);
66 } // namespace content
68 #endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_GPU_POLICY_LINUX_H_