Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: sandbox/win/tests/integration_tests/cfi_unittest.cc

Issue 2679793002: [Windows CFG Test] Added unittest for CFG enabling on process. (Closed)
Patch Set: Code review fixes, part 2. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/BUILD.gn ('k') | sandbox/win/tests/integration_tests/cfi_unittest_exe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #include <windows.h>
5
6 #include "base/command_line.h"
7 #include "base/files/file_util.h"
8 #include "base/process/launch.h"
9 #include "base/test/test_timeouts.h"
10 #include "base/win/windows_version.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace sandbox {
14 // ASLR must be enabled for CFG to be enabled. As ASLR is disabled in debug
15 // builds, so must be CFG.
16 #if defined(NDEBUG)
17
18 // Make sure Microsoft binaries, that are compiled with CFG enabled, catch
19 // a hook and throw an exception.
20 // - If this test fails, the expected CFG exception did NOT happen. This
21 // indicates a build system change that has disabled Chrome process-wide CFG.
22 TEST(CFGSupportTests, MsIndirectFailure) {
23 // CFG is only supported on >= Win8.1 Update 3.
24 // Not checking for update, since test infra is updated and it would add
25 // a lot of complexity.
26 if (base::win::GetVersion() < base::win::VERSION_WIN8_1)
27 return;
28
29 const wchar_t* exe_filename = L"cfi_unittest_exe.exe";
30 const wchar_t* sys_dll_test = L"1";
31
32 base::CommandLine cmd_line = base::CommandLine::FromString(exe_filename);
33 cmd_line.AppendArgNative(sys_dll_test);
34
35 base::Process proc =
36 base::LaunchProcess(cmd_line, base::LaunchOptionsForTest());
37 ASSERT_TRUE(proc.IsValid());
38
39 int exit_code = 0;
40 if (!proc.WaitForExitWithTimeout(TestTimeouts::action_timeout(),
41 &exit_code)) {
42 // Timeout while waiting. Try to cleanup.
43 proc.Terminate(1, false);
44 ADD_FAILURE();
45 return;
46 }
47
48 // CFG security check failure.
49 ASSERT_EQ(STATUS_STACK_BUFFER_OVERRUN, static_cast<DWORD>(exit_code));
50 }
51
52 #endif // defined(NDEBUG)
53 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/BUILD.gn ('k') | sandbox/win/tests/integration_tests/cfi_unittest_exe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698