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

Side by Side Diff: content/common/sandbox_linux/sandbox_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_LINUX_H_ 5 #ifndef CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_
6 #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_ 6 #define CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "content/public/common/sandbox_linux.h" 13 #include "content/public/common/sandbox_linux.h"
13 14
14 #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ 15 #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
15 defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \ 16 defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
16 defined(UNDEFINED_SANITIZER) 17 defined(UNDEFINED_SANITIZER)
17 #include <sanitizer/common_interface_defs.h> 18 #include <sanitizer/common_interface_defs.h>
18 #define ANY_OF_AMTLU_SANITIZER 1 19 #define ANY_OF_AMTLU_SANITIZER 1
(...skipping 23 matching lines...) Expand all
42 METHOD_MAKE_SHARED_MEMORY_SEGMENT = 36, 43 METHOD_MAKE_SHARED_MEMORY_SEGMENT = 36,
43 METHOD_MATCH_WITH_FALLBACK = 37, 44 METHOD_MATCH_WITH_FALLBACK = 37,
44 }; 45 };
45 46
46 // Get our singleton instance. 47 // Get our singleton instance.
47 static LinuxSandbox* GetInstance(); 48 static LinuxSandbox* GetInstance();
48 49
49 // Do some initialization that can only be done before any of the sandboxes 50 // Do some initialization that can only be done before any of the sandboxes
50 // are enabled. If using the setuid sandbox, this should be called manually 51 // are enabled. If using the setuid sandbox, this should be called manually
51 // before the setuid sandbox is engaged. 52 // before the setuid sandbox is engaged.
53 // Security: When this runs, it is imperative that either InitializeSandbox()
54 // runs as well or that all file descriptors returned in
55 // GetFileDescriptorsToClose()
Jorge Lucangeli Obes 2014/11/24 23:48:33 This formatting is super weird.
jln (very slow on Chromium) 2014/11/25 01:30:48 Yeah, sorry clang-format seems to always start a n
56 // get closed.
57 // Otherwise file descriptors that bypass the security of the setuid sandbox
58 // would be kept open. One must be particularly careful if a process performs
59 // a fork().
52 void PreinitializeSandbox(); 60 void PreinitializeSandbox();
53 61
62 // Return a list of file descriptors to close if PreinitializeSandbox() ran
63 // but
Jorge Lucangeli Obes 2014/11/24 23:48:33 Ditto. Are you trying to keep function names in th
jln (very slow on Chromium) 2014/11/25 01:30:48 Done.
64 // InitializeSandbox won't. Avoid using.
65 // TODO(jln): get rid of this hack.
66 std::vector<int> GetFileDescriptorsToClose();
67
54 // Initialize the sandbox with the given pre-built configuration. Currently 68 // Initialize the sandbox with the given pre-built configuration. Currently
55 // seccomp-bpf and address space limitations (the setuid sandbox works 69 // seccomp-bpf and address space limitations (the setuid sandbox works
56 // differently and is set-up in the Zygote). This will instantiate the 70 // differently and is set-up in the Zygote). This will instantiate the
57 // LinuxSandbox singleton if it doesn't already exist. 71 // LinuxSandbox singleton if it doesn't already exist.
58 // This function should only be called without any thread running. 72 // This function should only be called without any thread running.
59 static bool InitializeSandbox(); 73 static bool InitializeSandbox();
60 74
61 // Stop |thread| in a way that can be trusted by the sandbox. 75 // Stop |thread| in a way that can be trusted by the sandbox.
62 static void StopThread(base::Thread* thread); 76 static void StopThread(base::Thread* thread);
63 77
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // allow for sandbox bypasses. It needs to be closed before we consider 139 // allow for sandbox bypasses. It needs to be closed before we consider
126 // ourselves sandboxed. 140 // ourselves sandboxed.
127 int proc_fd_; 141 int proc_fd_;
128 bool seccomp_bpf_started_; 142 bool seccomp_bpf_started_;
129 // The value returned by GetStatus(). Gets computed once and then cached. 143 // The value returned by GetStatus(). Gets computed once and then cached.
130 int sandbox_status_flags_; 144 int sandbox_status_flags_;
131 // Did PreinitializeSandbox() run? 145 // Did PreinitializeSandbox() run?
132 bool pre_initialized_; 146 bool pre_initialized_;
133 bool seccomp_bpf_supported_; // Accurate if pre_initialized_. 147 bool seccomp_bpf_supported_; // Accurate if pre_initialized_.
134 bool yama_is_enforcing_; // Accurate if pre_initialized_. 148 bool yama_is_enforcing_; // Accurate if pre_initialized_.
149 bool initialize_sandbox_ran_; // InitializeSandbox() was called.
135 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client_; 150 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client_;
136 #if defined(ANY_OF_AMTLU_SANITIZER) 151 #if defined(ANY_OF_AMTLU_SANITIZER)
137 scoped_ptr<__sanitizer_sandbox_arguments> sanitizer_args_; 152 scoped_ptr<__sanitizer_sandbox_arguments> sanitizer_args_;
138 #endif 153 #endif
139 154
140 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox); 155 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox);
141 }; 156 };
142 157
143 } // namespace content 158 } // namespace content
144 159
145 #endif // CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_ 160 #endif // CONTENT_COMMON_SANDBOX_LINUX_SANDBOX_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698