OLD | NEW |
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 "chrome/common/sandbox_policy.h" | 5 #include "chrome/common/sandbox_policy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/string_number_conversions.h" | |
18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
19 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
20 #include "chrome/common/chrome_constants.h" | 19 #include "content/browser/content_browser_client.h" |
21 #include "chrome/common/chrome_paths.h" | 20 #include "content/common/content_switches.h" |
22 #include "chrome/common/chrome_switches.h" | |
23 #include "content/common/child_process_info.h" | 21 #include "content/common/child_process_info.h" |
24 #include "content/common/debug_flags.h" | 22 #include "content/common/debug_flags.h" |
25 #include "sandbox/src/sandbox.h" | 23 #include "sandbox/src/sandbox.h" |
26 | 24 |
27 static sandbox::BrokerServices* g_broker_services = NULL; | 25 static sandbox::BrokerServices* g_broker_services = NULL; |
28 | 26 |
29 namespace { | 27 namespace { |
30 | 28 |
31 // The DLLs listed here are known (or under strong suspicion) of causing crashes | 29 // The DLLs listed here are known (or under strong suspicion) of causing crashes |
32 // when they are loaded in the renderer. Note: at runtime we generate short | 30 // when they are loaded in the renderer. Note: at runtime we generate short |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 L"ssldivx.dll", // DivX. | 79 L"ssldivx.dll", // DivX. |
82 L"syncor11.dll", // SynthCore Midi interface. | 80 L"syncor11.dll", // SynthCore Midi interface. |
83 L"systools.dll", // Panda Antivirus. | 81 L"systools.dll", // Panda Antivirus. |
84 L"tfwah.dll", // Threatfire (PC tools). | 82 L"tfwah.dll", // Threatfire (PC tools). |
85 L"ycwebcamerasource.ax", // Cyberlink Camera helper. | 83 L"ycwebcamerasource.ax", // Cyberlink Camera helper. |
86 L"wblind.dll", // Stardock Object desktop. | 84 L"wblind.dll", // Stardock Object desktop. |
87 L"wbhelp.dll", // Stardock Object desktop. | 85 L"wbhelp.dll", // Stardock Object desktop. |
88 L"winstylerthemehelper.dll" // Tuneup utilities 2006. | 86 L"winstylerthemehelper.dll" // Tuneup utilities 2006. |
89 }; | 87 }; |
90 | 88 |
91 enum PluginPolicyCategory { | |
92 PLUGIN_GROUP_TRUSTED, | |
93 PLUGIN_GROUP_UNTRUSTED, | |
94 }; | |
95 | |
96 // Returns the policy category for the plugin dll. | |
97 PluginPolicyCategory GetPolicyCategoryForPlugin( | |
98 const std::wstring& dll, | |
99 const std::wstring& list) { | |
100 std::wstring filename = FilePath(dll).BaseName().value(); | |
101 std::wstring plugin_dll = StringToLowerASCII(filename); | |
102 std::wstring trusted_plugins = StringToLowerASCII(list); | |
103 | |
104 size_t pos = 0; | |
105 size_t end_item = 0; | |
106 while (end_item != std::wstring::npos) { | |
107 end_item = list.find(L",", pos); | |
108 | |
109 size_t size_item = (end_item == std::wstring::npos) ? end_item : | |
110 end_item - pos; | |
111 std::wstring item = list.substr(pos, size_item); | |
112 if (!item.empty() && item == plugin_dll) | |
113 return PLUGIN_GROUP_TRUSTED; | |
114 | |
115 pos = end_item + 1; | |
116 } | |
117 | |
118 return PLUGIN_GROUP_UNTRUSTED; | |
119 } | |
120 | |
121 // Adds the policy rules for the path and path\ with the semantic |access|. | 89 // Adds the policy rules for the path and path\ with the semantic |access|. |
122 // If |children| is set to true, we need to add the wildcard rules to also | 90 // If |children| is set to true, we need to add the wildcard rules to also |
123 // apply the rule to the subfiles and subfolders. | 91 // apply the rule to the subfiles and subfolders. |
124 bool AddDirectory(int path, const wchar_t* sub_dir, bool children, | 92 bool AddDirectory(int path, const wchar_t* sub_dir, bool children, |
125 sandbox::TargetPolicy::Semantics access, | 93 sandbox::TargetPolicy::Semantics access, |
126 sandbox::TargetPolicy* policy) { | 94 sandbox::TargetPolicy* policy) { |
127 FilePath directory; | 95 FilePath directory; |
128 if (!PathService::Get(path, &directory)) | 96 if (!PathService::Get(path, &directory)) |
129 return false; | 97 return false; |
130 | 98 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 207 |
240 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, | 208 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, |
241 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, | 209 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, |
242 L"\\\\.\\pipe\\chrome.nacl.*"); | 210 L"\\\\.\\pipe\\chrome.nacl.*"); |
243 if (result != sandbox::SBOX_ALL_OK) | 211 if (result != sandbox::SBOX_ALL_OK) |
244 return false; | 212 return false; |
245 | 213 |
246 // Add the policy for debug message only in debug | 214 // Add the policy for debug message only in debug |
247 #ifndef NDEBUG | 215 #ifndef NDEBUG |
248 FilePath app_dir; | 216 FilePath app_dir; |
249 if (!PathService::Get(chrome::DIR_APP, &app_dir)) | 217 if (!PathService::Get(base::DIR_MODULE, &app_dir)) |
250 return false; | 218 return false; |
251 | 219 |
252 wchar_t long_path_buf[MAX_PATH]; | 220 wchar_t long_path_buf[MAX_PATH]; |
253 DWORD long_path_return_value = GetLongPathName(app_dir.value().c_str(), | 221 DWORD long_path_return_value = GetLongPathName(app_dir.value().c_str(), |
254 long_path_buf, | 222 long_path_buf, |
255 MAX_PATH); | 223 MAX_PATH); |
256 if (long_path_return_value == 0 || long_path_return_value >= MAX_PATH) | 224 if (long_path_return_value == 0 || long_path_return_value >= MAX_PATH) |
257 return false; | 225 return false; |
258 | 226 |
259 string16 debug_message(long_path_buf); | 227 string16 debug_message(long_path_buf); |
260 file_util::AppendToPath(&debug_message, L"debug_message.exe"); | 228 file_util::AppendToPath(&debug_message, L"debug_message.exe"); |
261 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, | 229 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_PROCESS, |
262 sandbox::TargetPolicy::PROCESS_MIN_EXEC, | 230 sandbox::TargetPolicy::PROCESS_MIN_EXEC, |
263 debug_message.c_str()); | 231 debug_message.c_str()); |
264 if (result != sandbox::SBOX_ALL_OK) | 232 if (result != sandbox::SBOX_ALL_OK) |
265 return false; | 233 return false; |
266 #endif // NDEBUG | 234 #endif // NDEBUG |
267 | 235 |
268 return true; | 236 return true; |
269 } | 237 } |
270 | 238 |
271 // Creates a sandbox without any restriction. | |
272 bool ApplyPolicyForTrustedPlugin(sandbox::TargetPolicy* policy) { | |
273 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); | |
274 policy->SetTokenLevel(sandbox::USER_UNPROTECTED, sandbox::USER_UNPROTECTED); | |
275 return true; | |
276 } | |
277 | |
278 // Creates a sandbox with the plugin running in a restricted environment. | |
279 // Only the "Users" and "Everyone" groups are enabled in the token. The User SID | |
280 // is disabled. | |
281 bool ApplyPolicyForUntrustedPlugin(sandbox::TargetPolicy* policy) { | |
282 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); | |
283 | |
284 sandbox::TokenLevel initial_token = sandbox::USER_UNPROTECTED; | |
285 if (base::win::GetVersion() > base::win::VERSION_XP) { | |
286 // On 2003/Vista the initial token has to be restricted if the main token | |
287 // is restricted. | |
288 initial_token = sandbox::USER_RESTRICTED_SAME_ACCESS; | |
289 } | |
290 policy->SetTokenLevel(initial_token, sandbox::USER_LIMITED); | |
291 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); | |
292 | |
293 if (!AddDirectory(base::DIR_TEMP, NULL, true, | |
294 sandbox::TargetPolicy::FILES_ALLOW_ANY, policy)) | |
295 return false; | |
296 | |
297 if (!AddDirectory(base::DIR_IE_INTERNET_CACHE, NULL, true, | |
298 sandbox::TargetPolicy::FILES_ALLOW_ANY, policy)) | |
299 return false; | |
300 | |
301 if (!AddDirectory(base::DIR_APP_DATA, NULL, true, | |
302 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | |
303 policy)) | |
304 return false; | |
305 | |
306 if (!AddDirectory(base::DIR_PROFILE, NULL, false, /*not recursive*/ | |
307 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | |
308 policy)) | |
309 return false; | |
310 | |
311 if (!AddDirectory(base::DIR_APP_DATA, L"Adobe", true, | |
312 sandbox::TargetPolicy::FILES_ALLOW_ANY, | |
313 policy)) | |
314 return false; | |
315 | |
316 if (!AddDirectory(base::DIR_APP_DATA, L"Macromedia", true, | |
317 sandbox::TargetPolicy::FILES_ALLOW_ANY, | |
318 policy)) | |
319 return false; | |
320 | |
321 if (!AddDirectory(base::DIR_LOCAL_APP_DATA, NULL, true, | |
322 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | |
323 policy)) | |
324 return false; | |
325 | |
326 if (!AddKeyAndSubkeys(L"HKEY_CURRENT_USER\\SOFTWARE\\ADOBE", | |
327 sandbox::TargetPolicy::REG_ALLOW_ANY, | |
328 policy)) | |
329 return false; | |
330 | |
331 if (!AddKeyAndSubkeys(L"HKEY_CURRENT_USER\\SOFTWARE\\MACROMEDIA", | |
332 sandbox::TargetPolicy::REG_ALLOW_ANY, | |
333 policy)) | |
334 return false; | |
335 | |
336 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
337 if (!AddKeyAndSubkeys(L"HKEY_CURRENT_USER\\SOFTWARE\\AppDataLow", | |
338 sandbox::TargetPolicy::REG_ALLOW_ANY, | |
339 policy)) | |
340 return false; | |
341 | |
342 if (!AddDirectory(base::DIR_LOCAL_APP_DATA_LOW, NULL, true, | |
343 sandbox::TargetPolicy::FILES_ALLOW_ANY, | |
344 policy)) | |
345 return false; | |
346 | |
347 // DIR_APP_DATA is AppData\Roaming, but Adobe needs to do a directory | |
348 // listing in AppData directly, so we add a non-recursive policy for | |
349 // AppData itself. | |
350 if (!AddDirectory(base::DIR_APP_DATA, L"..", false, | |
351 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | |
352 policy)) | |
353 return false; | |
354 } | |
355 | |
356 return true; | |
357 } | |
358 | |
359 // Launches the privileged flash broker, used when flash is sandboxed. | |
360 // The broker is the same flash dll, except that it uses a different | |
361 // entrypoint (BrokerMain) and it is hosted in windows' generic surrogate | |
362 // process rundll32. After launching the broker we need to pass to | |
363 // the flash plugin the process id of the broker via the command line | |
364 // using --flash-broker=pid. | |
365 // More info about rundll32 at http://support.microsoft.com/kb/164787. | |
366 bool LoadFlashBroker(const FilePath& plugin_path, CommandLine* cmd_line) { | |
367 FilePath rundll; | |
368 if (!PathService::Get(base::DIR_SYSTEM, &rundll)) | |
369 return false; | |
370 rundll = rundll.AppendASCII("rundll32.exe"); | |
371 // Rundll32 cannot handle paths with spaces, so we use the short path. | |
372 wchar_t short_path[MAX_PATH]; | |
373 if (0 == ::GetShortPathNameW(plugin_path.value().c_str(), | |
374 short_path, arraysize(short_path))) | |
375 return false; | |
376 // Here is the kicker, if the user has disabled 8.3 (short path) support | |
377 // on the volume GetShortPathNameW does not fail but simply returns the | |
378 // input path. In this case if the path had any spaces then rundll32 will | |
379 // incorrectly interpret its parameters. So we quote the path, even though | |
380 // the kb/164787 says you should not. | |
381 std::wstring cmd_final = | |
382 base::StringPrintf(L"%ls \"%ls\",BrokerMain browser=chrome", | |
383 rundll.value().c_str(), | |
384 short_path); | |
385 base::ProcessHandle process; | |
386 if (!base::LaunchApp(cmd_final, false, true, &process)) | |
387 return false; | |
388 | |
389 cmd_line->AppendSwitchASCII("flash-broker", | |
390 base::Int64ToString(::GetProcessId(process))); | |
391 | |
392 // The flash broker, unders some circumstances can linger beyond the lifetime | |
393 // of the flash player, so we put it in a job object, when the browser | |
394 // terminates the job object is destroyed (by the OS) and the flash broker | |
395 // is terminated. | |
396 HANDLE job = ::CreateJobObjectW(NULL, NULL); | |
397 JOBOBJECT_EXTENDED_LIMIT_INFORMATION job_limits = {0}; | |
398 job_limits.BasicLimitInformation.LimitFlags = | |
399 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; | |
400 if (::SetInformationJobObject(job, JobObjectExtendedLimitInformation, | |
401 &job_limits, sizeof(job_limits))) { | |
402 ::AssignProcessToJobObject(job, process); | |
403 // Yes, we are leaking the object here. Read comment above. | |
404 } else { | |
405 ::CloseHandle(job); | |
406 return false; | |
407 } | |
408 | |
409 ::CloseHandle(process); | |
410 return true; | |
411 } | |
412 | |
413 // Creates a sandbox for the built-in flash plugin running in a restricted | |
414 // environment. This policy is in continual flux as flash changes | |
415 // capabilities. For more information see bug 50796. | |
416 bool ApplyPolicyForBuiltInFlashPlugin(sandbox::TargetPolicy* policy) { | |
417 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); | |
418 // Vista and Win7 get a weaker token but have low integrity. | |
419 if (base::win::GetVersion() > base::win::VERSION_XP) { | |
420 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, | |
421 sandbox::USER_INTERACTIVE); | |
422 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); | |
423 } else { | |
424 policy->SetTokenLevel(sandbox::USER_UNPROTECTED, | |
425 sandbox::USER_LIMITED); | |
426 | |
427 if (!AddKeyAndSubkeys(L"HKEY_LOCAL_MACHINE\\SOFTWARE", | |
428 sandbox::TargetPolicy::REG_ALLOW_READONLY, | |
429 policy)) | |
430 return false; | |
431 if (!AddKeyAndSubkeys(L"HKEY_LOCAL_MACHINE\\SYSTEM", | |
432 sandbox::TargetPolicy::REG_ALLOW_READONLY, | |
433 policy)) | |
434 return false; | |
435 | |
436 if (!AddKeyAndSubkeys(L"HKEY_CURRENT_USER\\SOFTWARE", | |
437 sandbox::TargetPolicy::REG_ALLOW_READONLY, | |
438 policy)) | |
439 return false; | |
440 } | |
441 | |
442 AddDllEvictionPolicy(policy); | |
443 return true; | |
444 } | |
445 | |
446 // Returns true of the plugin specified in |cmd_line| is the built-in | |
447 // flash plugin and optionally returns its full path in |flash_path| | |
448 bool IsBuiltInFlash(const CommandLine* cmd_line, FilePath* flash_path) { | |
449 std::wstring plugin_dll = cmd_line-> | |
450 GetSwitchValueNative(switches::kPluginPath); | |
451 | |
452 FilePath builtin_flash; | |
453 if (!PathService::Get(chrome::FILE_FLASH_PLUGIN, &builtin_flash)) | |
454 return false; | |
455 | |
456 FilePath plugin_path(plugin_dll); | |
457 if (plugin_path != builtin_flash) | |
458 return false; | |
459 | |
460 if (flash_path) | |
461 *flash_path = plugin_path; | |
462 return true; | |
463 } | |
464 | |
465 | |
466 // Adds the custom policy rules for a given plugin. |trusted_plugins| contains | |
467 // the comma separate list of plugin dll names that should not be sandboxed. | |
468 bool AddPolicyForPlugin(CommandLine* cmd_line, | |
469 sandbox::TargetPolicy* policy) { | |
470 std::wstring plugin_dll = cmd_line-> | |
471 GetSwitchValueNative(switches::kPluginPath); | |
472 std::wstring trusted_plugins = CommandLine::ForCurrentProcess()-> | |
473 GetSwitchValueNative(switches::kTrustedPlugins); | |
474 // Add the policy for the pipes. | |
475 sandbox::ResultCode result = sandbox::SBOX_ALL_OK; | |
476 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_NAMED_PIPES, | |
477 sandbox::TargetPolicy::NAMEDPIPES_ALLOW_ANY, | |
478 L"\\\\.\\pipe\\chrome.*"); | |
479 if (result != sandbox::SBOX_ALL_OK) { | |
480 NOTREACHED(); | |
481 return false; | |
482 } | |
483 | |
484 // The built-in flash gets a custom, more restricted sandbox. | |
485 FilePath flash_path; | |
486 if (IsBuiltInFlash(cmd_line, &flash_path)) { | |
487 // Spawn the flash broker and apply sandbox policy. | |
488 if (!LoadFlashBroker(flash_path, cmd_line)) { | |
489 // Could not start the broker, use a very weak policy instead. | |
490 DLOG(WARNING) << "Failed to start flash broker"; | |
491 return ApplyPolicyForTrustedPlugin(policy); | |
492 } | |
493 return ApplyPolicyForBuiltInFlashPlugin(policy); | |
494 } | |
495 | |
496 PluginPolicyCategory policy_category = | |
497 GetPolicyCategoryForPlugin(plugin_dll, trusted_plugins); | |
498 | |
499 switch (policy_category) { | |
500 case PLUGIN_GROUP_TRUSTED: | |
501 return ApplyPolicyForTrustedPlugin(policy); | |
502 case PLUGIN_GROUP_UNTRUSTED: | |
503 return ApplyPolicyForUntrustedPlugin(policy); | |
504 default: | |
505 NOTREACHED(); | |
506 break; | |
507 } | |
508 | |
509 return false; | |
510 } | |
511 | |
512 // For the GPU process we gotten as far as USER_LIMITED. The next level | 239 // For the GPU process we gotten as far as USER_LIMITED. The next level |
513 // which is USER_RESTRICTED breaks both the DirectX backend and the OpenGL | 240 // which is USER_RESTRICTED breaks both the DirectX backend and the OpenGL |
514 // backend. Note that the GPU process is connected to the interactive | 241 // backend. Note that the GPU process is connected to the interactive |
515 // desktop. | 242 // desktop. |
516 // TODO(cpu): Lock down the sandbox more if possible. | 243 // TODO(cpu): Lock down the sandbox more if possible. |
517 // TODO(apatrick): Use D3D9Ex to render windowless. | 244 // TODO(apatrick): Use D3D9Ex to render windowless. |
518 bool AddPolicyForGPU(CommandLine*, sandbox::TargetPolicy* policy) { | 245 bool AddPolicyForGPU(CommandLine*, sandbox::TargetPolicy* policy) { |
519 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); | 246 policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); |
520 | 247 |
521 if (base::win::GetVersion() > base::win::VERSION_XP) { | 248 if (base::win::GetVersion() > base::win::VERSION_XP) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 341 |
615 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess", 0, type_str); | 342 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess", 0, type_str); |
616 | 343 |
617 // To decide if the process is going to be sandboxed we have two cases. | 344 // To decide if the process is going to be sandboxed we have two cases. |
618 // First case: all process types except the nacl broker, and the plugin | 345 // First case: all process types except the nacl broker, and the plugin |
619 // process are sandboxed by default. | 346 // process are sandboxed by default. |
620 bool in_sandbox = | 347 bool in_sandbox = |
621 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && | 348 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && |
622 (type != ChildProcessInfo::PLUGIN_PROCESS); | 349 (type != ChildProcessInfo::PLUGIN_PROCESS); |
623 | 350 |
624 // Second case: If it is the plugin process then it depends on it being | 351 // If it is the GPU process then it can be disabled by a command line flag. |
625 // the built-in flash, the user forcing plugins into sandbox or the | |
626 // the user explicitly excluding flash from the sandbox. | |
627 if (!in_sandbox && (type == ChildProcessInfo::PLUGIN_PROCESS)) { | |
628 in_sandbox = browser_command_line.HasSwitch(switches::kSafePlugins) || | |
629 (IsBuiltInFlash(cmd_line, NULL) && | |
630 (base::win::GetVersion() > base::win::VERSION_XP) && | |
631 !browser_command_line.HasSwitch(switches::kDisableFlashSandbox)); | |
632 } | |
633 | |
634 // Third case: If it is the GPU process then it can be disabled by a | |
635 // command line flag. | |
636 if ((type == ChildProcessInfo::GPU_PROCESS) && | 352 if ((type == ChildProcessInfo::GPU_PROCESS) && |
637 (browser_command_line.HasSwitch(switches::kDisableGpuSandbox))) { | 353 (browser_command_line.HasSwitch(switches::kDisableGpuSandbox))) { |
638 in_sandbox = false; | 354 in_sandbox = false; |
639 VLOG(1) << "GPU sandbox is disabled"; | 355 VLOG(1) << "GPU sandbox is disabled"; |
640 } | 356 } |
641 | 357 |
642 if (browser_command_line.HasSwitch(switches::kNoSandbox)) { | 358 if (browser_command_line.HasSwitch(switches::kNoSandbox)) { |
643 // The user has explicity opted-out from all sandboxing. | 359 // The user has explicity opted-out from all sandboxing. |
644 in_sandbox = false; | 360 in_sandbox = false; |
645 } | 361 } |
(...skipping 19 matching lines...) Expand all Loading... |
665 } | 381 } |
666 | 382 |
667 bool child_needs_help = | 383 bool child_needs_help = |
668 DebugFlags::ProcessDebugFlags(cmd_line, type, in_sandbox); | 384 DebugFlags::ProcessDebugFlags(cmd_line, type, in_sandbox); |
669 | 385 |
670 // Prefetch hints on windows: | 386 // Prefetch hints on windows: |
671 // Using a different prefetch profile per process type will allow Windows | 387 // Using a different prefetch profile per process type will allow Windows |
672 // to create separate pretetch settings for browser, renderer etc. | 388 // to create separate pretetch settings for browser, renderer etc. |
673 cmd_line->AppendArg(base::StringPrintf("/prefetch:%d", type)); | 389 cmd_line->AppendArg(base::StringPrintf("/prefetch:%d", type)); |
674 | 390 |
675 if (!in_sandbox) { | |
676 base::LaunchApp(*cmd_line, false, false, &process); | |
677 return process; | |
678 } | |
679 | |
680 sandbox::ResultCode result; | 391 sandbox::ResultCode result; |
681 PROCESS_INFORMATION target = {0}; | 392 PROCESS_INFORMATION target = {0}; |
682 sandbox::TargetPolicy* policy = g_broker_services->CreatePolicy(); | 393 sandbox::TargetPolicy* policy = g_broker_services->CreatePolicy(); |
683 | 394 |
684 if (type == ChildProcessInfo::PLUGIN_PROCESS) { | 395 if (type == ChildProcessInfo::PLUGIN_PROCESS && |
685 if (!AddPolicyForPlugin(cmd_line, policy)) | 396 !browser_command_line.HasSwitch(switches::kNoSandbox) && |
686 return 0; | 397 content::GetContentClient()->browser()->SandboxPlugin(cmd_line, policy)) { |
687 } else if (type == ChildProcessInfo::GPU_PROCESS) { | 398 in_sandbox = true; |
| 399 AddDllEvictionPolicy(policy); |
| 400 } |
| 401 |
| 402 if (!in_sandbox) { |
| 403 policy->Release(); |
| 404 base::LaunchApp(*cmd_line, false, false, &process); |
| 405 return process; |
| 406 } |
| 407 |
| 408 if (type == ChildProcessInfo::GPU_PROCESS) { |
688 if (!AddPolicyForGPU(cmd_line, policy)) | 409 if (!AddPolicyForGPU(cmd_line, policy)) |
689 return 0; | 410 return 0; |
690 } else if (type == ChildProcessInfo::PPAPI_PLUGIN_PROCESS) { | 411 } else if (type == ChildProcessInfo::PPAPI_PLUGIN_PROCESS) { |
691 if (!AddPolicyForPepperPlugin(policy)) | 412 if (!AddPolicyForPepperPlugin(policy)) |
692 return 0; | 413 return 0; |
693 } else { | 414 } else { |
694 AddPolicyForRenderer(policy); | 415 AddPolicyForRenderer(policy); |
695 | 416 |
696 if (type_str != switches::kRendererProcess) { | 417 if (type_str != switches::kRendererProcess) { |
697 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into | 418 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 461 |
741 // Help the process a little. It can't start the debugger by itself if | 462 // Help the process a little. It can't start the debugger by itself if |
742 // the process is in a sandbox. | 463 // the process is in a sandbox. |
743 if (child_needs_help) | 464 if (child_needs_help) |
744 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); | 465 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); |
745 | 466 |
746 return process; | 467 return process; |
747 } | 468 } |
748 | 469 |
749 } // namespace sandbox | 470 } // namespace sandbox |
OLD | NEW |