| 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 "content/common/sandbox_policy.h" | 5 #include "content/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" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // We found it, but because it only has 6 significant letters, we | 191 // We found it, but because it only has 6 significant letters, we |
| 192 // want to make sure it is the right one. | 192 // want to make sure it is the right one. |
| 193 if (!IsExpandedModuleName(module, module_name)) | 193 if (!IsExpandedModuleName(module, module_name)) |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 // Found a match. We add both forms to the policy. | 196 // Found a match. We add both forms to the policy. |
| 197 policy->AddDllToUnload(alt_name.c_str()); | 197 policy->AddDllToUnload(alt_name.c_str()); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 policy->AddDllToUnload(module_name); | 200 policy->AddDllToUnload(module_name); |
| 201 DVLOG(1) << "dll to unload found: " << module_name; | 201 VLOG(1) << "dll to unload found: " << module_name; |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Adds policy rules for unloaded the known dlls that cause chrome to crash. | 205 // Adds policy rules for unloaded the known dlls that cause chrome to crash. |
| 206 // Eviction of injected DLLs is done by the sandbox so that the injected module | 206 // Eviction of injected DLLs is done by the sandbox so that the injected module |
| 207 // does not get a chance to execute any code. | 207 // does not get a chance to execute any code. |
| 208 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) { | 208 void AddGenericDllEvictionPolicy(sandbox::TargetPolicy* policy) { |
| 209 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix) | 209 for (int ix = 0; ix != arraysize(kTroublesomeDlls); ++ix) |
| 210 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); | 210 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); |
| 211 } | 211 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 return true; | 367 return true; |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace | 370 } // namespace |
| 371 | 371 |
| 372 namespace sandbox { | 372 namespace sandbox { |
| 373 | 373 |
| 374 void InitBrokerServices(sandbox::BrokerServices* broker_services) { | 374 void InitBrokerServices(sandbox::BrokerServices* broker_services) { |
| 375 // TODO(abarth): DCHECK(CalledOnValidThread()); | 375 // TODO(abarth): DCHECK(CalledOnValidThread()); |
| 376 // See <http://b/1287166>. | 376 // See <http://b/1287166>. |
| 377 DCHECK(broker_services); | 377 CHECK(broker_services); |
| 378 DCHECK(!g_broker_services); | 378 CHECK(!g_broker_services); |
| 379 broker_services->Init(); | 379 broker_services->Init(); |
| 380 g_broker_services = broker_services; | 380 g_broker_services = broker_services; |
| 381 } | 381 } |
| 382 | 382 |
| 383 base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, | 383 base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, |
| 384 const FilePath& exposed_dir) { | 384 const FilePath& exposed_dir) { |
| 385 base::ProcessHandle process = 0; | 385 base::ProcessHandle process = 0; |
| 386 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 386 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 387 ChildProcessInfo::ProcessType type; | 387 ChildProcessInfo::ProcessType type; |
| 388 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); | 388 std::string type_str = cmd_line->GetSwitchValueASCII(switches::kProcessType); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 413 // First case: all process types except the nacl broker, and the plugin | 413 // First case: all process types except the nacl broker, and the plugin |
| 414 // process are sandboxed by default. | 414 // process are sandboxed by default. |
| 415 bool in_sandbox = | 415 bool in_sandbox = |
| 416 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && | 416 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && |
| 417 (type != ChildProcessInfo::PLUGIN_PROCESS); | 417 (type != ChildProcessInfo::PLUGIN_PROCESS); |
| 418 | 418 |
| 419 // If it is the GPU process then it can be disabled by a command line flag. | 419 // If it is the GPU process then it can be disabled by a command line flag. |
| 420 if ((type == ChildProcessInfo::GPU_PROCESS) && | 420 if ((type == ChildProcessInfo::GPU_PROCESS) && |
| 421 (browser_command_line.HasSwitch(switches::kDisableGpuSandbox))) { | 421 (browser_command_line.HasSwitch(switches::kDisableGpuSandbox))) { |
| 422 in_sandbox = false; | 422 in_sandbox = false; |
| 423 DVLOG(1) << "GPU sandbox is disabled"; | 423 VLOG(1) << "GPU sandbox is disabled"; |
| 424 } | 424 } |
| 425 | 425 |
| 426 if (browser_command_line.HasSwitch(switches::kNoSandbox) || | 426 if (browser_command_line.HasSwitch(switches::kNoSandbox) || |
| 427 cmd_line->HasSwitch(switches::kNoSandbox)) { | 427 cmd_line->HasSwitch(switches::kNoSandbox)) { |
| 428 // The user or the caller has explicity opted-out from all sandboxing. | 428 // The user or the caller has explicity opted-out from all sandboxing. |
| 429 in_sandbox = false; | 429 in_sandbox = false; |
| 430 } | 430 } |
| 431 | 431 |
| 432 #if !defined (GOOGLE_CHROME_BUILD) | 432 #if !defined (GOOGLE_CHROME_BUILD) |
| 433 if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) { | 433 if (browser_command_line.HasSwitch(switches::kInProcessPlugins)) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 | 525 |
| 526 result = g_broker_services->SpawnTarget( | 526 result = g_broker_services->SpawnTarget( |
| 527 cmd_line->GetProgram().value().c_str(), | 527 cmd_line->GetProgram().value().c_str(), |
| 528 cmd_line->GetCommandLineString().c_str(), | 528 cmd_line->GetCommandLineString().c_str(), |
| 529 policy, &target); | 529 policy, &target); |
| 530 policy->Release(); | 530 policy->Release(); |
| 531 | 531 |
| 532 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 532 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 533 | 533 |
| 534 if (sandbox::SBOX_ALL_OK != result) { | 534 if (sandbox::SBOX_ALL_OK != result) { |
| 535 DLOG(ERROR) << "Failed to launch process. Error: " << result; | 535 LOG(ERROR) << "Failed to launch process. Error: " << result; |
| 536 return 0; | 536 return 0; |
| 537 } | 537 } |
| 538 | 538 |
| 539 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of | 539 // For Native Client sel_ldr processes on 32-bit Windows, reserve 1 GB of |
| 540 // address space to prevent later failure due to address space fragmentation | 540 // address space to prevent later failure due to address space fragmentation |
| 541 // from .dll loading. The NaCl process will attempt to locate this space by | 541 // from .dll loading. The NaCl process will attempt to locate this space by |
| 542 // scanning the address space using VirtualQuery. | 542 // scanning the address space using VirtualQuery. |
| 543 // TODO(bbudge) Handle the --no-sandbox case. | 543 // TODO(bbudge) Handle the --no-sandbox case. |
| 544 // http://code.google.com/p/nativeclient/issues/detail?id=2131 | 544 // http://code.google.com/p/nativeclient/issues/detail?id=2131 |
| 545 if (type == ChildProcessInfo::NACL_LOADER_PROCESS && | 545 if (type == ChildProcessInfo::NACL_LOADER_PROCESS && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 562 | 562 |
| 563 // Help the process a little. It can't start the debugger by itself if | 563 // Help the process a little. It can't start the debugger by itself if |
| 564 // the process is in a sandbox. | 564 // the process is in a sandbox. |
| 565 if (child_needs_help) | 565 if (child_needs_help) |
| 566 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); | 566 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); |
| 567 | 567 |
| 568 return process; | 568 return process; |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace sandbox | 571 } // namespace sandbox |
| OLD | NEW |