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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/profiler.h" | 11 #include "base/debug/profiler.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/hash.h" | 13 #include "base/hash.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/metrics/sparse_histogram.h" | 16 #include "base/metrics/sparse_histogram.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process/launch.h" | 18 #include "base/process/launch.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
23 #include "base/win/iat_patch_function.h" | 23 #include "base/win/iat_patch_function.h" |
24 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
25 #include "base/win/scoped_process_information.h" | 25 #include "base/win/scoped_process_information.h" |
26 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
27 #include "content/common/content_switches_internal.h" | 27 #include "content/common/content_switches_internal.h" |
28 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
30 #include "content/public/common/dwrite_font_platform_win.h" | |
31 #include "content/public/common/sandbox_init.h" | 30 #include "content/public/common/sandbox_init.h" |
32 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 31 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
33 #include "sandbox/win/src/process_mitigations.h" | 32 #include "sandbox/win/src/process_mitigations.h" |
34 #include "sandbox/win/src/sandbox.h" | 33 #include "sandbox/win/src/sandbox.h" |
35 #include "sandbox/win/src/sandbox_nt_util.h" | 34 #include "sandbox/win/src/sandbox_nt_util.h" |
36 #include "sandbox/win/src/sandbox_policy_base.h" | 35 #include "sandbox/win/src/sandbox_policy_base.h" |
37 #include "sandbox/win/src/win_utils.h" | 36 #include "sandbox/win/src/win_utils.h" |
38 #include "ui/gfx/win/direct_write.h" | 37 #include "ui/gfx/win/direct_write.h" |
39 | 38 |
40 static sandbox::BrokerServices* g_broker_services = NULL; | 39 static sandbox::BrokerServices* g_broker_services = NULL; |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 715 |
717 #if !defined(NACL_WIN64) | 716 #if !defined(NACL_WIN64) |
718 if (type_str == switches::kRendererProcess || | 717 if (type_str == switches::kRendererProcess || |
719 type_str == switches::kPpapiPluginProcess) { | 718 type_str == switches::kPpapiPluginProcess) { |
720 if (gfx::win::ShouldUseDirectWrite()) { | 719 if (gfx::win::ShouldUseDirectWrite()) { |
721 AddDirectory(base::DIR_WINDOWS_FONTS, | 720 AddDirectory(base::DIR_WINDOWS_FONTS, |
722 NULL, | 721 NULL, |
723 true, | 722 true, |
724 sandbox::TargetPolicy::FILES_ALLOW_READONLY, | 723 sandbox::TargetPolicy::FILES_ALLOW_READONLY, |
725 policy); | 724 policy); |
726 | |
727 // If DirectWrite is enabled for font rendering then open the font cache | |
728 // section which is created by the browser and pass the handle to the | |
729 // renderer process. This is needed because renderer processes on | |
730 // Windows 8+ may be running in an AppContainer sandbox and hence their | |
731 // kernel object namespace may be partitioned. | |
732 std::string name(content::kFontCacheSharedSectionName); | |
733 name.append(base::UintToString(base::GetCurrentProcId())); | |
734 | |
735 base::SharedMemory direct_write_font_cache_section; | |
736 if (direct_write_font_cache_section.Open(name, true)) { | |
737 void* shared_handle = policy->AddHandleToShare( | |
738 direct_write_font_cache_section.handle().GetHandle()); | |
739 cmd_line->AppendSwitchASCII(switches::kFontCacheSharedHandle, | |
740 base::UintToString(reinterpret_cast<unsigned int>(shared_handle))); | |
741 } | |
742 } | 725 } |
743 } | 726 } |
744 #endif | 727 #endif |
745 | 728 |
746 if (type_str != switches::kRendererProcess) { | 729 if (type_str != switches::kRendererProcess) { |
747 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into | 730 // Hack for Google Desktop crash. Trick GD into not injecting its DLL into |
748 // this subprocess. See | 731 // this subprocess. See |
749 // http://code.google.com/p/chromium/issues/detail?id=25580 | 732 // http://code.google.com/p/chromium/issues/detail?id=25580 |
750 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); | 733 cmd_line->AppendSwitchASCII("ignored", " --type=renderer "); |
751 } | 734 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } | 849 } |
867 | 850 |
868 return false; | 851 return false; |
869 } | 852 } |
870 | 853 |
871 bool BrokerAddTargetPeer(HANDLE peer_process) { | 854 bool BrokerAddTargetPeer(HANDLE peer_process) { |
872 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; | 855 return g_broker_services->AddTargetPeer(peer_process) == sandbox::SBOX_ALL_OK; |
873 } | 856 } |
874 | 857 |
875 } // namespace content | 858 } // namespace content |
OLD | NEW |