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

Unified Diff: content/common/sandbox_linux/sandbox_linux.cc

Issue 915823002: Namespace sandbox: add important security checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 | « content/common/sandbox_linux/sandbox_linux.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_linux/sandbox_linux.cc
diff --git a/content/common/sandbox_linux/sandbox_linux.cc b/content/common/sandbox_linux/sandbox_linux.cc
index 998a0fe0b49fda8f1fac98a425d01f800cef2d6b..f6f95a9c5bcf369f7cad7720aa6b868a9c994489 100644
--- a/content/common/sandbox_linux/sandbox_linux.cc
+++ b/content/common/sandbox_linux/sandbox_linux.cc
@@ -28,10 +28,12 @@
#include "base/sys_info.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "content/common/sandbox_linux/sandbox_debug_handling_linux.h"
#include "content/common/sandbox_linux/sandbox_linux.h"
#include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_linux.h"
+#include "sandbox/linux/services/credentials.h"
#include "sandbox/linux/services/namespace_sandbox.h"
#include "sandbox/linux/services/proc_util.h"
#include "sandbox/linux/services/thread_helpers.h"
@@ -182,6 +184,27 @@ void LinuxSandbox::PreinitializeSandbox() {
pre_initialized_ = true;
}
+void LinuxSandbox::EngageNamespaceSandbox() {
+ CHECK(pre_initialized_);
+ // Check being in a new PID namespace created by the namespace sandbox and
+ // being the init process.
+ CHECK(sandbox::NamespaceSandbox::InNewPidNamespace());
+ const pid_t pid = getpid();
+ CHECK_EQ(1, pid);
+
+ CHECK(sandbox::Credentials::MoveToNewUserNS());
+ // Note: this requires SealSandbox() to be called later in this process to be
+ // safe, as this class is keeping a file descriptor to /proc.
+ CHECK(!HasOpenDirectories());
+ CHECK(sandbox::Credentials::DropFileSystemAccess());
+ CHECK(IsSingleThreaded());
+ CHECK(sandbox::Credentials::DropAllCapabilities());
+
+ // This needs to happen after moving to a new user NS, since doing so involves
+ // writing the UID/GID map.
+ CHECK(SandboxDebugHandling::SetDumpableStatusAndHandlers());
+}
+
std::vector<int> LinuxSandbox::GetFileDescriptorsToClose() {
std::vector<int> fds;
if (proc_fd_ >= 0) {
« no previous file with comments | « content/common/sandbox_linux/sandbox_linux.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698