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

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

Issue 10826093: Create a LinuxSandbox class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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 | Annotate | Revision Log
OLDNEW
(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 #ifndef CONTENT_COMMON_SANDBOX_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_LINUX_H_
7
8 #include "content/public/common/sandbox_linux.h"
9
10 // TODO(jln) move this somewhere else.
11 #if defined(__i386__) || defined(__x86_64__)
12 #define SECCOMP_BPF_SANDBOX
13 #endif
14
15 template <typename T> struct DefaultSingletonTraits;
16 namespace sandbox { class SetuidSandboxClient; }
17
18 namespace content {
19
20 // A singleton class to represent and change our sandboxing state for the
21 // three main Linux sandboxes.
22 class LinuxSandbox {
23 public:
24 // This is a list of sandbox IPC methods which the renderer may send to the
25 // sandbox host. See http://code.google.com/p/chromium/wiki/LinuxSandboxIPC
26 // This isn't the full list, values < 32 are reserved for methods called from
27 // Skia.
28 enum LinuxSandboxIPCMethods {
29 METHOD_GET_FONT_FAMILY_FOR_CHARS = 32,
30 METHOD_LOCALTIME = 33,
31 METHOD_GET_CHILD_WITH_INODE = 34,
32 METHOD_GET_STYLE_FOR_STRIKE = 35,
33 METHOD_MAKE_SHARED_MEMORY_SEGMENT = 36,
34 METHOD_MATCH_WITH_FALLBACK = 37,
35 };
36
37 // Get our singleton instance.
38 static LinuxSandbox* GetInstance();
39
40 // Do some initialization that can only be done before any of the sandboxes
41 // is enabled.
42 //
43 // There are two versions of this function. One takes a process_type
44 // as an argument, the other doesn't.
45 // It may be necessary to call PreinitializeSandbox before knowing the
46 // process type (this is for instance the case with the Zygote).
47 // In that case, it is crucial that PreinitializeSandboxFinish() gets
48 // called for every child process.
49 // TODO(markus,jln) we know this is not always done at the moment
50 // (crbug.com/139877).
51 void PreinitializeSandbox(const std::string& process_type);
52 // These should be called together.
53 void PreinitializeSandbox();
54 void PreinitializeSandboxFinish(const std::string& process_type);
55
56 // Returns the Status of the sandbox. Can only be queried if we went through
57 // PreinitializeSandbox(). This is a bitmask and uses the constants defined
58 // in "enum LinuxSandboxStatus".
59 // Since we need to provide the status before the sandboxes are actually
60 // started, this returns what will actually happen once the various Start*
61 // functions are called from inside a renderer.
62 int GetStatus();
63
64 // Simple accessor for our instance of the setuid sandbox. Will never return
65 // NULL.
66 // There is no StartSetuidSandbox(), the SetuidSandboxClient instance should
67 // be used directly.
68 sandbox::SetuidSandboxClient* setuid_sandbox();
69
70 // Check the policy and eventually start the seccomp-legacy sandbox.
71 bool StartSeccompLegacy(const std::string& process_type);
72 // Check the policy and eventually start the seccomp-legacy sandbox.
Jorge Lucangeli Obes 2012/08/01 22:53:57 seccomp-bpf
jln (very slow on Chromium) 2012/08/01 22:57:36 Not my day. Thanks.
73 // TODO(jln): not implemented at the moment.
74 bool StartSeccompBpf(const std::string& process_type);
75
76 private:
77 friend struct DefaultSingletonTraits<LinuxSandbox>;
78 bool ShouldEnableSeccompLegacy(const std::string& process_type);
79
80 int proc_fd_;
81 bool pre_initialized_; // Have we been through PreinitializeSandbox() ?
82 bool seccomp_legacy_supported_; // Accurate if pre_initialized_.
83 sandbox::SetuidSandboxClient* setuid_sandbox_;
84 LinuxSandbox();
85 ~LinuxSandbox();
86 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_COMMON_SANDBOX_LINUX_H_
92
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698