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

Unified Diff: content/zygote/zygote_main_linux.cc

Issue 23830004: Linux Zygote: add sanity checks and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/zygote/zygote_main_linux.cc
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc
index 1f0e9f5fb52de28caafcfd8007bf7267e2d70376..3ae08e54b397f0293da2e71c908f9aad4c6859da 100644
--- a/content/zygote/zygote_main_linux.cc
+++ b/content/zygote/zygote_main_linux.cc
@@ -16,10 +16,7 @@
#include "base/basictypes.h"
#include "base/command_line.h"
-#include "base/containers/hash_tables.h"
-#include "base/files/file_path.h"
#include "base/linux_util.h"
-#include "base/memory/scoped_ptr.h"
#include "base/native_library.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
@@ -304,6 +301,8 @@ static void PreSandboxInit() {
#if defined(ENABLE_WEBRTC)
InitializeWebRtcModule();
#endif
+ SkFontConfigInterface::SetGlobal(
+ new FontConfigIPC(Zygote::kMagicSandboxIPCDescriptor))->unref();
}
// Do nothing here
@@ -384,16 +383,22 @@ static bool CreateInitProcessReaper() {
// This will set the *using_suid_sandbox variable to true if the SUID sandbox
// is enabled. This does not necessarily exclude other types of sandboxing.
-static bool EnterSandbox(sandbox::SetuidSandboxClient* setuid_sandbox,
- bool* using_suid_sandbox, bool* has_started_new_init) {
+static bool EnterSuidSandbox(LinuxSandbox* linux_sandbox,
+ bool* using_suid_sandbox,
+ bool* has_started_new_init) {
*using_suid_sandbox = false;
*has_started_new_init = false;
+
+ sandbox::SetuidSandboxClient* setuid_sandbox =
+ linux_sandbox->setuid_sandbox_client();
+
if (!setuid_sandbox)
return false;
PreSandboxInit();
- SkFontConfigInterface::SetGlobal(
- new FontConfigIPC(Zygote::kMagicSandboxIPCDescriptor))->unref();
+
+ // Check that the pre-sandbox initialization didn't spawn threads.
+ DCHECK(linux_sandbox->IsSingleThreaded());
if (setuid_sandbox->IsSuidSandboxChild()) {
// Use the SUID sandbox. This still allows the seccomp sandbox to
@@ -461,9 +466,6 @@ bool ZygoteMain(const MainFunctionParams& params,
// This will pre-initialize the various sandboxes that need it.
linux_sandbox->PreinitializeSandbox();
- sandbox::SetuidSandboxClient* setuid_sandbox =
- linux_sandbox->setuid_sandbox_client();
-
if (forkdelegate != NULL) {
VLOG(1) << "ZygoteMain: initializing fork delegate";
forkdelegate->Init(Zygote::kMagicSandboxIPCDescriptor);
@@ -475,14 +477,17 @@ bool ZygoteMain(const MainFunctionParams& params,
bool using_suid_sandbox = false;
bool has_started_new_init = false;
- if (!EnterSandbox(setuid_sandbox,
- &using_suid_sandbox,
- &has_started_new_init)) {
+ if (!EnterSuidSandbox(linux_sandbox,
+ &using_suid_sandbox,
+ &has_started_new_init)) {
LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: "
<< errno << ")";
return false;
}
+ sandbox::SetuidSandboxClient* setuid_sandbox =
+ linux_sandbox->setuid_sandbox_client();
+
if (setuid_sandbox->IsInNewPIDNamespace() && !has_started_new_init) {
LOG(ERROR) << "The SUID sandbox created a new PID namespace but Zygote "
"is not the init process. Please, make sure the SUID "
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698