electron/patches/chromium/support_mixed_sandbox_with_zygote.patch
Electron Bot a4de915b74
chore: bump chromium to d66c2e32380bf5d1eb5e1fe37faef (master) (#23791)
* chore: bump chromium in DEPS to db7d7b3e7cb2bc925f2abfde526280cfdfc21a41

* Update patches

* chore: bump chromium in DEPS to 5613e1b99a44fcbe22f3910f803ca76903a77ec1

* Update patches

* Network service: Remove primary_network_context bool.

https://chromium-review.googlesource.com/c/chromium/src/+/2204678

* WebContentsObserver now implements OnRendererResponsive

https://chromium-review.googlesource.com/c/chromium/src/+/2211066

* update patches

* Fixup printing patch

* chore: bump chromium in DEPS to e387b972cdd7160c416fa6c64a724e2258aa0218

* update patches

* [printing] Move PrintHostMsg_DidPrintContent_Params to print.mojom

https://chromium-review.googlesource.com/c/chromium/src/+/2212110

* [XProto] Move items from ::x11::XProto to ::x11

https://chromium-review.googlesource.com/c/chromium/src/+/2218476

* revert Add IChromeAccessible

This was added in https://chromium-review.googlesource.com/c/chromium/src/+/2206224 but it breaks WOA builds because third_party/win_build_output/midl/ui/accessibility/platform/arm64 does not exist. The link above says that the new interface is behind a feature flag which is disabled by default so it is safe to remove for now.

* rebaseline ichromeaccessible for Windows arm64

This patch will not be needed once we get the next roll.

* Update to 1b9e01844e8bf1aaafc4a52c0c62af7f56d9637b to get arm64 fix

* update patches

* chore: bump chromium in DEPS to 096aefa04092ea00f7b68d8d19345883f20db3c3

* chore: bump chromium in DEPS to a524a45ffd1d6fd46a7a86138fe2b22df5b6651a

* chore: update patches

* Window Placement: Gate cross-screen fullscreen behavior on permission

https://chromium-review.googlesource.com/c/chromium/src/+/2203268

* chore: add spec for https://crbug.com/1085836

* chore: bump chromium in DEPS to ff6c4f4b826d66c2e32380bf5d1eb5e1fe37faef

* update patches

Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Electron Bot <anonymous@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2020-06-01 16:34:34 -04:00

84 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Wed, 28 Nov 2018 13:20:27 -0800
Subject: support_mixed_sandbox_with_zygote.patch
On Linux, Chromium launches all new renderer processes via a "zygote"
process which has the sandbox pre-initialized (see
//docs/linux_zygote.md). In order to support mixed-sandbox mode, in
which some renderers are launched with the sandbox engaged and others
without it, we need the option to launch non-sandboxed renderers without
going through the zygote.
Chromium already supports a `--no-zygote` flag, but it turns off the
zygote completely, and thus also disables sandboxing. This patch allows
the `--no-zygote` flag to affect renderer processes on a case-by-case
basis, checking immediately prior to launch whether to go through the
zygote or not based on the command-line of the to-be-launched renderer.
This patch could conceivably be upstreamed, as it does not affect
production Chromium (which does not use the `--no-zygote` flag).
However, the patch would need to be reviewed by the security team, as it
does touch a security-sensitive class.
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index f33eb6d5a0e98e06cd3ba318e9b578df4bc9ab2c..0e84525e677131b3428e5fe73dfb7b48bf65a692 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -412,6 +412,11 @@ class RendererSandboxedProcessLauncherDelegate
{
}
+#if BUILDFLAG(USE_ZYGOTE_HANDLE)
+ RendererSandboxedProcessLauncherDelegate(bool use_zygote):
+ use_zygote_(use_zygote) {}
+#endif
+
~RendererSandboxedProcessLauncherDelegate() override {}
#if defined(OS_WIN)
@@ -433,6 +438,9 @@ class RendererSandboxedProcessLauncherDelegate
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
service_manager::ZygoteHandle GetZygote() override {
+ if (!use_zygote_) {
+ return nullptr;
+ }
const base::CommandLine& browser_command_line =
*base::CommandLine::ForCurrentProcess();
base::CommandLine::StringType renderer_prefix =
@@ -447,10 +455,13 @@ class RendererSandboxedProcessLauncherDelegate
return service_manager::SandboxType::kRenderer;
}
-#if defined(OS_WIN)
private:
+#if defined(OS_WIN)
const bool renderer_code_integrity_enabled_;
#endif
+#if BUILDFLAG(USE_ZYGOTE_HANDLE)
+ bool use_zygote_ = true;
+#endif
};
const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey";
@@ -1831,11 +1842,18 @@ bool RenderProcessHostImpl::Init() {
cmd_line->PrependWrapper(renderer_prefix);
AppendRendererCommandLine(cmd_line.get());
+#if BUILDFLAG(USE_ZYGOTE_HANDLE)
+ bool use_zygote = !cmd_line->HasSwitch(switches::kNoZygote);
+ auto delegate = std::make_unique<RendererSandboxedProcessLauncherDelegate>(use_zygote);
+#else
+ auto delegate = std::make_unique<RendererSandboxedProcessLauncherDelegate>();
+#endif
+
// Spawn the child process asynchronously to avoid blocking the UI thread.
// As long as there's no renderer prefix, we can use the zygote process
// at this stage.
child_process_launcher_ = std::make_unique<ChildProcessLauncher>(
- std::make_unique<RendererSandboxedProcessLauncherDelegate>(),
+ std::move(delegate),
std::move(cmd_line), GetID(), this, std::move(mojo_invitation_),
base::BindRepeating(&RenderProcessHostImpl::OnMojoError, id_),
GetV8SnapshotFilesToPreload());