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

Unified Diff: sandbox/win/src/sandbox_policy_base.cc

Issue 319573006: Add sandbox support for process memory limits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review Created 6 years, 6 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
Index: sandbox/win/src/sandbox_policy_base.cc
diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc
index 758a8bea58c59a226a0463f724bcc32e770422fb..89a605077de851b509cda54ecde11e53ccb0a623 100644
--- a/sandbox/win/src/sandbox_policy_base.cc
+++ b/sandbox/win/src/sandbox_policy_base.cc
@@ -80,6 +80,8 @@ PolicyBase::PolicyBase()
initial_level_(USER_LOCKDOWN),
job_level_(JOB_LOCKDOWN),
ui_exceptions_(0),
+ process_memory_limit_(0),
cpu_(ooo_6.6-7.5) 2014/06/06 19:44:05 maybe rename to memory_limit_ ?
jschuh 2014/06/06 20:13:14 Sure.
+ terminate_on_memory_limit_(false),
use_alternate_desktop_(false),
use_alternate_winstation_(false),
file_system_init_(false),
@@ -167,6 +169,19 @@ ResultCode PolicyBase::SetJobLevel(JobLevel job_level, uint32 ui_exceptions) {
return SBOX_ALL_OK;
}
+ResultCode PolicyBase::SetJobMemoryLimit(size_t limit, bool terminate) {
+ if (limit && job_level_ == JOB_NONE) {
+ return SBOX_ERROR_BAD_PARAMS;
+ }
+ process_memory_limit_ = limit;
+ terminate_on_memory_limit_ = terminate;
+ return SBOX_ALL_OK;
+}
+
+bool PolicyBase::WillTerminateOnJobMemoryLimit() const {
+ return terminate_on_memory_limit_;
+}
+
ResultCode PolicyBase::SetAlternateDesktop(bool alternate_winstation) {
use_alternate_desktop_ = true;
use_alternate_winstation_ = alternate_winstation;
@@ -459,6 +474,7 @@ ResultCode PolicyBase::MakeJobObject(HANDLE* job) {
if (job_level_ != JOB_NONE) {
// Create the windows job object.
Job job_obj;
+ job_obj.SetProcessMemoryLimit(process_memory_limit_);
DWORD result = job_obj.Init(job_level_, NULL, ui_exceptions_);
cpu_(ooo_6.6-7.5) 2014/06/06 19:44:05 seems best to move to job_obj.Init(..., memory_lim
jschuh 2014/06/06 20:13:14 Sure.
if (ERROR_SUCCESS != result) {
return SBOX_ERROR_GENERIC;

Powered by Google App Engine
This is Rietveld 408576698