OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 base::FilePath debug_message(long_path_buf); | 326 base::FilePath debug_message(long_path_buf); |
327 debug_message = debug_message.AppendASCII("debug_message.exe"); | 327 debug_message = debug_message.AppendASCII("debug_message.exe"); |
328 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, | 328 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, |
329 sandbox::TargetPolicy::PROCESS_MIN_EXEC, | 329 sandbox::TargetPolicy::PROCESS_MIN_EXEC, |
330 debug_message.value().c_str()); | 330 debug_message.value().c_str()); |
331 if (result != sandbox::SBOX_ALL_OK) | 331 if (result != sandbox::SBOX_ALL_OK) |
332 return false; | 332 return false; |
333 #endif // NDEBUG | 333 #endif // NDEBUG |
334 | 334 |
335 AddGenericDllEvictionPolicy(policy); | 335 AddGenericDllEvictionPolicy(policy); |
336 | |
337 return true; | 336 return true; |
338 } | 337 } |
339 | 338 |
340 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { | 339 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { |
341 sandbox::ResultCode result; | 340 sandbox::ResultCode result; |
342 // Renderers need to share events with plugins. | 341 // Renderers need to share events with plugins. |
343 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 342 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
344 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 343 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
345 L"Event"); | 344 L"Event"); |
346 if (result != sandbox::SBOX_ALL_OK) | 345 if (result != sandbox::SBOX_ALL_OK) |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 sandbox::MitigationFlags mitigations = sandbox::MITIGATION_HEAP_TERMINATE | | 602 sandbox::MitigationFlags mitigations = sandbox::MITIGATION_HEAP_TERMINATE | |
604 sandbox::MITIGATION_BOTTOM_UP_ASLR | | 603 sandbox::MITIGATION_BOTTOM_UP_ASLR | |
605 sandbox::MITIGATION_DEP | | 604 sandbox::MITIGATION_DEP | |
606 sandbox::MITIGATION_DEP_NO_ATL_THUNK | | 605 sandbox::MITIGATION_DEP_NO_ATL_THUNK | |
607 sandbox::MITIGATION_SEHOP; | 606 sandbox::MITIGATION_SEHOP; |
608 | 607 |
609 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 608 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
610 type_str == switches::kRendererProcess && | 609 type_str == switches::kRendererProcess && |
611 browser_command_line.HasSwitch( | 610 browser_command_line.HasSwitch( |
612 switches::kEnableWin32kRendererLockDown)) { | 611 switches::kEnableWin32kRendererLockDown)) { |
613 mitigations |= sandbox::MITIGATION_WIN32K_DISABLE; | 612 if (policy->AddRule(sandbox::TargetPolicy::SUBSYS_WIN32K_LOCKDOWN, |
614 } | 613 sandbox::TargetPolicy::FAKE_USER32_GDI32_INIT, |
614 L"FakeUserGdiInit") != sandbox::SBOX_ALL_OK) { | |
rvargas (doing something else)
2014/06/10 03:11:17
Does it work passing a NULL string?
ananta
2014/06/10 21:48:06
Done.
| |
615 return 0; | |
616 } | |
617 mitigations |= sandbox::MITIGATION_WIN32K_DISABLE; | |
618 } | |
615 | 619 |
616 if (policy->SetProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK) | 620 if (policy->SetProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK) |
617 return 0; | 621 return 0; |
618 | 622 |
619 mitigations = sandbox::MITIGATION_STRICT_HANDLE_CHECKS | | 623 mitigations = sandbox::MITIGATION_STRICT_HANDLE_CHECKS | |
620 sandbox::MITIGATION_DLL_SEARCH_ORDER; | 624 sandbox::MITIGATION_DLL_SEARCH_ORDER; |
621 | 625 |
622 if (policy->SetDelayedProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK) | 626 if (policy->SetDelayedProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK) |
623 return 0; | 627 return 0; |
624 | 628 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 } | 745 } |
742 | 746 |
743 return false; | 747 return false; |
744 } | 748 } |
745 | 749 |
746 bool BrokerAddTargetPeer(HANDLE peer_process) { | 750 bool BrokerAddTargetPeer(HANDLE peer_process) { |
747 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 751 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
748 } | 752 } |
749 | 753 |
750 } // namespace content | 754 } // namespace content |
OLD | NEW |