Commit e28197b1 authored by Katie Dektar's avatar Katie Dektar Committed by Commit Bot

Revert "Add test that verifies CFG loader config is generated correctly."

This reverts commit c2b6797f.

Reason for revert: Broke compile on Window:
https://ci.chromium.org/p/chromium/builders/ci/Win%20Builder/96923?

Original change's description:
> Add test that verifies CFG loader config is generated correctly.
> 
> This CL adds a test that creates a callback from operating system
> code to a module that has CFG enabled where the callback is not
> listed as a valid indirect target.
> 
> Note: this test does not require dispatch guards to be present
> in chromium code, just for them to be present in OS code and
> for the CFG load config to be generated correctly.
> 
> BUG=584575
> 
> Change-Id: Id6f5f4061f7237c23f08c8fe1b7471ea200f0628
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308854
> Commit-Queue: Will Harris <wfh@chromium.org>
> Reviewed-by: Alex Gough <ajgo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#790587}

TBR=wfh@chromium.org,ajgo@chromium.org

Change-Id: I8d5070d373d381146ee1e906e57bdc0323a7e0ab
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 584575
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311146Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790593}
parent 9396150b
...@@ -217,7 +217,6 @@ test("sbox_integration_tests") { ...@@ -217,7 +217,6 @@ test("sbox_integration_tests") {
"tests/common/controller.h", "tests/common/controller.h",
"tests/common/test_utils.cc", "tests/common/test_utils.cc",
"tests/common/test_utils.h", "tests/common/test_utils.h",
"tests/integration_tests/cfi_unittest.cc",
"tests/integration_tests/integration_tests.cc", "tests/integration_tests/integration_tests.cc",
"tests/integration_tests/integration_tests_common.h", "tests/integration_tests/integration_tests_common.h",
"tests/integration_tests/integration_tests_test.cc", "tests/integration_tests/integration_tests_test.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <intrin.h>
#include <windows.h>
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace sandbox {
// ASLR must be enabled for CFG to be enabled, and ASLR is disabled in debug
// builds.
#if !defined(_DEBUG)
namespace {
DWORD CopyProgressRoutine(LARGE_INTEGER total_file_size,
LARGE_INTEGER total_bytes_transferred,
LARGE_INTEGER stream_size,
LARGE_INTEGER stream_bytes_transferred,
DWORD stream_number,
DWORD callback_reason,
HANDLE source_file,
HANDLE destination_file,
LPVOID context) {
__asm {
nop
nop
ret
}
return PROGRESS_CONTINUE;
}
} // namespace
// Make sure Microsoft binaries compiled with CFG cannot call indirect pointers
// not listed in the loader config for this test binary.
TEST(CFGSupportTests, MsIndirectFailure) {
// CFG is only supported on >= Win8.1 Update 3.
// Not checking for update, since test infra is updated and it would add
// a lot of complexity.
if (base::win::GetVersion() < base::win::Version::WIN8_1)
return;
base::FilePath exe_path;
ASSERT_TRUE(base::PathService::Get(base::FILE_EXE, &exe_path));
using ProcessCallbackRoutineType = decltype(&CopyProgressRoutine);
// Create a bad callback pointer to midway into the callback function. This
// should cause a CFG violation in MS code.
auto bad_callback_func = reinterpret_cast<ProcessCallbackRoutineType>(
(reinterpret_cast<uintptr_t>(CopyProgressRoutine)) + 0x1);
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath temp_file_path = temp_dir.GetPath().AppendASCII("file.dat");
EXPECT_EXIT(
// CopyFileEx calls back into our code.
CopyFileExW(exe_path.value().c_str(), temp_file_path.value().c_str(),
bad_callback_func, nullptr, FALSE, 0),
::testing::ExitedWithCode(STATUS_STACK_BUFFER_OVERRUN), "");
}
#endif // !defined(_DEBUG)
} // namespace sandbox
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment