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

Side by Side Diff: mandoline/app/desktop/linux_sandbox.cc

Issue 1264463005: mandoline sandbox: prewarm libraries before we raise the sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mandoline/app/desktop/linux_sandbox.h" 5 #include "mandoline/app/desktop/linux_sandbox.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/syscall.h> 8 #include <sys/syscall.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 LinuxSandbox::LinuxSandbox(const std::vector<BrokerFilePermission>& permissions) 92 LinuxSandbox::LinuxSandbox(const std::vector<BrokerFilePermission>& permissions)
93 : broker_(new sandbox::syscall_broker::BrokerProcess(EPERM, permissions)) { 93 : broker_(new sandbox::syscall_broker::BrokerProcess(EPERM, permissions)) {
94 broker_->Init( 94 broker_->Init(
95 base::Bind<bool (*)()>(&sandbox::Credentials::DropAllCapabilities)); 95 base::Bind<bool (*)()>(&sandbox::Credentials::DropAllCapabilities));
96 policy_.reset(new SandboxPolicy(broker_.get())); 96 policy_.reset(new SandboxPolicy(broker_.get()));
97 } 97 }
98 98
99 LinuxSandbox::~LinuxSandbox() {} 99 LinuxSandbox::~LinuxSandbox() {}
100 100
101 // static
102 std::vector<BrokerFilePermission> LinuxSandbox::GetPermissions() {
103 std::vector<BrokerFilePermission> permissions;
104 permissions.push_back(BrokerFilePermission::ReadOnly("/dev/urandom"));
105 permissions.push_back(BrokerFilePermission::ReadOnly("/etc/ld.so.cache"));
106 permissions.push_back(BrokerFilePermission::ReadOnlyRecursive("/lib/"));
107 permissions.push_back(BrokerFilePermission::ReadOnlyRecursive("/usr/lib/"));
108 return permissions;
109 }
110
111 void LinuxSandbox::Warmup() { 101 void LinuxSandbox::Warmup() {
112 proc_fd_ = sandbox::ProcUtil::OpenProc(); 102 proc_fd_ = sandbox::ProcUtil::OpenProc();
113 warmed_up_ = true; 103 warmed_up_ = true;
114 } 104 }
115 105
116 void LinuxSandbox::EngageNamespaceSandbox() { 106 void LinuxSandbox::EngageNamespaceSandbox() {
117 CHECK(warmed_up_); 107 CHECK(warmed_up_);
118 CHECK_EQ(1, getpid()); 108 CHECK_EQ(1, getpid());
119 CHECK(sandbox::NamespaceSandbox::InNewPidNamespace()); 109 CHECK(sandbox::NamespaceSandbox::InNewPidNamespace());
120 CHECK(sandbox::Credentials::MoveToNewUserNS()); 110 CHECK(sandbox::Credentials::MoveToNewUserNS());
(...skipping 15 matching lines...) Expand all
136 // The Broker is now bound to this process and should only be destroyed when 126 // The Broker is now bound to this process and should only be destroyed when
137 // the process exits or is killed. 127 // the process exits or is killed.
138 ANNOTATE_LEAKING_OBJECT_PTR(broker_.release()); 128 ANNOTATE_LEAKING_OBJECT_PTR(broker_.release());
139 } 129 }
140 130
141 void LinuxSandbox::Seal() { 131 void LinuxSandbox::Seal() {
142 proc_fd_.reset(); 132 proc_fd_.reset();
143 } 133 }
144 134
145 } // namespace mandoline 135 } // namespace mandoline
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698