summaryrefslogtreecommitdiff
path: root/debuggerd/libdebuggerd/utility.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update for accurate unreadable elf files.Christopher Ferris2022-03-151-4/+17
| | | | | | | | | | | | | The functionality moved from the Unwinder object to the MapInfo object and means that the individual unreadable files can be displayed now. Included adding the unreadable elfs per thread in the protobuf. Updated the unwinder test. Test: All unit tests pass. Change-Id: I7140bde16938736da005f926e10bbdb3dbc0f6f5
* debuggerd: add the PAC keys to the tombstones.Elliott Hughes2022-01-131-22/+31
| | | | | | | | Hard to get otherwise if you're trying to debug PAC issues. Bug: http://b/214314197 Test: treehugger Change-Id: I2e5502809f84579bf287364e59d6e7ff67770919
* Merge "Improvements to tombstone output."Treehugger Robot2021-11-121-1/+2
|\
| * Improvements to tombstone output.Peter Collingbourne2021-11-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use "likelihood" instead of "probability" since that has connotations of being less precise, and our probability ordering isn't very precise anyway. - Hide the fault address with SEGV_MTEAERR because it is not available. - Pad the fault address with leading zeroes to make it clearer which bits of the top byte (and any following bytes such as PAC signature bits) are set. Bug: 206015287 Change-Id: I5e1e99b7f3e967c44781d8550bbd7158eb421b64
* | Add a human readable description of the tagged_addr_ctrl value to tombstones.Peter Collingbourne2021-11-051-0/+28
|/ | | | Change-Id: Ib9860b282cf749891e0f6ef7697669b94235c236
* Update for new TRAP_PERF value.Christopher Ferris2021-07-011-1/+3
| | | | | | | | For the new kernel 5.13 heders, there is a new TRAP_PERF value that needs to be handled. Test: Builds. Change-Id: I2c6658ca94423c210db9ad6692ec69f6be69b3f5
* Support MTE and GWP-ASan features in proto tombstones.Peter Collingbourne2021-03-161-32/+30
| | | | | | | | | | | | | Proto tombstones were missing tagged fault addresses, tagged_addr_ctrl, tags in memory dumps and Scudo and GWP-ASan error reports. Since text tombstones now go via protos, all of these features broke when we switched to text tombstones generated from protos by default. Fix the features by adding support for them to the proto format, tombstone_proto and tombstone_proto_to_text. Bug: 135772972 Bug: 182489365 Change-Id: I3ca854546c38755b1f6410a1f6198a44d25ed1c5
* Update for new kernel 5.11 headers.Christopher Ferris2021-02-181-1/+3
| | | | | | | Add new SYS_USER_DISPATCH to SIGSYS case. Test: Builds, unit tests pass. Change-Id: Id470053c167d7ffe51d622356c867815cd773fbc
* Remove use of libbase logging in libdebuggerd.Josh Gao2021-01-271-3/+3
| | | | | | | | | libbase logging uses getprogname() to get the default tag, which breaks for the fallback handler which is statically linked into the dynamic linker. Switch to libasync_safe for logging. Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls Change-Id: Ieeaf33fb26cff4ba7e1589d1d883ac2fcc74cf47
* Reland protobuf tombstones.Josh Gao2021-01-261-21/+33
| | | | | | | | | | | | | This reverts the following commits: e156ede145a7fc671c705d045d89b49922a758b5. eda96eddcbdda9632166232b2363c7b84da0994d. 5ec54d1e843729cd1e38a2f791f001226a653e95. 1e45d3f2239333217d3252f78151f4294fda4e80. a50f61f8fa903117a6df82d164628de310f16ae9. Test: treehugger Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls Change-Id: Ic2b1f489ac9f1fec7d7a33c845c29891f4306bbd
* Revert "libdebuggerd: add protobuf implementation."Jerome Gaillard2021-01-261-33/+21
| | | | | | | | | | | | | | | | | | Revert "Let crash_dump read /proc/$PID." Revert submission 1556807-tombstone_proto Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug Reverted Changes: Ide6811297:tombstoned: switch from goto to RAII. I8d285c4b4:tombstoned: make it easier to add more types of ou... Id0f0fa285:tombstoned: support for protobuf fds. I6be6082ab:Let crash_dump read /proc/$PID. Id812ca390:Make protobuf vendor_ramdisk_available. Ieeece6e6d:libdebuggerd: add protobuf implementation. Change-Id: Ia0a1ee57e7630e01c495dc166218f665340aad7f
* libdebuggerd: add protobuf implementation.Josh Gao2021-01-211-21/+33
| | | | | | | | | | | | | | This commit implements protobuf output for tombstones, along with a translator that should emit bytewise identical output to the existing tombstone dumping code, except for ancillary data from GWP-ASan and Scudo, which haven't been implemented yet. Test: setprop debug.debuggerd.translate.translate_proto_to_text 1 && /data/nativetest64/debuggerd_test/debuggerd_test Test: for TOMBSTONE in /data/tombstones/tombstone_??; do pbtombstone $TOMBSTONE.pb | diff $TOMBSTONE - done Change-Id: Ieeece6e6d1c26eb608b00ec24e2e725e161c8c92
* Remove ANDROID_EXPERIMENTAL_MTE.Peter Collingbourne2021-01-111-1/+0
| | | | | | | | Now that the feature guarded by this flag has landed in Linux 5.10 we no longer need the flag, so we can remove it. Bug: 135772972 Change-Id: I02fa50848cbd0486c23c8a229bb8f1ab5dd5a56f
* Update for v5.10 kernel headers.Christopher Ferris2020-12-141-3/+1
| | | | | Test: Builds. Change-Id: I6c4b04751df026ef7cbb91627174188c5e6d137c
* Switch to the new kernel API for obtaining fault address tag bits.Peter Collingbourne2020-11-131-37/+0
| | | | | | | | | | | | | | | | The discussion on LKML is converging on v16 of the fault address tag bits patch [1]. In this version of the patch the presence of the tag bits in si_addr is controlled by a sa_flags bit, and a protocol is introduced to allow userspace to detect kernel support for sa_flags bits. Update the tombstone signal handler to use this API to read the tag bits, update the interceptors in libsigchain to implement the flag support detection protocol and hide the tag bits in si_addr from chained signal handlers that did not request them to match the kernel behavior. [1] https://lore.kernel.org/linux-arm-kernel/cover.1605235762.git.pcc@google.com/ Change-Id: I57f24c07c01ceb3e5b81cfc15edf559ef7dfc740
* Update language to comply with Android's inclusive language guidanceJeff Sharkey2020-07-311-1/+0
| | | | | | | See https://source.android.com/setup/contribute/respectful-code for reference Bug: 161896447 Change-Id: Iafcccbdbdf3ff1078e87000e2ce560ff09b43f68
* Merge "debuggerd: use One True timestamp function."Elliott Hughes2020-07-241-17/+0
|\
| * debuggerd: use One True timestamp function.Elliott Hughes2020-07-231-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An OEM asks for sub-second granularity, and that's most easily done if we only have one timestamp generator. I'm not convinced sub-second granularity is particularly useful myself, and I definitely don't think that nanosecond resolution is meaningful but I do like this cleanup, and if I'm going to use sub-second precision I may as well use the maximum precision available to me. Also reduce some duplication of code reading cmdline/comm. Bug: https://issuetracker.google.com/161860597 Test: head /data/tombstones/* Change-Id: I035ecfd4a3338ccd84dae0ef973a998a7c7c5056
* | Include memory tags in memory dump output.Peter Collingbourne2020-07-211-3/+9
| | | | | | | | | | | | | | | | | | | | Tags appear in the addresses printed in the memory dump, which seems like a reasonable place to put them because tagged addresses will also appear in other places in the tombstone, such as registers and the fault address. Bug: 135772972 Change-Id: I52da338347ff6b7503cf5ac80763c540695dc061
* | Adjust conditions for dumping the memory around a register.Peter Collingbourne2020-07-211-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix dumping of heap memory.Peter Collingbourne2020-07-171-0/+4
|/ | | | | | | | | | After r.android.com/1288984 we started failing to dump memory contents for heap addresses because the tag started causing any addresses to fail this bounds check. Add an untag_address() call to the bounds check so that the tag is ignored. Bug: 154272452 Change-Id: I3a6d1a078b21871bd93164150a123549f83289f6
* Add support for MTE error reports in tombstones.Peter Collingbourne2020-04-271-0/+7
| | | | | | | | | Teach debuggerd to use the new scudo APIs proposed in https://reviews.llvm.org/D77283 for extracing MTE error reports from crashed processes, and include those reports in tombstones if possible. Bug: 135772972 Change-Id: I082dfd0ac9d781cfed2b8c34cc73562614bb0dbb
* Read fault address on arm64 using proposed kernel API.Peter Collingbourne2020-03-271-0/+37
| | | | | | | | | | | | | | | | 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: switch to using platform headers for DEBUGGER_SIGNAL.Josh Gao2019-12-171-1/+3
| | | | | Test: treehugger Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
* Add variadic logging to libdebuggerd internal.Mitch Phillips2019-11-191-3/+8
| | | | | | | | | | | | | | GWP-ASan's crash information retrieval services requires a Printf() function (declared by the system/implementing allocator). In this instance, because _LOG is called with additional arguments (the log_t), this function must be wrapped to conform to printf_t defined by GWP-ASan. We can easily wrap the variadic version. Bug: 135634846 Test: atest debuggerd_test Change-Id: I17209cd2b7455ce889e2f8194969f606cac329eb
* Add indicator that an elf is memory backed.Christopher Ferris2019-04-181-0/+20
| | | | | | | | | | | | | | | | Modify the unwinder library to indicate that at least one of the stack frames contains an elf file that is unreadable. Modify debuggerd to display a note about the unreadable frame and a possible way to fix it. Bug: 129769339 Test: New unit tests pass. Test: Ran an app that crashes and has an unreadable file and verified the Test: message is displayed. Then setenforce 0 and verify the message is Test: not displayed. Change-Id: Ibc4fe1d117e9b5840290454e90914ddc698d3cc2
* Remove include of backtrace/Backtrace.h.Christopher Ferris2019-04-081-1/+0
| | | | | | | | | | | | Somehow the code was still including this include from libbacktrace. I think the libbacktrace include directory was coming from some transitive includes. I verified that nothing in debuggerd is using the libbacktace.so shared library. Bug: 120606663 Test: Builds, unit tests pass. Change-Id: I85c2837c5a539ccefc5a7140949988058d21697a
* Update for v4.19 kernel headers.Christopher Ferris2018-10-301-1/+3
| | | | | | | | Add new trap type TRAP_UNK. Test: Unit tests pass. Change-Id: I2b9cb8ddd1d993aa4819831aaca34f8da4286b52 (cherry picked from commit ead88bc88e567182b3c6ae5fd2f17730f55ec3f3)
* Add support for new defines in v4.17.3 headers.Christopher Ferris2018-06-291-17/+29
| | | | | Test: Builds and unit tests pass. Change-Id: Ibd5711effb1e599d3239d45124383fe91e0f573d
* Show signal sender for SI_FROMUSER signals.Elliott Hughes2018-04-261-16/+24
| | | | | | | | | | | | | | | Suicide doesn't change: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- But homicide now looks like this (this is `sleep 666` killed by `kill -SEGV` as root: signal 11 (SIGSEGV), code 0 (SI_USER from pid 4446, uid 0), fault addr -------- Bug: http://b/78594105 Test: manual Change-Id: I8c2feafba8cc5a3db85e8250004d428a464c5d9e
* debuggerd: remove maximum abort message length.Josh Gao2018-04-131-12/+9
| | | | | | | | Let the logging implementation be the imposer of limits. Bug: http://b/64759619 Test: debuggerd_test Change-Id: I8bc73bf2301ce071668993b740880224846a4e75
* Include the map name when dumping memory around a register.Elliott Hughes2018-02-151-8/+2
| | | | | | Bug: http://b/19590178 Test: ran tests, ran crasher Change-Id: Ib9afa34c860d8732ef1943eb4decd0b7c8fb55fd
* Change all uintptr_t to uint64_t in API.Christopher Ferris2018-01-181-3/+3
| | | | | | | | | | | | | | | | | In order to support the offline unwinding properly, get rid of the usage of non-fixed type uintptr_t from all API calls. In addition, completely remove the old local and remote unwinding code that used libunwind. The next step will be to move the offline unwinding to the new unwinder. Bug: 65682279 Test: Ran unit tests for libbacktrace/debuggerd. Test: Ran debuggerd -b on a few arm and arm64 processes. Test: Ran crasher and crasher64 and verified tombstones look correct. Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
* crash_dump: fork a copy of the target's address space.Josh Gao2017-12-151-28/+174
| | | | | | | | | | | | | | Reduce the amount of time that a process remains paused by pausing its threads, fetching their registers, and then performing unwinding on a copy of its address space. This also works around a kernel change that's in 4.9 that prevents ptrace from reading memory of processes that we don't have immediate permissions to ptrace (even if we previously ptraced them). Bug: http://b/62112103 Bug: http://b/63989615 Test: treehugger Change-Id: I7b9cc5dd8f54a354bc61f1bda0d2b7a8a55733c4
* libdebuggerd: cleanup.Josh Gao2017-08-291-1/+1
| | | | | | | | | Move libdebuggerd headers into their own directory for namespacing, move some includes to the top of their implementing files, delete some dead code. Test: mma, treehugger Change-Id: Ie4c44e32e2ab3bc678092899d257fd4ed634aa34
* crash_dump: during early boot, output to kmsg on userdebug.Josh Gao2017-04-061-1/+45
| | | | | | | | | | | | | | | Crashes that happen before tombstoned is running are extremely hard to diagnose, because tombstones aren't written to disk, and the window of opportunity to get logs via `adb logcat` is small (potentially nonexistent). Solve this by adding a world-writable /dev/kmsg_debug on userdebug builds, and writing to it in addition to logcat when tombstoned hasn't started yet. Bug: http://b/36574794 Test: stop tombstoned; crasher; dmesg Change-Id: Ib22c02a002afb602933155fb2c9b7a8abbe9ed38
* crash_dump: fetch process/thread names before dropping privileges.Josh Gao2017-03-151-0/+18
| | | | | | | | | | | | Processes that don't have dumpable set to 1 cannot have their process/thread names read by processes that don't have all of their capabilities. Fetch these names in crash_dump before dropping privileges. Bug: http://b/36237221 Test: debuggerd_test Test: debuggerd -b `pidof android.hardware.bluetooth@1.0-service` Change-Id: I174769e7b3c1ea9f11f9c8cbdff83028a4225783
* Define _LOG as a weak symbol.Chenjie Luo2017-03-061-0/+1
| | | | | | | | | So _LOG could be overridden by customized logging implementations in non-Android systems. Bug: 35919515 Test: Test on device Change-Id: I0885c15353c0b1bf66f6f156e7f502f326b85d57
* debuggerd: advance our amazing bet.Josh Gao2017-01-171-0/+203
Remove debuggerd in favor of a helper process that gets execed by crashing processes. Bug: http://b/30705528 Test: debuggerd_test Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906