0

Skip creating zygote with --no-zygote flag

This CL fixed the side effect of
https://chromium-review.googlesource.com/c/chromium/src/+/509529
By above commit, browser creates zygote process even with --no-sandbox
--no-zygote flags. Zygote process should not be created with
--no-sandbox --no-zygote flags.

Bug: 895732
Change-Id: I2e2bebbab69b4ac5047cc33aa346942b83a67183
Reviewed-on: https://chromium-review.googlesource.com/c/1282687
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602590}
This commit is contained in:
Wanchang, Ryu
2018-10-25 02:56:08 +00:00
committed by Commit Bot
parent f90d5ca231
commit fc1b6354e0
4 changed files with 24 additions and 5 deletions
content
services/service_manager/zygote/host

@ -281,10 +281,12 @@ void InitializeZygoteSandboxForBrowserProcess(
// zygote are both disabled. It initializes the sandboxed process socket.
SandboxHostLinux::GetInstance()->Init();
if (parsed_command_line.HasSwitch(switches::kNoZygote) &&
!parsed_command_line.HasSwitch(service_manager::switches::kNoSandbox)) {
LOG(ERROR) << "--no-sandbox should be used together with --no--zygote";
exit(EXIT_FAILURE);
if (parsed_command_line.HasSwitch(switches::kNoZygote)) {
if (!parsed_command_line.HasSwitch(service_manager::switches::kNoSandbox)) {
LOG(ERROR) << "--no-sandbox should be used together with --no--zygote";
exit(EXIT_FAILURE);
}
return;
}
// Tickle the zygote host so it forks now.

@ -1106,7 +1106,10 @@ test("content_browsertests") {
if (is_linux) {
sources += [ "../zygote/zygote_browsertest.cc" ]
deps += [ "//ui/gfx:test_support" ]
deps += [
"//services/service_manager/zygote",
"//ui/gfx:test_support",
]
}
if (is_android) {

@ -14,6 +14,10 @@
#include "content/shell/browser/shell.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/sandbox/switches.h"
#include "services/service_manager/zygote/common/zygote_buildflags.h"
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
#include "services/service_manager/zygote/host/zygote_host_impl_linux.h"
#endif
namespace content {
@ -67,4 +71,13 @@ IN_PROC_BROWSER_TEST_F(LinuxZygoteDisabledBrowserTest,
}
#endif
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
IN_PROC_BROWSER_TEST_F(LinuxZygoteDisabledBrowserTest,
NoZygoteWhenZygoteDisabled) {
NavigateToURL(shell(), GURL("data:text/html,start page"));
EXPECT_FALSE(service_manager::ZygoteHostImpl::GetInstance()->HasZygote());
}
#endif
} // namespace content

@ -46,6 +46,7 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_ZYGOTE) ZygoteHostImpl
void AdjustRendererOOMScore(base::ProcessHandle process_handle,
int score) override;
bool HasZygote() { return !zygote_pids_.empty(); }
private:
friend struct base::DefaultSingletonTraits<ZygoteHostImpl>;