Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h

Issue 733303004: Linux sandbox: change API to start the sandbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewrap comment. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_SANDBOX_SECCOMP_BPF_LINUX_H_ 5 #ifndef CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_ 6 #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/scoped_file.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 13
13 namespace sandbox { 14 namespace sandbox {
14 namespace bpf_dsl { 15 namespace bpf_dsl {
15 class Policy; 16 class Policy;
16 } 17 }
17 } 18 }
18 19
19 namespace content { 20 namespace content {
20 21
21 // This class has two main sets of APIs. One can be used to start the sandbox 22 // This class has two main sets of APIs. One can be used to start the sandbox
22 // for internal content process types, the other is indirectly exposed as 23 // for internal content process types, the other is indirectly exposed as
23 // a public content/ API and uses a supplied policy. 24 // a public content/ API and uses a supplied policy.
24 class SandboxSeccompBPF { 25 class SandboxSeccompBPF {
25 public: 26 public:
26 // This is the API to enable a seccomp-bpf sandbox for content/ 27 // This is the API to enable a seccomp-bpf sandbox for content/
27 // process-types: 28 // process-types:
28 // Is the sandbox globally enabled, can anything use it at all ? 29 // Is the sandbox globally enabled, can anything use it at all ?
29 // This looks at global command line flags to see if the sandbox 30 // This looks at global command line flags to see if the sandbox
30 // should be enabled at all. 31 // should be enabled at all.
31 static bool IsSeccompBPFDesired(); 32 static bool IsSeccompBPFDesired();
32 // Should the sandbox be enabled for process_type ? 33 // Should the sandbox be enabled for process_type ?
33 static bool ShouldEnableSeccompBPF(const std::string& process_type); 34 static bool ShouldEnableSeccompBPF(const std::string& process_type);
34 // Check if the kernel supports this sandbox. It's useful to "prewarm" 35 // Check if the kernel supports this sandbox. It's useful to "prewarm"
35 // this, part of the result will be cached. 36 // this, part of the result will be cached.
36 static bool SupportsSandbox(); 37 static bool SupportsSandbox();
37 // Start the sandbox and apply the policy for process_type, depending on 38 // Start the sandbox and apply the policy for process_type, depending on
38 // command line switches. 39 // command line switches.
39 static bool StartSandbox(const std::string& process_type); 40 static bool StartSandbox(const std::string& process_type,
41 base::ScopedFD proc_task_fd);
40 42
41 // This is the API to enable a seccomp-bpf sandbox by using an 43 // This is the API to enable a seccomp-bpf sandbox by using an
42 // external policy. 44 // external policy.
43 static bool StartSandboxWithExternalPolicy( 45 static bool StartSandboxWithExternalPolicy(
44 scoped_ptr<sandbox::bpf_dsl::Policy> policy); 46 scoped_ptr<sandbox::bpf_dsl::Policy> policy,
47 base::ScopedFD proc_task_fd);
45 // The "baseline" policy can be a useful base to build a sandbox policy. 48 // The "baseline" policy can be a useful base to build a sandbox policy.
46 static scoped_ptr<sandbox::bpf_dsl::Policy> GetBaselinePolicy(); 49 static scoped_ptr<sandbox::bpf_dsl::Policy> GetBaselinePolicy();
47 50
48 private: 51 private:
49 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxSeccompBPF); 52 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxSeccompBPF);
50 }; 53 };
51 54
52 } // namespace content 55 } // namespace content
53 56
54 #endif // CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_ 57 #endif // CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_SECCOMP_BPF_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698