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

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

Issue 10690058: Add sandbox support for Windows process mitigations (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 3 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/broker_services.cc
===================================================================
--- sandbox/win/src/broker_services.cc (revision 154997)
+++ sandbox/win/src/broker_services.cc (working copy)
@@ -12,6 +12,7 @@
#include "base/win/startup_information.h"
#include "base/win/windows_version.h"
#include "sandbox/win/src/app_container.h"
+#include "sandbox/win/src/process_mitigations.h"
#include "sandbox/win/src/sandbox_policy_base.h"
#include "sandbox/win/src/sandbox.h"
#include "sandbox/win/src/target_process.h"
@@ -320,14 +321,45 @@
const_cast<wchar_t*>(desktop.c_str());
}
+ int attribute_count = 0;
const AppContainerAttributes* app_container = policy_base->GetAppContainer();
+ if (app_container)
+ ++attribute_count;
+
+ DWORD64 mitigations = GetProcessMitigationPolicyFlags(
+ policy->GetProcessMitigations());
+ if (mitigations)
+ ++attribute_count;
+
+ if (!startup_info.InitializeProcThreadAttributeList(attribute_count))
+ return SBOX_ERROR_GENERIC;
+
if (app_container) {
- startup_info.InitializeProcThreadAttributeList(1);
result = app_container->ShareForStartup(&startup_info);
if (SBOX_ALL_OK != result)
return result;
}
+ if (mitigations) {
+ size_t mitigation_size = sizeof(mitigations);
+ void* mitigation_ptr = &mitigations;
+
+#ifndef _WIN64
+ // A 64-bit flags attribute is illegal on 32-bit Win 7 and below.
+ DWORD mitigations32 = static_cast<DWORD>(mitigations);
+ if (base::win::GetVersion() < base::win::VERSION_WIN8) {
+ mitigation_size = sizeof(mitigations32);
+ mitigation_ptr = &mitigations32;
+ }
+#endif
cpu_(ooo_6.6-7.5) 2012/09/06 19:46:15 this would be clearer to me if instead you have so
jschuh 2012/09/07 01:14:22 Done.
+
+ if (!startup_info.UpdateProcThreadAttribute(
+ PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY, mitigation_ptr,
+ mitigation_size)) {
+ return SBOX_ERROR_GENERIC;
+ }
+ }
+
// Construct the thread pool here in case it is expensive.
// The thread pool is shared by all the targets
if (NULL == thread_pool_)

Powered by Google App Engine
This is Rietveld 408576698