| 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 "
|
|
|