Commit graph

13 commits

Author SHA1 Message Date
Josh Gao
347164cc59 crash_dump: read /proc/<pid>/maps before dropping capabilities.
Reading /proc/<pid>/maps does a ptrace_may_access check, which will
fail if we have fewer capabilities than the target, even if we've
already ptraced it.

Bug: http://b/35070339
Test: debuggerd -b `pidof zygote`
Change-Id: I984a061022bd945a7950b88f6d579e1bd735e893
2017-02-07 12:35:51 -08:00
Josh Gao
85bcaf68d3 crash_dump: drop capabilities after we ptrace attach.
Bug: http://b/34853272
Test: debuggerd -b `pidof system_server`
Test: debuggerd -b `pidof zygote`
Change-Id: Ic1e1a4b0eb1f561621800cd4cc9a5b848fc5ffd8
2017-02-02 13:54:38 -08:00
Josh Gao
fe90276aee crash_dump: use /proc/<pid> fd to check tid process membership.
Bug: http://b/34759490
Test: /data/nativetest/debuggerd_test/debuggerd_test32
Test: debuggerd -b `pidof system_server`
Test: debuggerd -b `pidof zygote`
Change-Id: I627692b44977335a9568cd765ad28205f0a61327
2017-02-02 13:54:38 -08:00
Josh Gao
b53f903cf1 debuggerd: fix debuggerd -b <pid>
Dump all of the threads when using `debuggerd -b`.

Bug: http://b/34719257
Test: `debuggerd -b mediaserver`
Change-Id: I2f57100985e5b0c2bf019482ba9feff31921692f
2017-01-30 17:58:04 -08:00
Josh Gao
0a37901b9f crash_dump: properly dump when we can't talk to tombstoned.
Bug: http://b/32466479
Test: stop tombstoned; logcat -c; crasher; logcat
Change-Id: I16c010cc1865b4e1db8d2b85c904a2e074f28f1f
2017-01-24 15:22:43 -08:00
Vijay Venkatraman
5fe1cebe7c Merge "Replaced include log/logger.h with log/log.h in debuggerd" 2017-01-24 19:07:30 +00:00
Vijay Venkatraman
a95acea5bf Replaced include log/logger.h with log/log.h in debuggerd
Test: Compile debuggerd
Change-Id: I33d12708993bd6818907b8cbb0a7a40672ad320d
2017-01-23 20:11:51 -08:00
Josh Gao
7c6e3133f5 crash_dump: set a watchdog timer.
PTRACE_DETACH is only necessary if the process is in group-stop state,
the tracer exiting is sufficient to detach and resume tracees.

Using this, set a 5 second timer with alarm(2) that just kills us, to
avoid leaving processes stopped.

Bug: http://b/34472671
Test: debuggerd_test
Test: crasher + manually inserting a 10 second sleep into crash_dump
Change-Id: Iacaa796f79037aa1585f3f2159abe45ef0069311
2017-01-23 11:39:31 -08:00
Josh Gao
122479f4a0 crash_dump: switch to PTRACE_SEIZE.
ptrace(PTRACE_ATTACH) does not immediately put the traced process in a
stopped state. If we manage to call PTRACE_CONT on it before it
finishes, we'll fail. Switch to using PTRACE_SEIZE and PTRACE_INTERRUPT
to guarantee that the target stops immediately.

This also has the advantage of never putting the process in group-stop
state, which means if we exit prematurely (e.g. if we crash during
stack unwinding), the target process will be resumed without any
intervention needed.

Bug: http://b/34472671
Test: while true; do debuggerd -b `pidof audioserver`; done
Change-Id: I7549f67489646cf300b8c9aa8c735e5e897806ef
2017-01-23 11:34:49 -08:00
Josh Gao
575941115e crash_dump: clear the default crash handlers.
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-23 11:34:49 -08:00
Josh Gao
d20d687de5 crash_dump: remove extra log.
We're already aborting via LOG(FATAL), there's no reason to log again.

Bug: none
Test: mma
Change-Id: I96cb09b716b19381d6a6931048827ef45f87170b
2017-01-23 11:34:49 -08:00
Josh Gao
42fd74bd1f crash_dump: don't abort if we fail to attach a sibling.
A TOCTOU race can occur between listing threads and attaching them.
Don't abort and leave the process in a stopped state when this happens.

Bug: http://b/34472671
Test: while true; do debuggerd -b `pidof audioserver`; done
Change-Id: Ib1632c3423fddf506b5c7874223c82fada78a85e
2017-01-20 12:55:07 -08:00
Josh Gao
cbe70cb0a8 debuggerd: advance our amazing bet.
Remove debuggerd in favor of a helper process that gets execed by
crashing processes.

Bug: http://b/30705528
Test: debuggerd_test
Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906
2017-01-17 13:57:57 -08:00