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

Side by Side Diff: content/common/sandbox_win.cc

Issue 893263003: Only close \Device\DeviceApi for renderer processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a comment Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
336 sandbox::TargetPolicy::PROCESS_MIN_EXEC, 336 sandbox::TargetPolicy::PROCESS_MIN_EXEC,
337 debug_message.value().c_str()); 337 debug_message.value().c_str());
338 if (result != sandbox::SBOX_ALL_OK) 338 if (result != sandbox::SBOX_ALL_OK)
339 return false; 339 return false;
340 #endif // NDEBUG 340 #endif // NDEBUG
341 341
342 AddGenericDllEvictionPolicy(policy); 342 AddGenericDllEvictionPolicy(policy);
343 return true; 343 return true;
344 } 344 }
345 345
346 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy) { 346 bool AddPolicyForSandboxedProcess(sandbox::TargetPolicy* policy,
347 std::string& type_str) {
347 sandbox::ResultCode result; 348 sandbox::ResultCode result;
348 // Renderers need to share events with plugins. 349 // Renderers need to share events with plugins.
349 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, 350 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES,
350 sandbox::TargetPolicy::HANDLES_DUP_ANY, 351 sandbox::TargetPolicy::HANDLES_DUP_ANY,
351 L"Event"); 352 L"Event");
352 if (result != sandbox::SBOX_ALL_OK) 353 if (result != sandbox::SBOX_ALL_OK)
353 return false; 354 return false;
354 355
355 // Win8+ adds a device DeviceApi that we don't need. 356 // Win8+ adds a device DeviceApi that we don't need.
356 if (base::win::GetVersion() > base::win::VERSION_WIN7) 357 // Only close this handle on renderer processes. See crbug.com/452613.
358 if (base::win::GetVersion() > base::win::VERSION_WIN7 &&
359 type_str == switches::kRendererProcess) {
357 result = policy->AddKernelObjectToClose(L"File", L"\\Device\\DeviceApi"); 360 result = policy->AddKernelObjectToClose(L"File", L"\\Device\\DeviceApi");
361 }
358 if (result != sandbox::SBOX_ALL_OK) 362 if (result != sandbox::SBOX_ALL_OK)
359 return false; 363 return false;
360 364
361 // Close the proxy settings on XP. 365 // Close the proxy settings on XP.
362 if (base::win::GetVersion() <= base::win::VERSION_SERVER_2003) 366 if (base::win::GetVersion() <= base::win::VERSION_SERVER_2003)
363 result = policy->AddKernelObjectToClose(L"Key", 367 result = policy->AddKernelObjectToClose(L"Key",
364 L"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\" \ 368 L"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\" \
365 L"CurrentVersion\\Internet Settings"); 369 L"CurrentVersion\\Internet Settings");
366 if (result != sandbox::SBOX_ALL_OK) 370 if (result != sandbox::SBOX_ALL_OK)
367 return false; 371 return false;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 if (policy->SetDelayedProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK) 646 if (policy->SetDelayedProcessMitigations(mitigations) != sandbox::SBOX_ALL_OK)
643 return base::Process(); 647 return base::Process();
644 648
645 SetJobLevel(*cmd_line, sandbox::JOB_LOCKDOWN, 0, policy); 649 SetJobLevel(*cmd_line, sandbox::JOB_LOCKDOWN, 0, policy);
646 650
647 bool disable_default_policy = false; 651 bool disable_default_policy = false;
648 base::FilePath exposed_dir; 652 base::FilePath exposed_dir;
649 if (delegate) 653 if (delegate)
650 delegate->PreSandbox(&disable_default_policy, &exposed_dir); 654 delegate->PreSandbox(&disable_default_policy, &exposed_dir);
651 655
652 if (!disable_default_policy && !AddPolicyForSandboxedProcess(policy)) 656 if (!disable_default_policy &&
657 !AddPolicyForSandboxedProcess(policy, type_str))
653 return base::Process(); 658 return base::Process();
654 659
655 if (type_str == switches::kRendererProcess) { 660 if (type_str == switches::kRendererProcess) {
656 #if !defined(NACL_WIN64) 661 #if !defined(NACL_WIN64)
657 if (gfx::win::ShouldUseDirectWrite()) { 662 if (gfx::win::ShouldUseDirectWrite()) {
658 AddDirectory(base::DIR_WINDOWS_FONTS, 663 AddDirectory(base::DIR_WINDOWS_FONTS,
659 NULL, 664 NULL,
660 true, 665 true,
661 sandbox::TargetPolicy::FILES_ALLOW_READONLY, 666 sandbox::TargetPolicy::FILES_ALLOW_READONLY,
662 policy); 667 policy);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 769 }
765 770
766 return false; 771 return false;
767 } 772 }
768 773
769 bool BrokerAddTargetPeer(HANDLE peer_process) { 774 bool BrokerAddTargetPeer(HANDLE peer_process) {
770 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 775 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
771 } 776 }
772 777
773 } // namespace content 778 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698