allow_new_privileges_in_unsandboxed_child_processes.patch 1.5 KB

123456789101112131415161718192021222324252627282930
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Jeremy Apthorp <[email protected]>
  3. Date: Mon, 26 Aug 2019 12:02:51 -0700
  4. Subject: allow new privileges in unsandboxed child processes
  5. This allows unsandboxed renderers to launch setuid processes on Linux.
  6. diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc
  7. index c1b5d30fd927feaeb3e068adc72edafa871ae8cd..7534eef2cfe57044be038632ab040b4df1e7ef9e 100644
  8. --- a/content/browser/child_process_launcher_helper_linux.cc
  9. +++ b/content/browser/child_process_launcher_helper_linux.cc
  10. @@ -53,6 +53,18 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
  11. if (GetProcessType() == switches::kRendererProcess) {
  12. const int sandbox_fd = SandboxHostLinux::GetInstance()->GetChildSocket();
  13. options->fds_to_remap.push_back(std::make_pair(sandbox_fd, GetSandboxFD()));
  14. +
  15. + // (For Electron), if we're launching without zygote, that means we're
  16. + // launching an unsandboxed process (since all sandboxed processes are
  17. + // forked from the zygote). Relax the allow_new_privs option to permit
  18. + // launching suid processes from unsandboxed renderers.
  19. + ZygoteHandle zygote_handle =
  20. + base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote)
  21. + ? nullptr
  22. + : delegate_->GetZygote();
  23. + if (!zygote_handle) {
  24. + options->allow_new_privs = true;
  25. + }
  26. }
  27. options->environment = delegate_->GetEnvironment();