Index: sandbox/win/src/sandbox_policy_base.cc |
=================================================================== |
--- sandbox/win/src/sandbox_policy_base.cc (revision 156579) |
+++ sandbox/win/src/sandbox_policy_base.cc (working copy) |
@@ -15,6 +15,7 @@ |
#include "sandbox/win/src/handle_policy.h" |
#include "sandbox/win/src/job.h" |
#include "sandbox/win/src/interception.h" |
+#include "sandbox/win/src/process_mitigations.h" |
#include "sandbox/win/src/named_pipe_dispatcher.h" |
#include "sandbox/win/src/named_pipe_policy.h" |
#include "sandbox/win/src/policy_broker.h" |
@@ -53,6 +54,7 @@ |
namespace sandbox { |
SANDBOX_INTERCEPT IntegrityLevel g_shared_delayed_integrity_level; |
+SANDBOX_INTERCEPT MitigationFlags g_shared_delayed_mitigations; |
// Initializes static members. |
HWINSTA PolicyBase::alternate_winstation_handle_ = NULL; |
@@ -70,6 +72,8 @@ |
relaxed_interceptions_(true), |
integrity_level_(INTEGRITY_LEVEL_LAST), |
delayed_integrity_level_(INTEGRITY_LEVEL_LAST), |
+ mitigations_(0), |
+ delayed_mitigations_(0), |
policy_maker_(NULL), |
policy_(NULL) { |
::InitializeCriticalSection(&lock_); |
@@ -276,6 +280,30 @@ |
return SBOX_ALL_OK; |
} |
+ResultCode PolicyBase::SetProcessMitigations( |
+ MitigationFlags flags) { |
+ if (!CanSetProcessMitigationsPreStartup(flags)) |
+ return SBOX_ERROR_BAD_PARAMS; |
+ mitigations_ = flags; |
+ return SBOX_ALL_OK; |
+} |
+ |
+MitigationFlags PolicyBase::GetProcessMitigations() { |
+ return mitigations_; |
+} |
+ |
+ResultCode PolicyBase::SetDelayedProcessMitigations( |
+ MitigationFlags flags) { |
+ if (!CanSetProcessMitigationsPostStartup(flags)) |
+ return SBOX_ERROR_BAD_PARAMS; |
+ delayed_mitigations_ = flags; |
+ return SBOX_ALL_OK; |
+} |
+ |
+MitigationFlags PolicyBase::GetDelayedProcessMitigations() { |
+ return delayed_mitigations_; |
+} |
+ |
void PolicyBase::SetStrictInterceptions() { |
relaxed_interceptions_ = false; |
} |
@@ -450,6 +478,11 @@ |
if (NULL != policy_) |
policy_maker_->Done(); |
+ if (!ApplyProcessMitigationsToSuspendedProcess(target->Process(), |
+ mitigations_)) { |
+ return false; |
+ } |
+ |
if (!SetupAllInterceptions(target)) |
return false; |
@@ -469,6 +502,19 @@ |
if (SBOX_ALL_OK != ret) |
return false; |
+ // Add in delayed mitigations and pseudo-mitigations enforced at startup. |
+ g_shared_delayed_mitigations = delayed_mitigations_ | |
+ FilterPostStartupProcessMitigations(mitigations_); |
+ if (!CanSetProcessMitigationsPostStartup(g_shared_delayed_mitigations)) |
+ return false; |
+ |
+ ret = target->TransferVariable("g_shared_delayed_mitigations", |
+ &g_shared_delayed_mitigations, |
+ sizeof(g_shared_delayed_mitigations)); |
+ g_shared_delayed_mitigations = 0; |
+ if (SBOX_ALL_OK != ret) |
+ return false; |
+ |
AutoLock lock(&lock_); |
targets_.push_back(target); |
return true; |