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

Side by Side Diff: content/app/startup_helper_win.cc

Issue 10907217: Revert 156550 - Add sandbox support for Windows process mitigations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/common/sandbox_policy.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/public/app/startup_helper_win.h" 5 #include "content/public/app/startup_helper_win.h"
6 6
7 #include <crtdbg.h> 7 #include <crtdbg.h>
8 #include <new.h> 8 #include <new.h>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "sandbox/win/src/process_mitigations.h" 13 #include "sandbox/win/src/dep.h"
14 #include "sandbox/win/src/sandbox_factory.h" 14 #include "sandbox/win/src/sandbox_factory.h"
15 15
16 namespace { 16 namespace {
17 17
18 #pragma optimize("", off) 18 #pragma optimize("", off)
19 // Handlers for invalid parameter and pure call. They generate a breakpoint to 19 // Handlers for invalid parameter and pure call. They generate a breakpoint to
20 // tell breakpad that it needs to dump the process. 20 // tell breakpad that it needs to dump the process.
21 void InvalidParameter(const wchar_t* expression, const wchar_t* function, 21 void InvalidParameter(const wchar_t* expression, const wchar_t* function,
22 const wchar_t* file, unsigned int line, 22 const wchar_t* file, unsigned int line,
23 uintptr_t reserved) { 23 uintptr_t reserved) {
24 __debugbreak(); 24 __debugbreak();
25 _exit(1); 25 _exit(1);
26 } 26 }
27 27
28 void PureCall() { 28 void PureCall() {
29 __debugbreak(); 29 __debugbreak();
30 _exit(1); 30 _exit(1);
31 } 31 }
32 #pragma optimize("", on) 32 #pragma optimize("", on)
33 33
34 } // namespace 34 } // namespace
35 35
36 namespace content { 36 namespace content {
37 37
38 void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo* info) { 38 void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo* info) {
39 info->broker_services = sandbox::SandboxFactory::GetBrokerServices(); 39 info->broker_services = sandbox::SandboxFactory::GetBrokerServices();
40 if (!info->broker_services) { 40 if (!info->broker_services)
41 info->target_services = sandbox::SandboxFactory::GetTargetServices(); 41 info->target_services = sandbox::SandboxFactory::GetTargetServices();
42 } else { 42
43 // Ensure the proper mitigations are enforced for the browser process. 43 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
44 sandbox::ApplyProcessMitigationsToCurrentProcess( 44 // Enforces strong DEP support. Vista uses the NXCOMPAT flag in the exe.
45 sandbox::MITIGATION_DEP | 45 sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
46 sandbox::MITIGATION_DEP_NO_ATL_THUNK);
47 } 46 }
48 } 47 }
49 48
50 // Register the invalid param handler and pure call handler to be able to 49 // Register the invalid param handler and pure call handler to be able to
51 // notify breakpad when it happens. 50 // notify breakpad when it happens.
52 void RegisterInvalidParamHandler() { 51 void RegisterInvalidParamHandler() {
53 _set_invalid_parameter_handler(InvalidParameter); 52 _set_invalid_parameter_handler(InvalidParameter);
54 _set_purecall_handler(PureCall); 53 _set_purecall_handler(PureCall);
55 // Also enable the new handler for malloc() based failures. 54 // Also enable the new handler for malloc() based failures.
56 _set_new_mode(1); 55 _set_new_mode(1);
57 } 56 }
58 57
59 void SetupCRT(const CommandLine& command_line) { 58 void SetupCRT(const CommandLine& command_line) {
60 #if defined(_CRTDBG_MAP_ALLOC) 59 #if defined(_CRTDBG_MAP_ALLOC)
61 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 60 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
62 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); 61 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
63 #else 62 #else
64 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { 63 if (!command_line.HasSwitch(switches::kDisableBreakpad)) {
65 _CrtSetReportMode(_CRT_ASSERT, 0); 64 _CrtSetReportMode(_CRT_ASSERT, 0);
66 } 65 }
67 #endif 66 #endif
68 } 67 }
69 68
70 } // namespace content 69 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/sandbox_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698