From b2f2fc8184c1f31254002a33966df57d4dd451f7 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 6 Oct 2023 16:58:12 -0700 Subject: [PATCH] Remove unreliable CFI test. Remove tests of implementation details rather than the CFI functionality itself. In particular, CFI is designed to protect against invalid calls to executable code, whereas heap memory is covered by page protection. Bug: http://b/298741930 Test: treehugger Change-Id: Ib7f8af283b4c0001da8fa80a1b281bdc4c50af51 --- tests/cfi_test.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/tests/cfi_test.cpp b/tests/cfi_test.cpp index 1c4594639..4b061b34f 100644 --- a/tests/cfi_test.cpp +++ b/tests/cfi_test.cpp @@ -70,21 +70,8 @@ class cfi_test_DeathTest : public testing::Test { struct sigaction64 previous_sigtrap_; }; -static bool KilledByCfi(int status) { - return WIFSIGNALED(status) && - (WTERMSIG(status) == SIGTRAP || WTERMSIG(status) == SIGILL || WTERMSIG(status) == SIGSEGV); -} - static void f() {} -static void test_cfi_slowpath_with_alloc() { - std::vector allocs; - for (size_t i = 0; i < 1000; i++) { - allocs.push_back(malloc(4096)); - __cfi_slowpath(46, allocs.back()); - } -} - TEST_F(cfi_test_DeathTest, basic) { #if defined(__BIONIC__) void* handle; @@ -135,12 +122,6 @@ TEST_F(cfi_test_DeathTest, basic) { EXPECT_EQ(get_global_address(), get_last_address()); EXPECT_EQ(c, get_count()); - // CFI check for a heap address. - // It's possible that this allocation could wind up in the same CFI granule as - // an unchecked library, which means the below might not crash. To force a - // crash keep allocating up to a max until there is a crash. - EXPECT_EXIT(test_cfi_slowpath_with_alloc(), KilledByCfi, ""); - // Check all the addresses. const size_t bss_size = 1024 * 1024; static_assert(bss_size >= kLibraryAlignment * 2, "test range not big enough"); @@ -162,10 +143,6 @@ TEST_F(cfi_test_DeathTest, basic) { dlclose(handle); dlclose(handle2); - - // CFI check for a function inside the unloaded DSO. This is always invalid and gets the process - // killed. - EXPECT_EXIT(__cfi_slowpath(45, reinterpret_cast(code_ptr)), KilledByCfi, ""); #endif }