summaryrefslogtreecommitdiff
path: root/debuggerd/handler
AgeCommit message (Collapse)Author
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-05-16debuggerd: fix CrasherTest.seccomp_crash_oom.Josh Gao
Switch from _exit to raising SIGABRT when we recurse in the fallback handler, so that waiters see an abort instead of a regular exit. Bug: http://b/79717060 Test: debuggerd_test32 Test: debuggerd_test64 Change-Id: Iddee1cb1b759690adf07bbb8cd0fda2faac87571
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-03-06PPR1.180227.001_AOSP_MergeDivya Sharma
Conflicts: libasyncio/Android.bp Change-Id: I1f783aea3d0a4231f35c34a772018a707e687625
2018-02-27PPR1.180219.001_AOSP_MergeDivya Sharma
Conflicts: libcutils/fs_config.cpp Change-Id: Ie0bc359025f12a79ce46e9b1eebe0980a1a86c40
2018-02-22debuggerd_fallback: don't recursively abort.Josh Gao
Calls to abort() will always result in our signal handler being called, because abort will manually unblock SIGABRT before raising it. This can lead to deadlock when handling address space exhaustion in the fallback handler. To fix this, switch our mutex to a recursive mutex, and manually keep track of our lock count. Bug: http://b/72929749 Test: debuggerd_test --gtest_filter="CrasherTest.seccomp_crash_oom" Change-Id: I609f263ce93550350b17757189326b627129d4a7
2018-02-09debuggerd_fallback: fix race.Josh Gao
A race condition occurs when one thread takes more than a second to get scheduled to handle the signal we send to ask it to dump its stack. When this happens, the main thread will continue on, close the fd, and then ask the next thread to dump, but the slow thread will then wake up and try to write to the new thread's fd, or trigger an assertion in __linker_enable_fallback_allocator. Do a few things to make this less bad: - encode both target tid and fd in the shared atomic, so that we know who each fd is for - switch __linker_enable_fallback_allocator to return success instead of aborting, and bail out if it's already in use - write to the output fd right when we get to it, instead of doing it whenever the dumping code decides to, to reduce the likelihood that the timeout expires Test: debuggerd_test Change-Id: Ife0f6dae388b601e7f991605f14d7a0274013f6b
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-29libdebuggerd: cleanup.Josh Gao
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
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
2017-05-22tombstoned: Add a shared library version of libtombstoned_client...Narayan Kamath
.. for ART and the frameworks to link against. In the new stack dumping scheme (see related bug), the Java runtime will communicate with tombstoned in order to obtain a FD to which it can write its traces. Also move things around to separate headers that are private implementation details from headers that constitute the public debuggerd API. There are currently only three such headers : - tombstoned/tombstoned.h - debuggerd/client.h - debuggerd/handler.h Bug: 32064548 Test: make Change-Id: If1b8578550e373d84828b180bbe585f1088d1aa3
2017-05-05debuggerd_handler: use syscall(__NR_get[pt]id) instead of get[pt]id.Josh Gao
bionic's cached values for getpid/gettid can be invalid if the crashing process manually invoked clone to create a thread or process, which will lead the crash_dump refusing to do anything, because it sees the actual values. Use the getpid/gettid syscalls directly to ensure correct values on this end. Bug: http://b/37769298 Test: debuggerd_test Change-Id: I0b1e652beb1a66e564a48b88ed7fa971d61c6ff9
2017-05-02Move libc_logging to libasync_safe.Christopher Ferris
Move the name of the "private/libc_logging.h" header to <async_safe/log.h>. For use of libc_malloc_debug_backtrace, remove the libc_logging library. The library now includes the async safe log functions. Remove the references to libc_logging.cpp in liblog, it isn't needed because the code is already protected by a check of the __ANDROID__ define. Test: Compiled and boot bullhead device. Test: Run debuggerd unit tests. Test: Run liblog unit tests on target and host. Test: Run libmemunreachable unit tests (these tests are flaky though). Change-Id: Ie79d7274febc31f210b610a2c4da958b5304e402
2017-04-27debuggerd_handler: don't assume that abort message implies fatal.Josh Gao
Applications can set abort messages via android_set_abort_message without actually aborting. This leads to following non-fatal dumps printing their output to logcat in the same format as a regular crash. Bug: http://b/37754992 Test: debuggerd_test Change-Id: I9c5e942984dfda36448860202b0ff1c2950bdd07
2017-03-23"Requested dump for tid XXX" message shouldn't be fatal.Elliott Hughes
This just means we were asked to dump, not that something necessarily went wrong. Bug: http://b/36191903 Test: builds Change-Id: I5638b38f3a13081b1e971512f43238010febb59c
2017-03-10debuggerd_handler: restore errno.Josh Gao
Bug: http://b/31448909 Test: mma Change-Id: I737d66e8bed5fb31c2558f68608d3df460fa73c9
2017-03-09debuggerd_handler: implement missing fallback functionality.Josh Gao
Allow the fallback implementation to dump traces and create tombstones in seccomped processes. Bug: http://b/35858739 Test: debuggerd -b `pidof media.codec`; killall -ABRT media.codec Change-Id: I381b283de39a66d8900f1c320d32497d6f2b4ec4
2017-02-16crash_dump: fix overflow.Josh Gao
`1 << 32` overflows, resulting in bogus PR_CAP_AMBIENT_RAISE attempts, and breaking dumping for processes with capabilities in the top 32 bits. Bug: http://b/35241370 Test: debuggerd -b `pidof com.android.bluetooth` Change-Id: I29c45a8bd36bdeb3492c9f74599993c139821088
2017-02-15libdebuggerd_handler: in-process crash dumping for seccomped processes.Josh Gao
Do an in-process unwind for processes that have PR_SET_NO_NEW_PRIVS enabled. Bug: http://b/34684590 Test: debuggerd_test, killall -ABRT media.codec Change-Id: I62562ec2c419d6643970100ab1cc0288982a1eed
2017-02-15debuggerd_handler: don't use snprintf in handler.Josh Gao
snprintf isn't safe to call in the linker after initialization, because it uses MB_CUR_MAX which is implemented via pthread_getspecific, which uses TLS slots shared with libc. If the TLS slots are assigned in a different order between libc.so and the linker, MB_CUR_MAX will evaluate to an incorrect value, and lead to snprintf doing bad things. Switch to __libc_format_buffer. Bug: http://b/35367169 Test: debuggerd -b `pidof zygote` Change-Id: I9d315cf63e5f3fd2f4545d6e3f707cdbe94ec606
2017-02-14debuggerd_handler: set PR_SET_DUMPABLE before running crash_dump.Josh Gao
Set and restore PR_SET_DUMPABLE when performing a dump, so that processes that have it implicitly cleared (e.g. services that acquire filesystem capabilities) still get crash dumps. Bug: http://b/35174939 Test: debuggerd -b `pidof surfaceflinger` Change-Id: Ife933c10086e546726dec12a7efa3f9cedfeea60
2017-02-14debuggerd_handler: raise capabilities before running crash_dump.Josh Gao
Raise CapInh and CapAmb after forking to exec crash_dump, so that it can ptrace us. Bug: http://b/35174939 Test: debuggerd -b `pidof surfaceflinger` Change-Id: I32567010a3603cfa494aae9dc0e3ce73fb86b590
2017-02-13debuggerd_handler: don't use waitpid(..., __WCLONE).Josh Gao
waitpid(..., __WCLONE) fails with ECHILD when passed an explicit PID to wait for. __WALL and __WCLONE don't seem to be necessary when waiting for a specific pid, so just pass 0 in the flags instead. Bug: http://b/35327712 Test: /data/nativetest/debuggerd_test/debuggerd_test32 --gtest_filter="*zombie*" Change-Id: I3dd7a1bdf7ff35fdfbf631429c089ef4e3172855
2017-02-06debuggerd_handler: fix prctl return value check.Josh Gao
Fixed this when I tested on internal, but failed to copy the fix over when submitting to AOSP. Bug: http://b/35070339 Test: `adb bugreport` on angler Change-Id: Ib84d212e5f890958cd21f5c018fbc6f368138d1e
2017-02-06Merge changes from topic 'debuggerd_ambient'Josh Gao
* changes: debuggerd_handler: don't use clone(..., SIGCHLD, ...) crash_dump: drop capabilities after we ptrace attach. crash_dump: use /proc/<pid> fd to check tid process membership. debuggerd_handler: raise ambient capset before execing. Revert "Give crash_dump CAP_SYS_PTRACE."
2017-02-02debuggerd_handler: don't use clone(..., SIGCHLD, ...)Josh Gao
Processes that handle SIGCHLD can race with the crash handler to wait on the crash_dump process. Use clone flags that cause the forked child's death to not be reported via SIGCHLD, and don't bail out of dumping when waitpid returns ECHILD (in case another thread is already in a waitpid(..., __WALL)) Note that the use of waitid was switched to waitpid, because waitid doesn't support __WCLONE until kernel version 4.7. Bug: none Test: "debuggerd -b `pidof zygote64`" a few times (failed roughly 50% of the time previously) Change-Id: Ia41a26a61f13c6f9aa85c4c2f88aef8d279d35ad
2017-02-02debuggerd_handler: raise ambient capset before execing.Josh Gao
Raise the ambient capability set to match CapEff so that crash_dump can inherit all of the capabilities of the dumped process to be able to ptrace. Note that selinux will prevent crash_dump from actually use any of the capabilities. Bug: http://b/34853272 Test: debuggerd -b `pidof system_server` Test: debuggerd -b `pidof zygote` Change-Id: I1fe69eff54c1c0a5b3ec63f6fa504b2681c47a88
2017-01-31debuggerd_handler: add and use fatal_errno.Josh Gao
Bug: none Test: mma Change-Id: I24d913abdbe74f9463feda78f7817ca8b92af9cc
2017-01-30debuggerd_handler: improve nonfatal signal message.Josh Gao
"Fatal signal 35 (???)" -> "Requested dump for" Bug: http://b/34809044 Test: debuggerd -b $$ Change-Id: I9ece0ee1117203d30142b843973ed7e5435e21da
2017-01-26debuggerd_handler: remove PR_SET_DUMPABLE check.Josh Gao
crash_dump has CAP_SYS_PTRACE and this was never obeyed by debuggerd. Change-Id: Ifee5e94b97b1f6440ad0be79758f0db2d2aaba2e
2017-01-25debuggerd_handler: don't dump PR_NO_NEW_PRIVS processes.Josh Gao
We can't do an selinux transition when this is on. Bug: http://b/34472671 Test: logcat -c; debuggerd `pidof media.codec`; logcat Change-Id: Ie6c1832ab838df48879c32a86126862de9a15420
2017-01-25debuggerd_handler: don't resend nonfatal signals when not dumping.Josh Gao
Bug: http://b/34516140 Test: debuggerd -b `pidof surfaceflinger` Change-Id: I0275ffca24bf4840e264eaa4b79611e2404edfb0
2017-01-23debuggerd_handler: properly crash when PR_GET_DUMPABLE is 0.Josh Gao
Actually exit when receiving a signal via kill(2) or raise(2) and PR_GET_DUMPABLE is 0. Bug: none Test: /data/nativetest/debuggerd_test/debuggerd_test32 Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter=pthread_DeathTest.pthread_mutex_lock_null_64 Change-Id: I833a2a34238129237bd9f953959ebda51d8d04d7
2017-01-23crash_dump: clear the default crash handlers.Josh Gao
crash_dump is a dynamic executable that gets the default crash dumping handlers set by the linker. Turn them off to prevent crash_dump from dumping itself. Bug: http://b/34472671 Test: inserted an abort into crash_dump Change-Id: Ic9d708805ad47afbb2a9ff37e2ca059f23f421de
2017-01-23debuggerd_handler: actually wait for pseudothread to exit.Josh Gao
Occasionally, the pseudothread wouldn't exit in time after unlocking the mutex to get crash_dump to proceed, resulting in spurious error messages. Instead of using a mutex to emulate pthread_join, just implement it correctly. Bug: http://b/34472671 Test: debuggerd_test Change-Id: I5c2658a84e9407ed8cc0ef2ad0fb648c388b7ad1
2017-01-17debuggerd: advance our amazing bet.Josh Gao
Remove debuggerd in favor of a helper process that gets execed by crashing processes. Bug: http://b/30705528 Test: debuggerd_test Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906