From bf2d6dd7d40e1b52986753277c9ef9a2f33abd22 Mon Sep 17 00:00:00 2001 From: Mitch Phillips Date: Tue, 6 Feb 2024 15:18:04 +0100 Subject: [PATCH] Update debuggerd for stack MTE. Two things need changing for debuggerd_test to pass. 1. The seccomp policy needs to allow for PROT_MTE (0x20) in both mprotect() and mmap(). Stack MTE processes do a mprotect()/mmap() of the stack when launching a process. 2. The fault address and stack pointer need to be untagged when trying to figure out the stack overflow cause. Bug: 320448268 Bug: 292478827 Test: atest debuggerd_test --iterations=10 Change-Id: I56471c32ca40edffbb61b7547bdf2b85a6eb1ff7 --- debuggerd/libdebuggerd/tombstone_proto.cpp | 5 +++++ debuggerd/seccomp_policy/crash_dump.arm64.policy | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debuggerd/libdebuggerd/tombstone_proto.cpp b/debuggerd/libdebuggerd/tombstone_proto.cpp index 744bfabf5..ca2551011 100644 --- a/debuggerd/libdebuggerd/tombstone_proto.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto.cpp @@ -94,6 +94,11 @@ static Architecture get_arch() { static std::optional get_stack_overflow_cause(uint64_t fault_addr, uint64_t sp, unwindstack::Maps* maps) { + // Under stack MTE the stack pointer and/or the fault address can be tagged. + // In order to calculate deltas between them, strip off the tags off both + // addresses. + fault_addr = untag_address(fault_addr); + sp = untag_address(sp); static constexpr uint64_t kMaxDifferenceBytes = 256; uint64_t difference; if (sp >= fault_addr) { diff --git a/debuggerd/seccomp_policy/crash_dump.arm64.policy b/debuggerd/seccomp_policy/crash_dump.arm64.policy index adf87380e..c5d10d66b 100644 --- a/debuggerd/seccomp_policy/crash_dump.arm64.policy +++ b/debuggerd/seccomp_policy/crash_dump.arm64.policy @@ -28,11 +28,11 @@ rt_sigaction: 1 rt_tgsigqueueinfo: 1 prctl: arg0 == PR_GET_NO_NEW_PRIVS || arg0 == 0x53564d41 || arg0 == PR_PAC_RESET_KEYS || arg0 == 56 || arg0 == 61 madvise: 1 -mprotect: arg2 in 0x1|0x2 +mprotect: arg2 in 0x1|0x2|0x20 munmap: 1 getuid: 1 fstat: 1 -mmap: arg2 in 0x1|0x2 +mmap: arg2 in 0x1|0x2|0x20 geteuid: 1 getgid: 1 getegid: 1