android_system_core/debuggerd
Peter Collingbourne b1fcedb928 Adjust conditions for dumping the memory around a register.
Previously, we would do a simple bounds check before deciding
whether to dump the memory around a register. On 64-bit platforms,
the register's value was required to be less than (4 << 60). However,
after stripping tags on AArch64 as part of r.android.com/1365229, all
pointer values became less than (4 << 60), so the check became useless
for filtering out invalid pointers. As a result, we would attempt to
dump memory for all registers, which for a register not containing
a valid pointer would typically consist of 16 lines of dashes.

One possible fix may be to replace the constant (4 << 60) with the
process's actual address space limit (known as TASK_SIZE inside the
kernel; typically 39 bits on AArch64 and 48 bits on x86_64), but the
kernel provides no API for retrieving a process's TASK_SIZE value. We
could guess it by looking at for example the highest bit set in the
value of getauxval(AT_EXECFN), which points to an address on the stack
which typically is mapped at the end of the address space on program
startup, but at least on AArch64 it is possible to dynamically extend
TASK_SIZE at runtime by providing a hint to mmap(), so this is not
always sufficient.

Instead, it seems best to remove most of the early bounds check, and
simply issue ptrace() calls for each register value, bailing out of
the entire output if none of the calls ended up succeeding. This also
has the nice side effect of avoiding 16 lines of noise per register
whose value looks like a pointer but actually points to unmapped
memory. We still retain part of the bounds check in order to avoid
integer overflow during the dump (including overflows into the tag
part of the address on architectures that support tagging).

Bug: 154272452
Change-Id: I94e4b7124b7735b92fd83a49c80ebded3483cd4e
2020-07-21 16:59:24 -07:00
..
client [GWP-ASan] Add GWP-ASan information to tombstones. 2020-02-18 16:49:50 -08:00
common/include tombstoned: allow intercepts for java traces. 2017-05-31 10:35:32 +01:00
crasher Create a debugger_process_info data structure with the process info pointers. 2020-03-24 17:23:15 -07:00
handler debuggerd: don't leave a zombie child if crash_dump is killed. 2020-04-10 10:09:39 -07:00
include/debuggerd Add support for MTE error reports in tombstones. 2020-04-27 13:15:49 -07:00
libdebuggerd Adjust conditions for dumping the memory around a register. 2020-07-21 16:59:24 -07:00
seccomp_policy debuggerd seccomp: explain why we define PROT_READ/WRITE. 2018-02-18 23:50:19 -08:00
tombstoned debuggerd: increase the default limit on tombstones to 32. 2019-09-26 14:36:01 -07:00
.clang-format Remove extraneous .clang-format files 2017-03-14 14:06:31 -07:00
Android.bp Statically link libminijail to debuggerd_test. 2020-07-21 16:59:24 -07:00
crash_dump.cpp Add support for MTE error reports in tombstones. 2020-04-27 13:15:49 -07:00
debuggerd.cpp debuggerd: add support for Java traces. 2018-06-14 15:40:06 -07:00
debuggerd_benchmark.cpp debuggerd: add pause time benchmark. 2017-12-19 16:36:04 -08:00
debuggerd_test.cpp Fix dumping of heap memory. 2020-07-17 17:35:49 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
OWNERS Add OWNERS. 2017-12-07 13:30:03 -08:00
protocol.h Add support for MTE error reports in tombstones. 2020-04-27 13:15:49 -07:00
util.cpp debuggerd: switch to base::{Send,Receive}FileDescriptors. 2019-02-13 13:21:54 -08:00
util.h debuggerd: switch to base::{Send,Receive}FileDescriptors. 2019-02-13 13:21:54 -08:00