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

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

Issue 2193603004: Ignore desktop creation errors in the sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | sandbox/win/src/window.cc » ('j') | 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 sancov_path.value().c_str()); 364 sancov_path.value().c_str());
365 if (result != sandbox::SBOX_ALL_OK) 365 if (result != sandbox::SBOX_ALL_OK)
366 return result; 366 return result;
367 } 367 }
368 #endif 368 #endif
369 369
370 AddGenericDllEvictionPolicy(policy); 370 AddGenericDllEvictionPolicy(policy);
371 return sandbox::SBOX_ALL_OK; 371 return sandbox::SBOX_ALL_OK;
372 } 372 }
373 373
374 void LogLaunchWarning(sandbox::ResultCode last_warning, DWORD last_error) {
375 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.WarningResultCode",
376 last_warning);
377 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Warning", last_error);
378 }
379
374 sandbox::ResultCode AddPolicyForSandboxedProcess( 380 sandbox::ResultCode AddPolicyForSandboxedProcess(
375 sandbox::TargetPolicy* policy) { 381 sandbox::TargetPolicy* policy) {
376 sandbox::ResultCode result = sandbox::SBOX_ALL_OK; 382 sandbox::ResultCode result = sandbox::SBOX_ALL_OK;
377 383
378 // Win8+ adds a device DeviceApi that we don't need. 384 // Win8+ adds a device DeviceApi that we don't need.
379 if (base::win::GetVersion() > base::win::VERSION_WIN7) 385 if (base::win::GetVersion() > base::win::VERSION_WIN7)
380 result = policy->AddKernelObjectToClose(L"File", L"\\Device\\DeviceApi"); 386 result = policy->AddKernelObjectToClose(L"File", L"\\Device\\DeviceApi");
381 if (result != sandbox::SBOX_ALL_OK) 387 if (result != sandbox::SBOX_ALL_OK)
382 return result; 388 return result;
383 389
(...skipping 19 matching lines...) Expand all
403 result = policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED); 409 result = policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_UNTRUSTED);
404 if (result != sandbox::SBOX_ALL_OK) 410 if (result != sandbox::SBOX_ALL_OK)
405 return result; 411 return result;
406 result = policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); 412 result = policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
407 if (result != sandbox::SBOX_ALL_OK) 413 if (result != sandbox::SBOX_ALL_OK)
408 return result; 414 return result;
409 policy->SetLockdownDefaultDacl(); 415 policy->SetLockdownDefaultDacl();
410 416
411 result = policy->SetAlternateDesktop(true); 417 result = policy->SetAlternateDesktop(true);
412 if (result != sandbox::SBOX_ALL_OK) { 418 if (result != sandbox::SBOX_ALL_OK) {
419 // We ignore the result of setting the alternate desktop, however log
420 // a launch warning.
421 LogLaunchWarning(result, ::GetLastError());
413 DLOG(WARNING) << "Failed to apply desktop security to the renderer"; 422 DLOG(WARNING) << "Failed to apply desktop security to the renderer";
414 return result; 423 result = sandbox::SBOX_ALL_OK;
415 } 424 }
416 425
417 return result; 426 return result;
418 } 427 }
419 428
420 // Updates the command line arguments with debug-related flags. If debug flags 429 // Updates the command line arguments with debug-related flags. If debug flags
421 // have been used with this process, they will be filtered and added to 430 // have been used with this process, they will be filtered and added to
422 // command_line as needed. 431 // command_line as needed.
423 void ProcessDebugFlags(base::CommandLine* command_line) { 432 void ProcessDebugFlags(base::CommandLine* command_line) {
424 const base::CommandLine& current_cmd_line = 433 const base::CommandLine& current_cmd_line =
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Error", last_error); 821 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Error", last_error);
813 if (result == sandbox::SBOX_ERROR_GENERIC) 822 if (result == sandbox::SBOX_ERROR_GENERIC)
814 DPLOG(ERROR) << "Failed to launch process"; 823 DPLOG(ERROR) << "Failed to launch process";
815 else 824 else
816 DLOG(ERROR) << "Failed to launch process. Error: " << result; 825 DLOG(ERROR) << "Failed to launch process. Error: " << result;
817 826
818 return result; 827 return result;
819 } 828 }
820 829
821 if (sandbox::SBOX_ALL_OK != last_warning) { 830 if (sandbox::SBOX_ALL_OK != last_warning) {
822 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.WarningResultCode", 831 LogLaunchWarning(last_warning, last_error);
823 last_warning);
824 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Warning", last_error);
825 } 832 }
826 833
827 delegate->PostSpawnTarget(target.process_handle()); 834 delegate->PostSpawnTarget(target.process_handle());
828 835
829 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); 836 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1));
830 *process = base::Process(target.TakeProcessHandle()); 837 *process = base::Process(target.TakeProcessHandle());
831 return sandbox::SBOX_ALL_OK; 838 return sandbox::SBOX_ALL_OK;
832 } 839 }
833 840
834 } // namespace content 841 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | sandbox/win/src/window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698