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

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

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

Powered by Google App Engine
This is Rietveld 408576698