summaryrefslogtreecommitdiff
path: root/debuggerd/handler/debuggerd_handler.cpp
AgeCommit message (Collapse)Author
2021-03-29Merge SP1A.210329.001Scott Lobdell
Change-Id: I5658dcb0f7ed2ca7deb5eeb333981daaf76592ca
2021-03-17debuggerd: prepare to abandon ship^Wgdb.Elliott Hughes
Talk of "gdb" when we currently mean "gdb or lldb" and will soon mean "lldb" is starting to confuse people. Let's use the more neutral "debugger" in places where it really doesn't matter. The switch from gdbclient.py to lldbclient.py is a change for another day... Test: treehugger Change-Id: If39ca7e1cdf4c8bb9475f1791cdaf201fbea50e0
2021-02-08Merge SP1A.210208.001Daniel Norman
Change-Id: I16e0e3c65461673b714dd66a389670445608d017
2021-01-26Reland protobuf tombstones.Josh Gao
This reverts the following commits: e156ede145a7fc671c705d045d89b49922a758b5. eda96eddcbdda9632166232b2363c7b84da0994d. 5ec54d1e843729cd1e38a2f791f001226a653e95. 1e45d3f2239333217d3252f78151f4294fda4e80. a50f61f8fa903117a6df82d164628de310f16ae9. Test: treehugger Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls Change-Id: Ic2b1f489ac9f1fec7d7a33c845c29891f4306bbd
2021-01-26Merge SP1A.210122.003Scott Lobdell
Change-Id: Ife25f38176831b7e5595ab7a42c8690d88a12e77
2021-01-26Revert "libdebuggerd: add protobuf implementation."Jerome Gaillard
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
2021-01-25Merge changes from topic "tombstone_proto"Josh Gao
* changes: libdebuggerd: add protobuf implementation. tombstoned: support for protobuf fds. tombstoned: make it easier to add more types of outputs. tombstoned: switch from goto to RAII.
2021-01-21libdebuggerd: add protobuf implementation.Josh Gao
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
2021-01-19Remove unnecessary #includes.Elliott Hughes
Sadly, it looks like we do still really use libcutils for some of the socket functions. Test: treehugger Change-Id: Ic71f97507c89b10d2f3b7a2971064a9e6b1d349d
2020-11-30Merge SP1A.201130.001Daniel Norman
Change-Id: Ifcb754098c052feda32283cc056a9d760048832f
2020-11-13Switch to the new kernel API for obtaining fault address tag bits.Peter Collingbourne
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
2020-09-03Merge SP1A.200727.001Daniel Norman
Change-Id: I8f6750352c361cdc5b23825395234de12384ddd7
2020-04-10debuggerd: don't leave a zombie child if crash_dump is killed.Josh Gao
If crash_dump dies before it gets a chance to write to the pipe we use to let the debugged-process know that it successfully started, we weren't cleaning up the child we fork to start it, leaving a zombie child. Bug: http://b/152119184 Test: debuggerd_test Change-Id: Id01cc05f693995e9998941774f74ab8e3d8b4d8a
2020-03-30Merge "Read fault address on arm64 using proposed kernel API."Peter Collingbourne
2020-03-30Merge "Create a debugger_process_info data structure with the process info ↵Peter Collingbourne
pointers."
2020-03-27Read fault address on arm64 using proposed kernel API.Peter Collingbourne
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
2020-03-24Create a debugger_process_info data structure with the process info pointers.Peter Collingbourne
Similar to r.android.com/1247247 I'll be adding more of them for MTE. Also, change the protocol between the crasher and crash_dump to make it easier to add new fields and change the referenced data structures without needing to worry about versioning. The version number for static executables is now always 1 (where the protocol will never change), while the version number for dynamic executables is always 4 (where the protocol can change, because the linker and crash_dump are version locked). Bug: 135772972 Change-Id: Ib4696d0544d7c87cb429aaaa15f18c3640059e16
2020-03-18Move crash_dump into the runtime APEX.Peter Collingbourne
A future change will introduce a version lock between linker and crash_dump. Move crash_dump into the runtime APEX alongside linker in order to ensure that they will be the same version even if the runtime APEX is updated. Bug: 135772972 Change-Id: Ic2eae31b6927eb0e8a62315ac141f50933c00bcc Merged-In: Ic2eae31b6927eb0e8a62315ac141f50933c00bcc
2020-02-24Merge RP1A.200221.003Bill Peckham
Change-Id: I3c418d0dd1be8839a740194f461ad38e278f4343
2020-02-18[GWP-ASan] Add GWP-ASan information to tombstones.Mitch Phillips
GWP-ASan can provide information about a crash that it caused. Grab the GWP-ASan regions from the globals shared by the linker for crash-handler purpopses, pull the information from GWP-ASan, and display it. This adds two regions: 1. Causality tracking by GWP-ASan. We now print a cause header about the crash, like `Cause: [GWP-ASan]: Use After Free on a 1-byte allocation at 0x7365bb3ff8` 2. Allocation and deallocation stack traces. Bug: 135634846 Test: atest debuggerd_test Change-Id: Id28d5400c9a9a053fcde83a4788f971e677d4643
2020-01-23Merge RP1A.200123.001Steven Laver
Change-Id: I9a5261600a4bbae9e68b1e7ee554be2fd1c7525c
2020-01-17debuggerd_handler: increase thread stack size.Josh Gao
1 page isn't enough to log on AArch64, and clean pages are free, so increase the stack size to 8 pages. Bug: http://b/144887737 Test: treehugger Change-Id: I731b3bc27ab37f4b830a9478a04cd34d4f7648d3
2020-01-06Merge RP1A.200106.001Steven Laver
Change-Id: Iac92eee679219e76109967cf7d49914759313ccd
2019-12-17debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.Josh Gao
Test: treehugger Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
2019-11-05Merge RP1A.191024.001Steven Laver
Change-Id: Ia87bdd95c8f51e6fdb6ce86b473189bc073862bc
2019-10-10[debuggerd] fix -Wreorder-init-listNick Desaulniers
C++20 wants members to be ordered unlike C99. Bug: 139945549 Test: mm Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-05-02Merge QP1A.190501.001Scott Lobdell
Change-Id: I4400cfb92e362af46838594efd98e636c24189ca
2019-04-17debuggerd: call setsid in our children.Josh Gao
There appears to be a kernel bug that causes SIGHUP and SIGCONT to be sent to the parent process group we spawn from if the process group contains stopped jobs (e.g. the parent itself, because of wait_for_gdb). Call setsid in all of our children to prevent this from happening. Bug: http://b/31124563 Test: adb shell 'setprop debug.debuggerd.wait_for_gdb 1; killall -ABRT surfaceflinger' Change-Id: I1a48d70886880a5bfbe2deb80d48deece55faf09 (cherry picked from commit 18cb6812474e00050efab19e242c8a04ed470bec)
2019-04-16debuggerd: call setsid in our children.Josh Gao
There appears to be a kernel bug that causes SIGHUP and SIGCONT to be sent to the parent process group we spawn from if the process group contains stopped jobs (e.g. the parent itself, because of wait_for_gdb). Call setsid in all of our children to prevent this from happening. Bug: http://b/31124563 Test: adb shell 'setprop debug.debuggerd.wait_for_gdb 1; killall -ABRT surfaceflinger' Change-Id: I1a48d70886880a5bfbe2deb80d48deece55faf09
2019-03-26Merge QP1A.190324.001Scott Lobdell
Change-Id: Ib8e341b5da57c0db00a208d1a8323bef84e9124f
2019-03-18debuggerd_handler: demote abort on exec failure to log.Josh Gao
If a process is ptraced already, we might not be able to exec crash_dump due to selinux. Since we can be called for non-fatal events, we shouldn't abort in that case. Bug: http://b/128054996 Test: treehugger Change-Id: I1442041caa7af908df2ab87b9e010c44082e7587
2018-09-24Merge QP1A.180918.001Bill Peckham
Change-Id: I6e221d7a92b6ecb92bb8364757522d4906b86877
2018-09-12Fix multithreaded backtraces for seccomp processes.Josh Gao
Add threads to the existing seccomp backtrace test to prevent regressing this. Bug: http://b/114139908 Bug: http://b/115349586 Test: debuggerd_test32 Test: debuggerd_test64 Change-Id: I07fbe1619b60f0008deb045a249f9045404478c2
2018-08-31Merge QP1A.180823.001Bill Peckham
Change-Id: I43a054f155f100b3d7f414e17d3af9b900a05ab5
2018-08-27debuggerd_handler: receive abort messages via sigqueue(DEBUGGER_SIGNAL).Josh Gao
Make it possible for code such as fdsan that generates debugging tombstones via raise(DEBUGGER_SIGNAL) to pass an abort message as well. Bug: http://b/112770187 Test: debuggerd_test Change-Id: Idc34263241c18033573e466da3a45aa6f716ddb3
2018-08-06crash_dump: pass the address of the fdsan table.Josh Gao
Pass the address of the fdsan table down to crash_dump so that we can dump the fdsan table along with the open file descriptor list. Test: debuggerd_test Test: manually ran an old static_crasher Change-Id: Icbac5487109f2db1e1061c4d46de11b016b299e3
2018-08-02Merge QPR1.180718.001Jiyong Park
Conflicts: init/ueventd.cpp libion/ion.c lmkd/lmkd.c rootdir/init.rc Change-Id: I05419927e27be1148cd1a2665d51f9a715ab8d47
2018-07-18debuggerd_handler: use syscall(__NR_close) instead of close.Josh Gao
Avoid bionic's file descriptor ownership checks by calling the close syscall manually. Test: debuggerd_test Change-Id: I10af6aca0e66fe030fd7a53506ae61c87695641d
2018-04-26Show signal sender for SI_FROMUSER signals.Elliott Hughes
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
2018-01-18P PPR1.180114.001 merge 3926655cda1c63b97fd35c7d6f337504c1ec2741 - cleanBruce Levy
Change-Id: I72d227485017ef4a6003997524628c4c78be521d
2018-01-11P PPR1.171228.001 merge 29c39f6cac1f11c3f3d22c02ea779c3c2325e256 - cleanLalit Kansara
Change-Id: Ifcf64077e52f27cfa53b1da0e494db38abf1bb9f
2017-12-27debuggerd_handler: set PR_SET_PTRACER before running crash_dump.Luis Hector Chavez
Set and restore PR_SET_PTRACER when performing a dump, so that when Android is running on a kernel that has the Yama LSM enabled (and the value of ptrace_scope is > 0), crash_dump can attach to processes and print nice, symbolized stack traces. Bug: 70992745 Test: kill -6 `pidof surfaceflinger` && logcat -d -b crash # in both sailfish and Chrome OS Change-Id: If4646442c6000fdcc69cf4ab95fdc71ae74baaaf
2017-12-22debuggerd: wait for dump completion on crashes.Josh Gao
When a process crashes, both ActivityManager and init will try to kill its process group when they notice. The recent change to minimize the amount of time a process is paused results in crash dumps being killed before they finish as a result of this. Since anything that needs to be low-latency is probably not going to be too happy if it crashes, just wait for completion whenever we're processing a real crash. Bug: http://b/70343110 Test: debuggerd_test Change-Id: I894bb06efd264b1ba005df06f7326a72f4b767bb
2017-12-21Workaround to get full backtrace when userspace dies.Siddeswar Aluganti
Change-Id: I5f139a78558051b8b3a8887928cc7fe5df4df800
2017-12-15crash_dump: fork a copy of the target's address space.Josh Gao
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
2017-11-16Force call the fallback handler.Christopher Ferris
Always check to see if the fallback handler has been called and is not trying to dump a specific thread. Bug: 69110957 Test: Verified on a system where the prctl value changes, that before the Test: change it dumps multiple tombstones, and after the change it Test: works as expected. Test: Ran debuggerd unit tests. Test: Dumped process using debuggerd -b <PID> and debuggerd <PID>. Change-Id: Id98bbe96cced9335f7c3e17088bb4ab2ad2e7a64
2017-11-03crash_dump: don't inherit environment from parent.Josh Gao
Bug: http://b/68381717 Test: debuggerd_test Change-Id: Ie1b342bc9901cb9ae9b79147899928a19052cbad
2017-08-28base: add Pipe and Socketpair wrappers.Josh Gao
Also, switch debuggerd_handler over to using android::base::unique_fd. Test: treehugger Change-Id: I97b2ce22f1795ce1c4370f95d00d769846cc54b8
2017-08-11debuggerd_handler: print pid and process name.Josh Gao
Bug: http://b/64483618 Test: manual Change-Id: Ie772324895a8ffcd41d919a4a6113862a6468d12
2017-05-31tombstoned: allow intercepts for java traces.Narayan Kamath
All intercept requests and crash dump requests must now specify a dump_type, which can be one of kDebuggerdNativeBacktrace, kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have only one outstanding intercept registered at a time. There's only one non-trivial change in this changeset; and that is to crash_dump. We now pass the type of dump via a command line argument instead of inferring it from the (resent) signal, this allows us to connect to tombstoned before we wait for the signal as the protocol requires. Test: debuggerd_test Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37