| 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_win.h" | 5 #include "content/common/sandbox_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/activity_tracker.h" | 13 #include "base/debug/activity_tracker.h" |
| 14 #include "base/debug/profiler.h" | 14 #include "base/debug/profiler.h" |
| 15 #include "base/feature_list.h" |
| 15 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 16 #include "base/hash.h" | 17 #include "base/hash.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/memory/shared_memory.h" | 20 #include "base/memory/shared_memory.h" |
| 20 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| 21 #include "base/metrics/histogram_macros.h" | 22 #include "base/metrics/histogram_macros.h" |
| 22 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 23 #include "base/process/launch.h" | 24 #include "base/process/launch.h" |
| 24 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 | 595 |
| 595 #ifdef _WIN64 | 596 #ifdef _WIN64 |
| 596 sandbox::ResultCode ret = | 597 sandbox::ResultCode ret = |
| 597 policy->SetJobMemoryLimit(4ULL * 1024 * 1024 * 1024); | 598 policy->SetJobMemoryLimit(4ULL * 1024 * 1024 * 1024); |
| 598 if (ret != sandbox::SBOX_ALL_OK) | 599 if (ret != sandbox::SBOX_ALL_OK) |
| 599 return ret; | 600 return ret; |
| 600 #endif | 601 #endif |
| 601 return policy->SetJobLevel(job_level, ui_exceptions); | 602 return policy->SetJobLevel(job_level, ui_exceptions); |
| 602 } | 603 } |
| 603 | 604 |
| 605 // This is for finch. See also crbug.com/464430 for details. |
| 606 const base::Feature kEnableCsrssLockdownFeature{ |
| 607 "EnableCsrssLockdown", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 608 |
| 604 // TODO(jschuh): Need get these restrictions applied to NaCl and Pepper. | 609 // TODO(jschuh): Need get these restrictions applied to NaCl and Pepper. |
| 605 // Just have to figure out what needs to be warmed up first. | 610 // Just have to figure out what needs to be warmed up first. |
| 606 sandbox::ResultCode AddBaseHandleClosePolicy(sandbox::TargetPolicy* policy) { | 611 sandbox::ResultCode AddBaseHandleClosePolicy(sandbox::TargetPolicy* policy) { |
| 612 if (base::win::GetVersion() >= base::win::VERSION_WIN10) { |
| 613 if (base::FeatureList::IsEnabled(kEnableCsrssLockdownFeature)) { |
| 614 // Close all ALPC ports. |
| 615 sandbox::ResultCode ret = |
| 616 policy->AddKernelObjectToClose(L"ALPC Port", NULL); |
| 617 if (ret != sandbox::SBOX_ALL_OK) { |
| 618 return ret; |
| 619 } |
| 620 } |
| 621 } |
| 607 // TODO(cpu): Add back the BaseNamedObjects policy. | 622 // TODO(cpu): Add back the BaseNamedObjects policy. |
| 608 base::string16 object_path = PrependWindowsSessionPath( | 623 base::string16 object_path = PrependWindowsSessionPath( |
| 609 L"\\BaseNamedObjects\\windows_shell_global_counters"); | 624 L"\\BaseNamedObjects\\windows_shell_global_counters"); |
| 610 return policy->AddKernelObjectToClose(L"Section", object_path.data()); | 625 return policy->AddKernelObjectToClose(L"Section", object_path.data()); |
| 611 } | 626 } |
| 612 | 627 |
| 613 sandbox::ResultCode AddAppContainerPolicy(sandbox::TargetPolicy* policy, | 628 sandbox::ResultCode AddAppContainerPolicy(sandbox::TargetPolicy* policy, |
| 614 const wchar_t* sid) { | 629 const wchar_t* sid) { |
| 615 if (IsAppContainerEnabled()) | 630 if (IsAppContainerEnabled()) |
| 616 return policy->SetLowBox(sid); | 631 return policy->SetLowBox(sid); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 } | 876 } |
| 862 | 877 |
| 863 delegate->PostSpawnTarget(target.process_handle()); | 878 delegate->PostSpawnTarget(target.process_handle()); |
| 864 | 879 |
| 865 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); | 880 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); |
| 866 *process = base::Process(target.TakeProcessHandle()); | 881 *process = base::Process(target.TakeProcessHandle()); |
| 867 return sandbox::SBOX_ALL_OK; | 882 return sandbox::SBOX_ALL_OK; |
| 868 } | 883 } |
| 869 | 884 |
| 870 } // namespace content | 885 } // namespace content |
| OLD | NEW |