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

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 // Do some initialization that can only be done before any of the sandboxes
40 // is enabled.
41 //
42 // There are two versions of this function. One takes a process_type
43 // as an argument, the other doesn't.
44 // It may be necessary to call PreinitializeSandbox before knowing the
45 // process type (this is for instance the case with the Zygote).
46 // In that case, it is crucial that PreinitializeSandboxFinish() gets
47 // called for every child process.
48 // TODO(markus,jln) we know this is not always done at the moment
49 // (crbug.com/139877).
50 void PreinitializeSandbox(const std::string& process_type);
51 // These should be called together.
52 void PreinitializeSandbox();
53 void PreinitializeSandboxFinish(const std::string& process_type);
Markus (顧孟勤) 2012/08/01 22:09:19 In general, I find it really hard to read without
54 // Returns the Status of the sandbox. Can only be queried if we went through
55 // PreinitlizeSandbox(). This is a bitmask anduses the constants defined in
Markus (顧孟勤) 2012/08/01 22:09:19 spelling: s/Preinitlize/Preinitialize/ s/anduses/a
jln (very slow on Chromium) 2012/08/01 22:21:53 Done.
56 // "enum LinuxSandboxStatus".
57 // Since we need to provide the status before the sandboxes are actually
58 // started, this returns what will actually happen once the various Start*
59 // functions are called from inside a renderer.
60 int GetStatus();
61 // Simple accessor for our instance of the setuid sandbox. Will never return
62 // NULL.
63 // There is no StartSuidSandbox() the SetuidSandboxClient instance should be
64 // used directly.
65 sandbox::SetuidSandboxClient* setuid_sandbox();
66 // Check the policy and eventually the seccomp-legacy sandbox if the policy.
67 bool StartSeccompLegacy(const std::string& process_type);
68 // Check the policy and eventually the seccomp-legacy sandbox if the policy.
69 // TODO(jln): not implemented at the moment.
70 bool StartSeccompBpf(const std::string& process_type);
71
72 private:
73 friend struct DefaultSingletonTraits<LinuxSandbox>;
74 int proc_fd_;
75 bool pre_initialized_; // Have we been through PreinitializeSandbox() ?
76 bool seccomp_legacy_supported_; // Accurate if pre_initialized_.
77 sandbox::SetuidSandboxClient* setuid_sandbox_;
78 LinuxSandbox();
79 ~LinuxSandbox();
80 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox);
81 };
82
83 } // namespace content
84
85 #endif // CONTENT_COMMON_SANDBOX_LINUX_H_
86
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698