OLD | NEW |
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_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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // The DLLs listed here are known (or under strong suspicion) of causing crashes | 113 // The DLLs listed here are known (or under strong suspicion) of causing crashes |
114 // when they are loaded in the plugin process. | 114 // when they are loaded in the plugin process. |
115 const wchar_t* const kTroublesomePluginDlls[] = { | 115 const wchar_t* const kTroublesomePluginDlls[] = { |
116 L"rpmainbrowserrecordplugin.dll", // RealPlayer. | 116 L"rpmainbrowserrecordplugin.dll", // RealPlayer. |
117 L"rpchromebrowserrecordhelper.dll", // RealPlayer. | 117 L"rpchromebrowserrecordhelper.dll", // RealPlayer. |
118 L"rpchrome10browserrecordhelper.dll", // RealPlayer. | 118 L"rpchrome10browserrecordhelper.dll", // RealPlayer. |
119 L"ycwebcamerasource.ax" // Cyberlink Camera helper. | 119 L"ycwebcamerasource.ax" // Cyberlink Camera helper. |
120 L"CLRGL.ax" // Cyberlink Camera helper. | 120 L"CLRGL.ax" // Cyberlink Camera helper. |
121 }; | 121 }; |
122 | 122 |
| 123 // The DLLs listed here are known (or under strong suspicion) of causing crashes |
| 124 // when they are loaded in the GPU process. |
| 125 const wchar_t* const kTroublesomeGpuDlls[] = { |
| 126 L"cmsetac.dll", // Unknown (suspected malware). |
| 127 }; |
| 128 |
123 // Adds the policy rules for the path and path\ with the semantic |access|. | 129 // Adds the policy rules for the path and path\ with the semantic |access|. |
124 // If |children| is set to true, we need to add the wildcard rules to also | 130 // If |children| is set to true, we need to add the wildcard rules to also |
125 // apply the rule to the subfiles and subfolders. | 131 // apply the rule to the subfiles and subfolders. |
126 bool AddDirectory(int path, const wchar_t* sub_dir, bool children, | 132 bool AddDirectory(int path, const wchar_t* sub_dir, bool children, |
127 sandbox::TargetPolicy::Semantics access, | 133 sandbox::TargetPolicy::Semantics access, |
128 sandbox::TargetPolicy* policy) { | 134 sandbox::TargetPolicy* policy) { |
129 FilePath directory; | 135 FilePath directory; |
130 if (!PathService::Get(path, &directory)) | 136 if (!PathService::Get(path, &directory)) |
131 return false; | 137 return false; |
132 | 138 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); | 241 BlacklistAddOneDll(kTroublesomeDlls[ix], true, policy); |
236 } | 242 } |
237 | 243 |
238 // Same as AddGenericDllEvictionPolicy but specifically for plugins. In this | 244 // Same as AddGenericDllEvictionPolicy but specifically for plugins. In this |
239 // case we add the blacklisted dlls even if they are not loaded in this process. | 245 // case we add the blacklisted dlls even if they are not loaded in this process. |
240 void AddPluginDllEvictionPolicy(sandbox::TargetPolicy* policy) { | 246 void AddPluginDllEvictionPolicy(sandbox::TargetPolicy* policy) { |
241 for (int ix = 0; ix != arraysize(kTroublesomePluginDlls); ++ix) | 247 for (int ix = 0; ix != arraysize(kTroublesomePluginDlls); ++ix) |
242 BlacklistAddOneDll(kTroublesomePluginDlls[ix], false, policy); | 248 BlacklistAddOneDll(kTroublesomePluginDlls[ix], false, policy); |
243 } | 249 } |
244 | 250 |
| 251 // Same as AddGenericDllEvictionPolicy but specifically for the GPU process. |
| 252 // In this we add the blacklisted dlls even if they are not loaded in this |
| 253 // process. |
| 254 void AddGpuDllEvictionPolicy(sandbox::TargetPolicy* policy) { |
| 255 for (int ix = 0; ix != arraysize(kTroublesomeGpuDlls); ++ix) |
| 256 BlacklistAddOneDll(kTroublesomeGpuDlls[ix], false, policy); |
| 257 } |
| 258 |
245 // Returns the object path prepended with the current logon session. | 259 // Returns the object path prepended with the current logon session. |
246 string16 PrependWindowsSessionPath(const char16* object) { | 260 string16 PrependWindowsSessionPath(const char16* object) { |
247 // Cache this because it can't change after process creation. | 261 // Cache this because it can't change after process creation. |
248 static uintptr_t s_session_id = 0; | 262 static uintptr_t s_session_id = 0; |
249 if (s_session_id == 0) { | 263 if (s_session_id == 0) { |
250 HANDLE token; | 264 HANDLE token; |
251 DWORD session_id_length; | 265 DWORD session_id_length; |
252 DWORD session_id = 0; | 266 DWORD session_id = 0; |
253 | 267 |
254 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)); | 268 CHECK(::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // GPU also needs to add sections to the browser for aura | 412 // GPU also needs to add sections to the browser for aura |
399 // TODO(jschuh): refactor the GPU channel to remove this. crbug.com/128786 | 413 // TODO(jschuh): refactor the GPU channel to remove this. crbug.com/128786 |
400 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 414 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
401 sandbox::TargetPolicy::HANDLES_DUP_BROKER, | 415 sandbox::TargetPolicy::HANDLES_DUP_BROKER, |
402 L"Section"); | 416 L"Section"); |
403 if (result != sandbox::SBOX_ALL_OK) | 417 if (result != sandbox::SBOX_ALL_OK) |
404 return false; | 418 return false; |
405 #endif | 419 #endif |
406 | 420 |
407 AddGenericDllEvictionPolicy(policy); | 421 AddGenericDllEvictionPolicy(policy); |
| 422 AddGpuDllEvictionPolicy(policy); |
408 #endif | 423 #endif |
409 return true; | 424 return true; |
410 } | 425 } |
411 | 426 |
412 bool AddPolicyForRenderer(sandbox::TargetPolicy* policy) { | 427 bool AddPolicyForRenderer(sandbox::TargetPolicy* policy) { |
413 // Renderers need to copy sections for plugin DIBs and GPU. | 428 // Renderers need to copy sections for plugin DIBs and GPU. |
414 sandbox::ResultCode result; | 429 sandbox::ResultCode result; |
415 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, | 430 result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_HANDLES, |
416 sandbox::TargetPolicy::HANDLES_DUP_ANY, | 431 sandbox::TargetPolicy::HANDLES_DUP_ANY, |
417 L"Section"); | 432 L"Section"); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 865 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
851 } | 866 } |
852 | 867 |
853 base::ProcessHandle StartProcessWithAccess( | 868 base::ProcessHandle StartProcessWithAccess( |
854 CommandLine* cmd_line, | 869 CommandLine* cmd_line, |
855 const FilePath& exposed_dir) { | 870 const FilePath& exposed_dir) { |
856 return sandbox::StartProcessWithAccess(cmd_line, exposed_dir); | 871 return sandbox::StartProcessWithAccess(cmd_line, exposed_dir); |
857 } | 872 } |
858 | 873 |
859 } // namespace content | 874 } // namespace content |
OLD | NEW |