diff options
author | rickyz <rickyz@chromium.org> | 2015-11-16 16:17:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-17 00:18:51 +0000 |
commit | 020a9e098c32710edd20534c8de584a25cc3c1ac (patch) | |
tree | 5bdafeacd44f0ea39687619a8a2408dc03a6361a /sandbox/win | |
parent | 8335a8869b48e2c5837c12bca370bd44de058c3f (diff) | |
download | chromium_src-020a9e098c32710edd20534c8de584a25cc3c1ac.zip chromium_src-020a9e098c32710edd20534c8de584a25cc3c1ac.tar.gz chromium_src-020a9e098c32710edd20534c8de584a25cc3c1ac.tar.bz2 |
Revert "Fix inherited handles conflicting with handle tracker"
This reverts commit 2504e304501a29ba1798a2268cfe78ed8d7864dd.
As of https://codereview.chromium.org/1355703002, the handle tracker no
longer marks handles as non-closeable, so this is no longer necessary.
BUG=524267
Review URL: https://codereview.chromium.org/1423603004
Cr-Commit-Position: refs/heads/master@{#359954}
Diffstat (limited to 'sandbox/win')
-rw-r--r-- | sandbox/win/src/broker_services.cc | 24 | ||||
-rw-r--r-- | sandbox/win/src/handle_inheritance_test.cc | 40 |
2 files changed, 0 insertions, 64 deletions
diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc index fbebc83..5e6494f 100644 --- a/sandbox/win/src/broker_services.cc +++ b/sandbox/win/src/broker_services.cc @@ -415,23 +415,6 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, if (NULL == thread_pool_) thread_pool_ = new Win2kThreadPool(); - // We need to temporarily mark all inherited handles as closeable. The handle - // tracker may have marked the handles we're passing to the child as - // non-closeable, but the child is getting new copies that it's allowed to - // close. We're about to mark these handles as closeable for this process - // (when we close them below in ClearSharedHandles()) but that will be too - // late -- there will already another copy in the child that's non-closeable. - // After launching we restore the non-closability of these handles. We don't - // have any way here to affect *only* the child's copy, as the process - // launching mechanism takes care of doing the duplication-with-the-same-value - // into the child. - std::vector<DWORD> inherited_handle_information(inherited_handle_list.size()); - for (size_t i = 0; i < inherited_handle_list.size(); ++i) { - const HANDLE& inherited_handle = inherited_handle_list[i]; - ::GetHandleInformation(inherited_handle, &inherited_handle_information[i]); - ::SetHandleInformation(inherited_handle, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0); - } - // Create the TargetProces object and spawn the target suspended. Note that // Brokerservices does not own the target object. It is owned by the Policy. base::win::ScopedProcessInformation process_info; @@ -442,13 +425,6 @@ ResultCode BrokerServicesBase::SpawnTarget(const wchar_t* exe_path, DWORD win_result = target->Create(exe_path, command_line, inherit_handles, startup_info, &process_info); - // Restore the previous handle protection values. - for (size_t i = 0; i < inherited_handle_list.size(); ++i) { - ::SetHandleInformation(inherited_handle_list[i], - HANDLE_FLAG_PROTECT_FROM_CLOSE, - inherited_handle_information[i]); - } - policy_base->ClearSharedHandles(); if (ERROR_SUCCESS != win_result) { diff --git a/sandbox/win/src/handle_inheritance_test.cc b/sandbox/win/src/handle_inheritance_test.cc index 1a411b5..d8c2808 100644 --- a/sandbox/win/src/handle_inheritance_test.cc +++ b/sandbox/win/src/handle_inheritance_test.cc @@ -6,9 +6,6 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" -#include "base/memory/shared_memory.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/utf_string_conversions.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/win/tests/common/controller.h" @@ -52,41 +49,4 @@ TEST(HandleInheritanceTests, TestStdoutInheritance) { } } -SBOX_TESTS_COMMAND int -HandleInheritanceTests_ValidInheritedHandle(int argc, wchar_t **argv) { - if (argc != 1) - return SBOX_TEST_FAILED_TO_RUN_TEST; - HANDLE handle = nullptr; - base::StringToUint(argv[0], reinterpret_cast<unsigned int *>(&handle)); - - // This handle we inherited must be both valid and closeable. - DWORD flags = 0; - if (!GetHandleInformation(handle, &flags)) - return SBOX_TEST_FAILED; - if ((flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) != 0) - return SBOX_TEST_FAILED; - - return SBOX_TEST_SUCCEEDED; -} - -TEST(HandleInheritanceTests, InheritByValue) { - // Handle inheritance doesn't work on XP. - if (base::win::GetVersion() < base::win::VERSION_VISTA) - return; - - base::SharedMemory test_shared_memory; - ASSERT_TRUE(test_shared_memory.CreateAnonymous(1000)); - ASSERT_TRUE(test_shared_memory.Map(0)); - - TestRunner runner; - void* shared_handle = runner.GetPolicy()->AddHandleToShare( - test_shared_memory.handle().GetHandle()); - - std::string command_line = - "HandleInheritanceTests_ValidInheritedHandle " + - base::UintToString(reinterpret_cast<unsigned int>(shared_handle)); - int result = runner.RunTest(base::UTF8ToUTF16(command_line).c_str()); - ASSERT_EQ(SBOX_TEST_SUCCEEDED, result); -} - } // namespace sandbox |