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

Unified Diff: content/common/sandbox_win.cc

Issue 1306243012: Add command line option to enable PPAPI win32k lockdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_render_font_code
Patch Set: Rebased patch. Created 5 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
« no previous file with comments | « content/common/sandbox_win.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_win.cc
diff --git a/content/common/sandbox_win.cc b/content/common/sandbox_win.cc
index 110edb8a6812438efa13d1d1549568dfdc6553b0..a3c26e1267e0dd17822ea7a9058f88781230f669 100644
--- a/content/common/sandbox_win.cc
+++ b/content/common/sandbox_win.cc
@@ -569,6 +569,31 @@ void AddAppContainerPolicy(sandbox::TargetPolicy* policy, const wchar_t* sid) {
}
}
+bool AddWin32kLockdownPolicy(sandbox::TargetPolicy* policy) {
+#if !defined(NACL_WIN64)
+ if (!IsWin32kRendererLockdownEnabled())
+ return true;
+
+ // Enable win32k lockdown if not already.
+ sandbox::MitigationFlags flags = policy->GetProcessMitigations();
+ if ((flags & sandbox::MITIGATION_WIN32K_DISABLE) ==
+ sandbox::MITIGATION_WIN32K_DISABLE)
+ return true;
+
+ sandbox::ResultCode result =
+ policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN,
+ sandbox::TargetPolicy::FAKE_USER_GDI_INIT, nullptr);
+ if (result != sandbox::SBOX_ALL_OK)
+ return false;
+
+ flags |= sandbox::MITIGATION_WIN32K_DISABLE;
+ result = policy->SetProcessMitigations(flags);
+ if (result != sandbox::SBOX_ALL_OK)
+ return false;
+#endif
+ return true;
+}
+
bool InitBrokerServices(sandbox::BrokerServices* broker_services) {
// TODO(abarth): DCHECK(CalledOnValidThread());
// See <http://b/1287166>.
@@ -656,21 +681,17 @@ base::Process StartSandboxedProcess(
sandbox::MITIGATION_DEP_NO_ATL_THUNK |
sandbox::MITIGATION_SEHOP;
+ if (policy->SetProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK)
+ return base::Process();
+
#if !defined(NACL_WIN64)
if (type_str == switches::kRendererProcess &&
IsWin32kRendererLockdownEnabled()) {
- if (policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN,
- sandbox::TargetPolicy::FAKE_USER_GDI_INIT,
- NULL) != sandbox::SBOX_ALL_OK) {
+ if (!AddWin32kLockdownPolicy(policy))
return base::Process();
- }
- mitigations |= sandbox::MITIGATION_WIN32K_DISABLE;
}
#endif
- if (policy->SetProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK)
- return base::Process();
-
mitigations = sandbox::MITIGATION_STRICT_HANDLE_CHECKS |
sandbox::MITIGATION_DLL_SEARCH_ORDER;
« no previous file with comments | « content/common/sandbox_win.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698