Commit graph

490 commits

Author SHA1 Message Date
Josh Gao
7d199de8e2 Merge changes I0ff1fc5c,I7a23d3bf
* changes:
  libdebuggerd: print the build fingerprint in fallback.
  libdebuggerd: implement fallback register dumping on arm/aarch64.
2017-05-10 23:24:38 +00:00
Chenjie Luo
68c24eff77 Remove not-used dependency in crash_dump
Test: Build crash_dump.
Change-Id: I053cf53196b3e438545138ca8401a0ad01006a8c
2017-05-08 15:18:40 -07:00
Josh Gao
2bc6196faa Merge "debuggerd_handler: use syscall(__NR_get[pt]id) instead of get[pt]id." 2017-05-08 20:18:34 +00:00
Josh Gao
62f5977d4a libdebuggerd: print the build fingerprint in fallback.
Bug: http://b/37798209
Test: killall -ABRT media.codec on internal
Change-Id: I0ff1fc5ca1e0bcec2c1b2553d6af7099deebfeda
2017-05-08 13:15:19 -07:00
Josh Gao
77b00ed429 libdebuggerd: implement fallback register dumping on arm/aarch64.
Bug: http://b/35439781
Test: killall -ABRT media.codec on internal
Change-Id: I7a23d3bfcf07ad584e677b2ef5fff28436ef0972
2017-05-08 13:15:19 -07:00
Dan Willemsen
a4103a85b6 Turn off debuggerd for host bionic
Bug: 31559095
Test: Attempt to build host bionic
Change-Id: Ie0b30417bdc2c59fd4793a79fd23dc9ccd398937
2017-05-07 13:22:01 -07:00
Josh Gao
2e7b8e2d1a debuggerd_handler: use syscall(__NR_get[pt]id) instead of get[pt]id.
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-05 14:58:12 -07:00
Christopher Ferris
ac225780dd Move libc_logging to libasync_safe.
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-05-02 18:38:46 -07:00
Josh Gao
e06f2a4886 debuggerd_handler: don't assume that abort message implies fatal.
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-04-27 17:28:05 -07:00
Josh Gao
72ca48e5cb Merge "crash_dump: during early boot, output to kmsg on userdebug." 2017-04-10 20:51:59 +00:00
Josh Gao
bf2dd48241 crash_dump: during early boot, output to kmsg on userdebug.
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
2017-04-06 15:00:52 -07:00
Liu Changcheng
3492221fcf check send_signal result before further dealing
If send_signal failed, debuggerd_trigger_dump should return
instead of further dealing

Change-Id: I0a1ac4255344d1da7a21917ad559b9de4d5a4fee
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Signed-off-by: Jerry Liu <primerlink@gmail.com>
2017-04-06 22:47:00 +08:00
Josh Gao
8b951f5adc Merge changes Ib8369088,I743433bc
* changes:
  debuggerd_test: remove useless pipe.
  debuggerd_client: fix infinite timeouts.
2017-04-05 04:20:14 +00:00
Josh Gao
951cf70071 debuggerd_test: remove useless pipe.
Bug: http://b/36897117
Test: none
Change-Id: Ib8369088153fe44de2af9037299bdfce7b709b98
2017-04-04 14:09:04 -07:00
Josh Gao
287d50dc59 debuggerd_client: fix infinite timeouts.
Bug: http://b/36897117
Test: debuggerd_test
Test: debuggerd -b `pidof zygote`
Change-Id: I743433bc420b1c433b82ef62795abb6ea9f5d840
2017-04-04 14:08:54 -07:00
Josh Gao
a5199a9e43 debuggerd_test: add test for process/thread names.
Make sure that we can get the process/thread names for nondumpable
processes with capabilities.

Bug: http://b/36237221
Test: /data/nativetest/debuggerd_test/debuggerd_test32
Change-Id: Iedd4eae18065c2e64abeebff15e3b9b09a630550
2017-04-03 13:18:34 -07:00
Josh Gao
352a84574d tombstoned: add tests for b/36685795.
Add some tests for edge cases which may have triggered b/36685795.

Bug: http://b/36685795
Test: debuggerd_test
Change-Id: I20670684c8dae422af157be21e44ba5d6d3214d3
2017-03-30 16:49:19 -07:00
Josh Gao
460b336d6a tombstoned: fix a race between intercept and crash_dump.
Previously, there was no way to detect when tombstoned processed an
intercept request packet, making it possible for a intercept request
followed by a crash_dump being processed in the wrong order.

Add a response to intercept registration, to eliminate this race.

Test: debuggerd_test
Change-Id: If38c6d14081ebc86ff1ed0edd7afaeafc40a8381
2017-03-30 16:49:02 -07:00
Josh Gao
807a45807b tombstoned: refactor request dequeuing a bit.
Also make it loop, so that upon failing to start a dequeued crash
request, we continue to the next one.

Bug: http://b/36685795
Test: debuggerd_test
Change-Id: I94889125f16f4681c6fa0fa9cac456302602ce01
2017-03-30 16:19:53 -07:00
Josh Gao
13078245a0 tombstoned: don't increment num_concurrent_dumps until success.
Previously, we would increment num_concurrent_dumps and fail to
decrement it if we failed to start the request. Change this to
only increment after we've successfully started the dump.

Bug: http://b/36685795
Test: debuggerd_test
Change-Id: I66169ed56ed44271e1d8fe1298d95260be7a32a3
2017-03-30 14:51:38 -07:00
Treehugger Robot
372d8a2931 Merge "debuggerd_client: properly wait for completion." 2017-03-28 03:21:39 +00:00
Josh Gao
ae9d7676a5 debuggerd_client: properly wait for completion.
Use an intermediate pipe to detect and report when a requested dump has
completed.

Bug: http://b/35241370
Bug: http://b/35813071
Test: debuggerd_test
Test: manually triggered a background ANR
Change-Id: If14aedf6071288360f1a7853d5a2ee79db121759
2017-03-27 16:11:38 -07:00
Elliott Hughes
f5d727f221 Merge ""Requested dump for tid XXX" message shouldn't be fatal." 2017-03-24 23:29:23 +00:00
Elliott Hughes
561da6aa82 "Requested dump for tid XXX" message shouldn't be fatal.
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-23 23:04:27 -07:00
Christopher Ferris
9642232f13 Initialize si_code in siginfo.
There was at least one failure due to si_code being unitialized
and then examined.

Test: Run the 32 bit and 64 bit version of the unit tests on angler.
Change-Id: I5455a2cd29afafcd26a49f696e61141bb48478dc
2017-03-22 18:06:57 -07:00
Christopher Ferris
f5e568e653 Do not access device maps.
It's possible that a device map has memory controlled by a single entry
device driver. Thus, you can deadlock if a process is touching that
device memory and we try to unwind it and also touch that device memory.
Simply skip any attempts to step through, or get function names from
device memory maps.

Bug: 36130325

Test: Ran new unit tests, ran bionic unit tests, ran art ThreadStress.
Change-Id: Ibc62d7ec8106c619ee08968f05e04aea55d7cbfa
2017-03-22 14:55:05 -07:00
Josh Gao
7390d96ff2 Merge "crash_dump: fetch process/thread names before dropping privileges." 2017-03-16 17:45:18 +00:00
Josh Gao
57f58f8e4a crash_dump: fetch process/thread names before dropping privileges.
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
2017-03-15 23:30:14 -07:00
Dan Willemsen
e0cd1e043d Enable more modules on linux_bionic builds
Bug: 31559095
Test: Enable host bionic, run soong
Change-Id: Ib4ebd909322cf464b6a40040e4b60ece7d905b6f
2017-03-15 15:44:00 -07:00
Tom Cherry
5b4eb23cfd Remove extraneous .clang-format files
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format.  Therefore, let's reduce the
differences and use only the two top level clang-format files.

Secondly perform some small clean-up of the top level .clang-format
files.  AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed.  AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.

The diff stats for these changes are:

./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)

./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)

./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)

./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)

./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)

./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)

Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
2017-03-14 14:06:31 -07:00
Josh Gao
c7fe0600cc crash_dump: fix warnings, turn on -Werror.
Test: mma
Change-Id: I0722fef7b513be976cbbe89f73e8bb7138a80442
2017-03-13 14:13:29 -07:00
Josh Gao
428daafc5b crash_dump: improve logging for when a process dies prematurely.
If a process that's getting dumped dies before crash_dump starts (e.g.
because seccomp immediately kills it after it execs crash_dump),
improve the error message to not just say "target died before we could
attach".

Bug: http://b/36077710
Test: inserted an exit in the handler, inspected output
Change-Id: I7d394c66d60d328b096b15654b3648e1ed711728
2017-03-10 14:52:34 -08:00
Josh Gao
ec91809dae debuggerd_handler: restore errno.
Bug: http://b/31448909
Test: mma
Change-Id: I737d66e8bed5fb31c2558f68608d3df460fa73c9
2017-03-10 14:44:54 -08:00
Josh Gao
9eb4eb1811 libdebuggerd: add compatibility shim.
Avoid breaking internal code when AOSP automerges to internal.

This will be reverted after fixing up the uses on the other end.

Bug: http://b/35858739
Test: treehugger
Change-Id: If1ee03d8d7c218d3ad9f451cfe9a9077753dda02
2017-03-09 12:13:16 -08:00
Josh Gao
e1aa0ca58a debuggerd_handler: implement missing fallback functionality.
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-03-09 11:26:05 -08:00
Chenjie Luo
97258aad8a Define _LOG as a weak symbol.
So _LOG could be overridden by customized logging
implementations in non-Android systems.

Bug: 35919515
Test: Test on device
Change-Id: I0885c15353c0b1bf66f6f156e7f502f326b85d57
2017-03-06 15:04:32 -08:00
Treehugger Robot
56e89ade33 Merge changes Ib69a206f,If57cc175
* changes:
  tombstoned: turn off signal handlers.
  tombstoned: create tombstones with 0640 permissions.
2017-03-06 22:26:17 +00:00
Josh Gao
55f79a5953 tombstoned: turn off signal handlers.
Don't try to connect to ourselves in a signal handler (e.g. if someone
does `killall -ABRT tombstoned`).

Test: killall -ABRT tombstoned
Change-Id: Ib69a206f741acb523c9f2883d474c940b6ebfab2
2017-03-06 12:30:25 -08:00
Josh Gao
8830c95def tombstoned: create tombstones with 0640 permissions.
Make tombstones group readable to allow them to be picked up by the
dropbox service.

Bug: http://b/35979630
Test: killall -ABRT rild; dumpsys dropbox
Change-Id: If57cc17563c80d5b5c4887b0937905bffef6b231
2017-03-06 12:30:25 -08:00
Elliott Hughes
12b7129406 Small debuggerd improvements.
Include the ABI in seccomp causes.

Slightly improved command-line usage information.

Fix crasher for seccomp failures.

Bug: N/A
Test: crasher
Change-Id: Ie419ecfe72ee4f5ccf49c927be18350a58a66a90
2017-03-02 19:01:20 -08:00
Josh Gao
b038995d29 Merge "debuggerd: remove obsolete dumpable check." 2017-03-01 22:59:01 +00:00
Josh Gao
981761bbb2 debuggerd: remove obsolete dumpable check.
PR_SET_DUMPABLE is ignored now.

Bug: http://b/35872161
Test: debuggerd -b `pidof surfaceflinger`
Change-Id: Iefd090f2b762d454d1e6ce8061ff5f992974267c
2017-03-01 11:55:16 -08:00
Elliott Hughes
b7788fd454 There's no longer a limit to property names.
Bug: http://b/33926793
Test: boots
Change-Id: I8554d7af74e064c114cf817f5a2ba1247fa2a2db
2017-02-28 14:12:54 -08:00
Treehugger Robot
94aabe47db Merge "debuggerd_test: add capability test." 2017-02-17 21:20:11 +00:00
Josh Gao
502cfd22ba debuggerd_test: add capability test.
Also, remove the dependency on crasher.

Bug: http://b/35100921
Bug: http://b/35241370
Test: /data/nativetest/debuggerd_test/debuggerd_test32
Test: /data/nativetest64/debuggerd_test/debuggerd_test64
Change-Id: I318f6de764d435251417953bf175ba321b59981f
2017-02-17 11:22:21 -08:00
Elliott Hughes
da9e3958d6 Add crasher check for passing a bad pthread_t to pthread_join.
Bug: http://b/35455349
Test: manual
Change-Id: If09454c7104a1e6de7c0edb50ee52118b7ca5eaa
2017-02-17 10:26:48 -08:00
Josh Gao
5ad965bf41 crash_dump: fix overflow.
`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-16 20:16:58 -08:00
Josh Gao
2a18b822d5 crash_dump: remove unneeded/faulty checks.
We already check our /proc/`getppid()` fd every time we attach a thread, so
these were unneeded at best. The one that happened after dropping
capabilities was actively wrong, though, because /proc/pid access
checks happen on every operation. (only on some kernels?)

Also, add a check that getppid() doesn't change after opening
/proc/getppid().

Bug: http://b/35241370
Test: debuggerd -b `pidof com.android.bluetooth`
Change-Id: I807439d8c2afd027f3c382face50167a8a7946c4
2017-02-16 19:26:09 -08:00
Josh Gao
c7cd48af58 Merge "libdebuggerd_handler: in-process crash dumping for seccomped processes." 2017-02-16 23:11:52 +00:00
Josh Gao
a70f11331f Merge "crash_dump: make output fd O_APPEND." 2017-02-16 22:43:59 +00:00