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

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

Issue 1024463005: Added UMA metrics to track errors while launching lowbox enabled sandboxed process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added link to MSDN GetLastError error codes. Created 5 years, 9 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 | tools/metrics/histograms/histograms.xml » ('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 <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"
11 #include "base/debug/profiler.h" 11 #include "base/debug/profiler.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/hash.h" 13 #include "base/hash.h"
14 #include "base/metrics/sparse_histogram.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/process/launch.h" 16 #include "base/process/launch.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
18 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
19 #include "base/win/iat_patch_function.h" 20 #include "base/win/iat_patch_function.h"
20 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
21 #include "base/win/scoped_process_information.h" 22 #include "base/win/scoped_process_information.h"
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #include "content/common/content_switches_internal.h" 24 #include "content/common/content_switches_internal.h"
24 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
25 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
26 #include "content/public/common/sandbox_init.h" 27 #include "content/public/common/sandbox_init.h"
27 #include "content/public/common/sandboxed_process_launcher_delegate.h" 28 #include "content/public/common/sandboxed_process_launcher_delegate.h"
28 #include "sandbox/win/src/process_mitigations.h" 29 #include "sandbox/win/src/process_mitigations.h"
29 #include "sandbox/win/src/sandbox.h" 30 #include "sandbox/win/src/sandbox.h"
30 #include "sandbox/win/src/sandbox_nt_util.h" 31 #include "sandbox/win/src/sandbox_nt_util.h"
32 #include "sandbox/win/src/sandbox_policy_base.h"
31 #include "sandbox/win/src/win_utils.h" 33 #include "sandbox/win/src/win_utils.h"
32 #include "ui/gfx/win/direct_write.h" 34 #include "ui/gfx/win/direct_write.h"
33 35
34 static sandbox::BrokerServices* g_broker_services = NULL; 36 static sandbox::BrokerServices* g_broker_services = NULL;
35 static sandbox::TargetServices* g_target_services = NULL; 37 static sandbox::TargetServices* g_target_services = NULL;
36 38
37 namespace content { 39 namespace content {
38 namespace { 40 namespace {
39 41
40 // The DLLs listed here are known (or under strong suspicion) of causing crashes 42 // The DLLs listed here are known (or under strong suspicion) of causing crashes
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 return base::Process(); 719 return base::Process();
718 } 720 }
719 721
720 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); 722 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0);
721 723
722 PROCESS_INFORMATION temp_process_info = {}; 724 PROCESS_INFORMATION temp_process_info = {};
723 result = g_broker_services->SpawnTarget( 725 result = g_broker_services->SpawnTarget(
724 cmd_line->GetProgram().value().c_str(), 726 cmd_line->GetProgram().value().c_str(),
725 cmd_line->GetCommandLineString().c_str(), 727 cmd_line->GetCommandLineString().c_str(),
726 policy, &temp_process_info); 728 policy, &temp_process_info);
729 DWORD last_error = ::GetLastError();
727 policy->Release(); 730 policy->Release();
728 base::win::ScopedProcessInformation target(temp_process_info); 731 base::win::ScopedProcessInformation target(temp_process_info);
729 732
730 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); 733 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0);
731 734
732 if (sandbox::SBOX_ALL_OK != result) { 735 if (sandbox::SBOX_ALL_OK != result) {
733 if (result == sandbox::SBOX_ERROR_GENERIC) 736 if (result == sandbox::SBOX_ERROR_GENERIC)
734 DPLOG(ERROR) << "Failed to launch process"; 737 DPLOG(ERROR) << "Failed to launch process";
735 else 738 else
736 DLOG(ERROR) << "Failed to launch process. Error: " << result; 739 DLOG(ERROR) << "Failed to launch process. Error: " << result;
740
741 sandbox::PolicyBase* policy_base =
742 static_cast<sandbox::PolicyBase*>(policy);
743 if (policy_base->GetLowBoxSid()) {
744 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Lowbox.Launch.Error",
745 last_error);
746 }
737 return base::Process(); 747 return base::Process();
738 } 748 }
739 749
740 if (delegate) 750 if (delegate)
741 delegate->PostSpawnTarget(target.process_handle()); 751 delegate->PostSpawnTarget(target.process_handle());
742 752
743 CHECK(ResumeThread(target.thread_handle()) != -1); 753 CHECK(ResumeThread(target.thread_handle()) != -1);
744 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str); 754 TRACE_EVENT_END_ETW("StartProcessWithAccess", 0, type_str);
745 return base::Process(target.TakeProcessHandle()); 755 return base::Process(target.TakeProcessHandle());
746 } 756 }
(...skipping 30 matching lines...) Expand all
777 } 787 }
778 788
779 return false; 789 return false;
780 } 790 }
781 791
782 bool BrokerAddTargetPeer(HANDLE peer_process) { 792 bool BrokerAddTargetPeer(HANDLE peer_process) {
783 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; 793 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK;
784 } 794 }
785 795
786 } // namespace content 796 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698