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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { | 337 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { |
338 sandbox::ResultCode result; | 338 sandbox::ResultCode result; |
339 // Renderers need to share events with plugins. | 339 // Renderers need to share events with plugins. |
340 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 340 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
341 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 341 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
342 L"Event"); | 342 L"Event"); |
343 if (result != sandbox::SBOX_ALL_OK) | 343 if (result != sandbox::SBOX_ALL_OK) |
344 return false; | 344 return false; |
345 | 345 |
| 346 // Win8+ adds a device DeviceApi that we don't need. |
| 347 if (base::win::GetVersion() > base::win::VERSION_WIN7) |
| 348 policy->AddKernelObjectToClose(L"File", L"\\Device\\DeviceApi"); |
| 349 |
346 sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; | 350 sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; |
347 if (base::win::GetVersion() > base::win::VERSION_XP) { | 351 if (base::win::GetVersion() > base::win::VERSION_XP) { |
348 // On 2003/Vista the initial token has to be restricted if the main | 352 // On 2003/Vista the initial token has to be restricted if the main |
349 // token is restricted. | 353 // token is restricted. |
350 initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; | 354 initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; |
351 } | 355 } |
352 | 356 |
353 policy->SetTokenLevel(initial_token, sandbox::USER_LOCKDOWN); | 357 policy->SetTokenLevel(initial_token, sandbox::USER_LOCKDOWN); |
354 // Prevents the renderers from manipulating low-integrity processes. | 358 // Prevents the renderers from manipulating low-integrity processes. |
355 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED); | 359 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 734 } |
731 | 735 |
732 return false; | 736 return false; |
733 } | 737 } |
734 | 738 |
735 bool BrokerAddTargetPeer(HANDLE peer_process) { | 739 bool BrokerAddTargetPeer(HANDLE peer_process) { |
736 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 740 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
737 } | 741 } |
738 | 742 |
739 } // namespace content | 743 } // namespace content |
OLD | NEW |