From f03af8844acbd63f257c51577834d2c126a41f47 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 20 Mar 2020 18:09:00 -0700 Subject: Read fault address on arm64 using proposed kernel API. On aarch64, the top 8 bits of the address (i.e. the tag bits) of the fault address in si_addr are always clear. This isn't ideal for MTE which will require these bits in order to correctly diagnose tag mismatches. A proposed kernel patch [1] exposes the full fault address including the tag bits as part of the ucontext. Change debuggerd to read this fault address if available. [1] https://patchwork.kernel.org/patch/11435077/ Bug: 135772972 Change-Id: Ia05be574113860f4e9ecc36a310c4b740e0c4afb --- debuggerd/debuggerd_test.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'debuggerd/debuggerd_test.cpp') diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 6a8cc563d..054f83675 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -305,6 +305,32 @@ TEST_F(CrasherTest, smoke) { ASSERT_MATCH(result, R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr 0xdead)"); } +TEST_F(CrasherTest, tagged_fault_addr) { +#if !defined(__aarch64__) + GTEST_SKIP() << "Requires aarch64"; +#endif + int intercept_result; + unique_fd output_fd; + StartProcess([]() { + *reinterpret_cast(0x100000000000dead) = '1'; + }); + + StartIntercept(&output_fd); + FinishCrasher(); + AssertDeath(SIGSEGV); + FinishIntercept(&intercept_result); + + ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; + + std::string result; + ConsumeFd(std::move(output_fd), &result); + + // The address can either be tagged (new kernels) or untagged (old kernels). + ASSERT_MATCH( + result, + R"(signal 11 \(SIGSEGV\), code 1 \(SEGV_MAPERR\), fault addr (0x100000000000dead|0xdead))"); +} + TEST_F(CrasherTest, LD_PRELOAD) { int intercept_result; unique_fd output_fd; -- cgit v1.2.3