Commit graph

667 commits

Author SHA1 Message Date
Josh Gao
0915f23d5f debuggerd: diagnostics for dumps that are guaranteed to fail.
Print diagnostics when the user requests a dump that is guaranteed to
fail, such as trying to dump a process you can't send a signal to.

Bug: http://b/63008395
Change-Id: I5c6bf2a5751f858e0534990b8d2ab6932eb9f11d
Test: manually tested
2017-06-27 15:06:57 -07:00
Elliott Hughes
3e8d923276 Merge "Allow configuration of the number of tombstones." 2017-06-27 20:57:08 +00:00
Elliott Hughes
35bb6d2a89 Allow configuration of the number of tombstones.
Bug: http://b/62810514
Test: altered the property, got more tombstones
Change-Id: Iba8089915fa715658d2dfecb076c6a61321243bd
2017-06-26 14:00:00 -07:00
Narayan Kamath
111f351762 Merge "tombstoned: Improve message on java trace completion." 2017-06-23 08:12:51 +00:00
Andreas Gampe
b02851a984 Debuggerd: Extend crash_dump timeout to 5 seconds
Some processes have lots of threads and minidebug-info. Unwinding
these can take more than the original two seconds.

Bug: 62828735
Test: m
Test: debuggerd_test
Test: adb shell kill -s 6 `pid system_server`
Change-Id: I0041bd01753135ef9d86783a3c6a5cbca1c5bbad
2017-06-22 20:19:11 -07:00
Andreas Gampe
26cbafb892 Debuggerd: Fix debuggerd_test
Follow-up to commit 695713e931f0436aca56be9c0dacf2a5dd4e56e7 in
bionic. Change expectations of the abort callstack.

Test: mmma system/core/debuggerd
Test: adb shell /data/nativetest/debuggerd_test/debuggerd_test32
Test: adb shell /data/nativetest64/debuggerd_test/debuggerd_test64
Change-Id: I350a29ee1713a7ebdd50f2b9bdc2078c671e22c7
2017-06-22 20:19:11 -07:00
Jaesung Chung
1dcee84294 Merge "crash_dump: lower THREAD_COUNT in debuggerd_client.race for low-speed devices" 2017-06-23 01:59:28 +00:00
Jaesung Chung
cde2b524f1 crash_dump: lower THREAD_COUNT in debuggerd_client.race for low-speed devices
The debuggerd_client.race tests the crash_dump process to finalize the
killed process within 2 seconds. The 2 seconds timeout for finalizing a
process, which has 1024 threads, is bit small for low-speed devices.
This CL lowers the bar in order to make such devices pass the test.
Wraping up 128 threads within 2 seconds looks safe.

Bug: 62600479
Test: debuggerd_test passes on low-speed devices.
Change-Id: I3089415961422e6933405d2c872913273425caff
2017-06-23 08:59:22 +09:00
Narayan Kamath
79dd143e5f tombstoned: Improve message on java trace completion.
For java traces, log the kind of dump as well as the PID of the
completed dump. This makes it easier to correlate dump requests with the
actual file they're written to.

Sample log statement:
E /system/bin/tombstoned: Traces for pid 4737 written to: /data/anr/trace_00

The message for native traces / tombstones remains unchanged because
several tools parse it.

Test: manual
Bug: 32064548

Change-Id: I7b3792dd5ae312ee0bc055c22ec3f7c747152072
2017-06-22 11:04:33 +01:00
Narayan Kamath
07a57f0f28 Merge "tombstoned: change path for traces from "anr_" to "trace_"" 2017-06-22 08:30:42 +00:00
Narayan Kamath
b123220dd6 tombstoned: change path for traces from "anr_" to "trace_"
The only case where tombstoned creates files for java traces is
when the process is signalled "by hand" using "shell kill -3", or
by the program itself. Such traces do not correspond to an ANR, so
name those files "trace_XX".

When dumpstate / system_server want to dump java traces, they set up
a tombstoned intercept and manage the lifetime of any associated file
that themselves.

Bug: 32064548
Test: manual, debuggerd_test
Change-Id: I97006ec7c0cd35de4b9564f535e77af846cc3891
2017-06-21 18:00:09 +01:00
Elliott Hughes
336a52e00c Decode ptrace-induced SIGTRAP si_code values.
Example:

  signal 5 (SIGTRAP), code -32763 (PTRACE_EVENT_STOP), fault addr 0x274e00005fb3

I'm tempted to say that %d isn't the best choice for si_code, but as long as
we're fully decoding all the values, I don't think it matters.

Bug: http://b/62856172
Test: manual debuggerd run
Change-Id: Ieeca690828e1e12f4162bbadece53f4aa7b9537a
2017-06-21 08:45:33 -07:00
Jaesung Chung
58778e138e debuggerd_test: find backtrace frame in all lines in CrasherTest
Kernel can use vsyscall for system calls. The vsyscall implementation in
the kernel gives one more depth in the backtrace. It leads to failures
on CrasherTest. This CL makes tests find a system call frame not only in
the first line but also in all lines on the backtrace.

Bug: 62600694
Test: passes all CrasherTests.
Change-Id: Ice383bb94db097e7e9a9e4f74d8fa5ecc528122a
2017-06-16 19:16:50 +09:00
Josh Gao
550f3bf328 Merge "Revert "crash_dump: defer pausing threads until we're ready."" 2017-06-13 18:22:01 +00:00
Josh Gao
3407d7c80f Revert "crash_dump: defer pausing threads until we're ready."
This reverts commit 8a2a2d182a.

Bug: http://b/62572585
Change-Id: Ia4278bca52178eb7b7b28b30d0930b292d97f353
2017-06-13 17:21:12 +00:00
Treehugger Robot
87f5432f52 Merge "tombstoned: log where we're writing the tombstone." 2017-06-13 02:47:34 +00:00
Treehugger Robot
66e1a1e3e2 Merge changes Id7ab0464,Ic2a212be
* changes:
  crash_dump: defer pausing threads until we're ready.
  crash_dump: add tracing.
2017-06-12 23:08:24 +00:00
Josh Gao
cb68a0317d tombstoned: log where we're writing the tombstone.
Make it easy to find out where a specific crash's tombstone was written
to by adding a log.

Bug: http://b/62268830
Test: crasher
Change-Id: I1961dfb19f76a42a8448ebafd4be153b73cb6800
2017-06-12 21:00:59 +00:00
Josh Gao
8a2a2d182a crash_dump: defer pausing threads until we're ready.
Don't pause the threads we're going to dump until after we're about to
fetch their backtraces.

Bug: http://b/62112103
Test: debuggerd_test
Change-Id: Id7ab0464842b35f98f3b3ebc42fb76161d8afbd2
2017-06-07 14:11:28 -07:00
Josh Gao
8bb039073f crash_dump: add tracing.
Add some tracing to figure out where time is going during a dump.

Bug: http://b/62112103
Test: systrace.py sched freq idle bionic
Change-Id: Ic2a212beeb0bb0350b4d9c2cd7a4e70adc97752d
2017-06-07 14:11:06 -07:00
Narayan Kamath
ca5e908dd6 tombstoned: turn on java trace support + unit tests.
The SELinux changes that this depends on have now landed.

This change also adds a few lower level unit tests of intercept
functionality.

Test: make; debuggerd_test
Change-Id: I0be5e85e7097e26b71db269c9ed92d9b438bfb28
2017-06-07 18:57:54 +01:00
Josh Gao
5675f3c321 debuggerd_client: increase pipe buffer size to max.
If a process tries to dump itself (e.g. system_server during ANRs),
crash_dump will block trying to write to its pipe if it's not
sufficiently large. Increase the pipe size to the max, and add a test
to make sure that it's always at least 1MB (the default value).

Bug: http://b/38427757
Test: debuggerd_test
Change-Id: Iddb0cb1e5ce9e687efa9e94c2748a1edfe09f119
2017-06-01 12:42:44 -07:00
Josh Gao
b0e51e388b crash_dump: don't notify ActivityManager if it crashed.
Bug: http://b/38427757
Test: killall -ABRT system_server, plus added logging
Change-Id: Ic15e0b0870b1ec08a2f165ad0e5356afed02eece
2017-06-01 12:42:33 -07:00
Josh Gao
e740250b9d crash_dump: clear the signal mask.
crash_dump inherits its signal mask from the thread that forked it,
which always has all of its signals blocked, now that sigchain respects
sa_mask.

Manually clear the signal mask, and reduce the timeout to a
still-generous 2 seconds.

Bug: http://b/38427757
Test: manually inserted sleep in crash_dump
Change-Id: If1c9adb68777b71fb19d9b0f47d6998733ed8f52
2017-06-01 11:55:25 -07:00
Narayan Kamath
a73df601b7 tombstoned: allow intercepts for java traces.
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-31 10:35:32 +01:00
Narayan Kamath
2d377cd688 tombstoned: Add a shared library version of libtombstoned_client...
.. 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-22 16:55:21 +01:00
Narayan Kamath
922f6b22fc tombstoned: Support java trace dumps.
The changes here involve :
- Creating and opening a new socket to receive trace dump requests on. Having
  different sockets allows us to install different sets of access control rules.

- A minor refactor to allow us to share common pieces of implementation
  between the java and native dumping code. This will also allow us to
  add a unit test for all file / directory related logic.

There are two java trace specific additions here :
- We use SO_PEERCRED instead of trusting the PID written to the seocket
  because requests come in from untrusted processes.
- Java trace dumps are not interceptible.

kJavaTraceDumpsEnabled is set to false for now but the value of the flag
will be flipped in a future change.

Bug: 32064548
Test: Manual; Currently working on a unit_test for CrashType.

Change-Id: I1d62cc7a7035fd500c3e2b831704a2934d725e35
2017-05-18 12:01:14 +00:00
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
Josh Gao
e73c932373 libdebuggerd_handler: in-process crash dumping for seccomped processes.
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-15 17:03:44 -08:00
Josh Gao
f6ad5851e6 crash_dump: fix typos in error messages.
Bug: http://b/34760032
Bug: http://b/35367169
Test: mm
Change-Id: I45fa002d4ca616a41524583228987ab1197a125e
2017-02-15 17:03:30 -08:00
Josh Gao
8a7e703912 crash_dump: make output fd O_APPEND.
Bug: http://b/35209835
Test: mma
Change-Id: I447e3cfa3361f9c8b4b3335d0abccd1fe4c98e0f
2017-02-15 16:25:27 -08:00
Josh Gao
60515bf9f1 debuggerd_handler: don't use snprintf in handler.
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-15 12:24:09 -08:00
Josh Gao
2f11a25a48 debuggerd_handler: set PR_SET_DUMPABLE before running crash_dump.
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-14 21:19:38 -08:00
Josh Gao
d2069632bd debuggerd_handler: raise capabilities before running crash_dump.
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-14 14:40:47 -08:00
Josh Gao
91ad653c82 crasher: add a case that uses PR_SET_NO_NEW_PRIVS.
Bug: http://b/34684590
Test: crasher no_new_privs
Change-Id: I400d599116e3f3c27f5ea46d260e288cf900e156
2017-02-14 14:40:47 -08:00
Josh Gao
c3c8c029ec debuggerd_handler: don't use waitpid(..., __WCLONE).
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-13 17:01:24 -08:00
Josh Gao
c24cc8a9e5 crash_dump: collect open files before dropping caps.
/proc/<pid>/fd is also limited by ptrace_may_access.

Test: manual inspection of "debuggerd -b `pidof zygote`"
Change-Id: I1a28c21c0438fe8729bd8e041c6b418d6a84c586
2017-02-07 13:36:08 -08:00
Josh Gao
7a0ee64f9d debuggerd_test: improve error when crasher fails to exec.
Bug: http://b/35100742
Test: rm /system/bin/crasher && /data/nativetest/debugerd_test/debuggerd_test32
Change-Id: I02faec3b7f7ef62bb8a2ac2af730506e3d28e03e
2017-02-07 13:36:08 -08:00
Josh Gao
a7d7eb6d2a debuggerd_test: fix crasher path.
https://android-review.googlesource.com/#/c/331200 moved crasher to
using soong, which changed its location from /system/xbin/crasher to
/system/bin/crasher.

Bug: http://b/35100742
Test: /data/nativetest/debuggerd_test/debuggerd_test32
Test: /data/nativetest64/debuggerd_test/debuggerd_test64
Change-Id: I16a2050b257277023773cc0c960b5ab36e0c7cd4
2017-02-07 13:13:48 -08:00
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
54ef57d0b8 debuggerd_handler: fix prctl return value check.
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-06 21:10:48 -08:00
Josh Gao
279cb8b39a Merge changes from topic 'debuggerd_ambient'
* 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-06 18:37:55 +00:00
Josh Gao
b3ee52e4d0 debuggerd_handler: don't use clone(..., SIGCHLD, ...)
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-02 13:54:39 -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
7ae426c731 debuggerd_handler: raise ambient capset before execing.
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-02-02 13:54:38 -08:00
Elliott Hughes
f4ae6203a9 Merge "Better seccomp/kuser_helper diagnostics from debuggerd." 2017-02-02 17:37:25 +00:00
Elliott Hughes
0ba535976f Better seccomp/kuser_helper diagnostics from debuggerd.
Also switch to Android.bp for crasher.

Bug: http://b/34629282 (seccomp)
Bug: http://b/34705831 (seccomp)
Bug: http://b/34884086 (kuser_helpers)
Test: manual
Change-Id: I8ee79c635518faeba751742919af69a505b5e3e1
2017-02-01 18:43:03 -08:00
Josh Gao
6462bb41e0 debuggerd_handler: add and use fatal_errno.
Bug: none
Test: mma
Change-Id: I24d913abdbe74f9463feda78f7817ca8b92af9cc
2017-01-31 14:59:05 -08:00
Josh Gao
1e4afb52c5 debuggerd: fix debuggerd <pid>
Bug: none
Test: `debuggerd mediaserver`
Change-Id: Ibd7bbddb92a99ce49622c0ecc9329a3723f2085d
2017-01-30 17:58:04 -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
4ed00c8d73 debuggerd_handler: improve nonfatal signal message.
"Fatal signal 35 (???)" -> "Requested dump for"

Bug: http://b/34809044
Test: debuggerd -b $$
Change-Id: I9ece0ee1117203d30142b843973ed7e5435e21da
2017-01-30 17:58:04 -08:00
Josh Gao
e5288f292a debuggerd_handler: remove PR_SET_DUMPABLE check.
crash_dump has CAP_SYS_PTRACE and this was never obeyed by debuggerd.

Change-Id: Ifee5e94b97b1f6440ad0be79758f0db2d2aaba2e
2017-01-26 15:08:18 -08:00
Josh Gao
7e14d020f1 debuggerd_handler: don't dump PR_NO_NEW_PRIVS processes.
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-25 11:16:03 -08:00
Josh Gao
529b3066d5 debuggerd_handler: don't resend nonfatal signals when not dumping.
Bug: http://b/34516140
Test: debuggerd -b `pidof surfaceflinger`
Change-Id: I0275ffca24bf4840e264eaa4b79611e2404edfb0
2017-01-25 11:15:01 -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
8498016b81 tombstoned: silence spurious error messages.
Bug: none
Test: booted after deleting /data/tombstones/*
Test: crasher creates a tombstone
Change-Id: I8b3e8a3b521952412ebc955b2437bf8150220c16
2017-01-23 16:01:14 -08:00
Josh Gao
0ad5107e51 Actually don't start tombstoned until /data is mounted.
Bug: http://b/34461270
Test: boot is actually faster
Test: tombstoned still started by init
Change-Id: I4976abef108bbb6fad264f9b68cbc1fba711085b
2017-01-23 16:01:14 -08:00
Josh Gao
4decbe0d6c debuggerd_handler: add SIGSYS to the list of handled signals.
Bug: http://b/34586922
Test: kill -SYS $$
Change-Id: I31dadb9c65141d0c5556cc7256439e0a8d1519ab
2017-01-23 16:01:14 -08:00
Josh Gao
fca7ca3585 debuggerd_handler: properly crash when PR_GET_DUMPABLE is 0.
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-23 14:13:36 -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
b64dd85c94 debuggerd_handler: actually wait for pseudothread to exit.
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-23 11:34:49 -08:00
Treehugger Robot
b479a5002e Merge "init: don't start tombstoned until /data is mounted." 2017-01-20 22:13:38 +00:00
Josh Gao
42a0fed78b init: don't start tombstoned until /data is mounted.
When vold mounts the encrypted /data partition, it first checks for and
kills processes that have open fds to the tmpfs placeholder at /data.
This resulted in a 20 second boot-time regression (vold's timeout period)
when tombstoned was started before vold.

Bug: http://b/34461270
Test: boot is faster, no messages from vold in console spew
Test: tombstoned still started by init
Change-Id: Ib5e9ddb05f40c9da852f00e103861c6ff2d94888
2017-01-20 13:18:51 -08:00
Josh Gao
ac0403b1e5 Merge "crash_dump: don't abort if we fail to attach a sibling." 2017-01-20 21:02:30 +00: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
George Burgess IV
7008c8484d Fix a call to openat with incorrect arguments
Caught by running clang-FORTIFY over Android.

Bug: None
Test: Builds
Change-Id: If138c4bbb7f5fb40bbb20e24adbb25a6ef1286ac
2017-01-19 13:33:52 -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
Mark Salyzyn
51c33b7011 liblog: use log/log.h for ALOG macros
Test: compile
Bug: 34250038
Change-Id: I0f56c563871f377c03380498cd867b916892f1dc
2017-01-12 15:44:06 -08:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Elliott Hughes
400628aeac Improve crasher.
Make it behave better in our typical use cases and support more of the kinds
of crash we want to document.

Bug: http://b/28746168
Test: crasher
Change-Id: Ifbc3dfb042f6055568244c921f4abe1ea554cec4
2016-12-14 17:33:46 -08:00
Richard Uhler
3ff028c7db Merge "debuggerd: Dump list of open files on process crash."
am: b675f7cd32

Change-Id: Iec231fc7eb57fa2c51aabc0fb75b4a09c47004cd
2016-11-30 09:18:57 +00:00
Treehugger Robot
b675f7cd32 Merge "debuggerd: Dump list of open files on process crash." 2016-11-30 07:53:09 +00:00
Mark Salyzyn
10f4044341 Merge "system/core: replace EVENT_TAG_MAP_FILE with NULL"
am: 9bfd9f558b

Change-Id: Ief7fcc4f7dd8086186b38c091fed626560ca7215
2016-11-29 19:46:50 +00:00
Mark Salyzyn
1179eb8048 system/core: replace EVENT_TAG_MAP_FILE with NULL
NULL represents system default.  In the future, NULL could represent
static and dynamic tags, which can come from multiple files based on
implementation details in the liblog library.

Test: gTest logd-unit-tests & liblog-unit-tests
Bug: 31456426
Change-Id: I0e3d296de81ca299ae63d7b83781639ee67ec298
2016-11-21 11:13:02 -08:00
Richard Uhler
53fb32f05c debuggerd: Dump list of open files on process crash.
Test: Open a bunch of files, wait for the process to crash, verify dubuggerd
includes the list of open files the tombstone it generates.
Test: Added OpenFilesListTest to debuggerd_test.

Bug: 32013594

Change-Id: I6f939ae1d04dc58dc99abff0ed930da9e0ef0d1c
2016-11-21 11:40:42 +00:00
Josh Gao
e1a06eef2a Merge "crasher: add option to wait for input before crashing."
am: 84db3f19bc

Change-Id: I448bf3e527cd7435f650345492a9df1711b91048
2016-11-12 01:17:04 +00:00
Josh Gao
100ce3910d crasher: add option to wait for input before crashing.
This will be useful for tests that want to do things with crasher's pid
before it crashes.

Bug: http://b/30705528
Test: crasher wait-abort; crasher wait-thread-abort
Change-Id: I8ba826094dc304d6cd0e6ab088e5cfdb35d2007b
2016-11-11 14:29:13 -08:00
Mark Salyzyn
6df6448930 Merge "fix regression from android_lookupEventTag_len()"
am: 9fa133cc28

Change-Id: I8aa5cddb87290eaf86536b567b34cb3119839911
2016-10-24 23:12:42 +00:00
Mark Salyzyn
9f53cac1b4 fix regression from android_lookupEventTag_len()
Commit 807e40ecc9 'liblog: logd: Add
android_lookupEventTag_len()' which addressed a Dirty Shared memory
leak resulted in a regression. Most notably logcat <tag> stopped
working for the events log buffer.

AndroidLogEntry::tag also requires callers to check out
AndroidLogEntry::tagLen as tag is no longer guaranteed to be
nul terminated.

Test: logcat-unit-tests --gtest_filter=logcat.event_tag_filter
Bug: 31456426
Change-Id: Ibe5236131b640eb5b7e3df0ab4b5f3e25b85ad45
2016-10-24 13:39:19 -07:00
Mark Salyzyn
8a7297a09f Merge "system/core: preparation to pull back interfaces from android/log.h"
am: 27d2d49f48

Change-Id: I604bb1d4cf62636663fa92e3d14a55887dbcae23
2016-10-20 18:03:57 +00:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Mark Salyzyn
400d85ab2a debuggerd: use __android_log_is_debuggable()
am: dafe384207

Change-Id: Idba40e16ccc20f66c14aa294033d534212646fbf
2016-10-18 16:46:11 +00:00
Mark Salyzyn
dafe384207 debuggerd: use __android_log_is_debuggable()
Test: compile and signal 8 to some component
Bug: 27566046
Bug: 31456426
Change-Id: I35e83679fbc40d54217850521bff23d9306d86f8
2016-10-14 11:12:16 -07:00
Elliott Hughes
f1dffe0501 Merge "Rely on the platform -std default." am: 955648a915
am: 4594f50635

Change-Id: I459e76bcada6d849eccca73a470a910e335482bf
2016-10-14 02:47:44 +00:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Josh Gao
e758b2b3d3 Merge commit 'd3896c106d6a6e4d461be658a9e66efbde31f28d' into nyc-dev-plus-aosp
Change-Id: I77d77be5ba21c55cdf1172d7a7f7b4ba04dcbc81
2016-10-10 16:20:04 -07:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Josh Gao
218f7fb68e debuggerd: report crashes even when out of file descriptors.
Use nasty clone hacks to let us close random file descriptors to be
able to connect to debuggerd when the fd table is full.

Bug: http://b/32013594
Test: crasher exhaustfd-SIGSEGV
Change-Id: I47772e9a5994da4473bd935b105d9c36827c017a
2016-10-07 18:04:05 -07:00
Mark Salyzyn
6e5ffe2680 Merge "system/core: drop or replace log/logger.h" am: 1f90485804
am: cb670780be

Change-Id: I532a0f6143511f53f3303751f95de115ac034cd7
2016-10-04 18:33:44 +00:00
Mark Salyzyn
37c9451349 system/core: drop or replace log/logger.h
debuggerd does not require log/logger.h, can use android/log.h
In some cases, mark why log/logger.h was required.

Test: Compile and boot smoke test
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: Ia34987e25a01d81971ec8d785415f732b8376c4f
2016-10-04 09:09:10 -07:00
Mark Salyzyn
0308b0eabd system/core Replace log/log.h with android/log.h am: ff2dcd9af9
am: cac331afd9

Change-Id: I95c6a64bc35a041688303fcee4d506865d0a19a4
2016-09-30 22:13:00 +00:00
Mark Salyzyn
16f7786032 system/core Replace cutils/log.h with android/log.h am: 66ce3e08c5
am: eb189f147b

Change-Id: I3f2b13e259d9bbb7bc714f21eab7181fa72c35bf
2016-09-30 22:12:55 +00:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Mark Salyzyn
66ce3e08c5 system/core Replace cutils/log.h with android/log.h
Should use android/log.h instead of cutils/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
2016-09-30 12:47:05 -07:00
Elliott Hughes
c3501a4dff Merge "Fix debuggerd argument parsing." am: 99ed65234c
am: 014d9df418

Change-Id: I2565eb9a4b631e51bfe6bd57d328c8cdd2c3eff6
2016-09-16 21:13:17 +00:00
Elliott Hughes
9048608db1 Fix debuggerd argument parsing.
We weren't detecting incorrect input before. Also clean up the help output
to match the style of all the toybox output. Also flush stdout so that we
don't report failure before even saying that we're going to try to contact
debuggerd...

Change-Id: I9e4bfa878f270fe46c3c210c7a7138959a108d67
2016-09-15 17:08:33 -07:00
Elliott Hughes
6942f98f5d Merge "Teach debuggerd about SIGSYS SYS_SECCOMP signals." am: 44d7a87621
am: 9bec09f3cd

Change-Id: I57a46b611dfecac17d90df3d76da4c149d8f3704
2016-09-07 22:33:20 +00:00
Elliott Hughes
6fff551728 Teach debuggerd about SIGSYS SYS_SECCOMP signals.
These should be easier to interpret.

Bug: http://b/31171101
Change-Id: I362361d218390ab2306f86976172f8365b26b6ef
2016-09-07 13:55:50 -07:00
Christopher Ferris
99bb22da1b Merge "Update for kernel headers v4.7.2." am: 73d2cc570d
am: c4abab8578

Change-Id: I54f9530180e9d42032ed06fa7670125e5de0e4cf
2016-08-29 19:21:49 +00:00
Christopher Ferris
f83c7923f9 Update for kernel headers v4.7.2.
The new uapi kernel headers added a new SEGV reason code, so
add it to the tombstone code.

Update sync.c to include the needed data structures itself. Someone
else will be fixing this to work on old versus new kernels.

Change-Id: Icb27713ea38a20003c7671a9bca262eebd96099b
2016-08-26 16:48:18 -07:00
Mark Salyzyn
098b5887c6 Merge "logger: validate hdr_size field in logger entry" am: fcf7ab8b1b
am: 2d562c9dce

Change-Id: I5721e8614079a04c2dc364304d0ffed10d74be90
2016-08-24 16:07:38 +00:00
Mark Salyzyn
2d562c9dce Merge "logger: validate hdr_size field in logger entry"
am: fcf7ab8b1b

Change-Id: Ic88fe616256ab4949040771d3bed1dfb823ab981
2016-08-24 16:05:04 +00:00
Treehugger Robot
fcf7ab8b1b Merge "logger: validate hdr_size field in logger entry" 2016-08-24 15:56:23 +00:00
Elliott Hughes
66e5e2432a Merge "Most accept/accept4 calls in system/core don't actually want the remote address." am: 299d64144b
am: 8615d79d85

Change-Id: I89aeabf6efa8217c9acd3f8a766bbd18f7e994fa
2016-08-23 23:05:59 +00:00
Elliott Hughes
8615d79d85 Merge "Most accept/accept4 calls in system/core don't actually want the remote address."
am: 299d64144b

Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
2016-08-23 23:03:20 +00:00
Treehugger Robot
299d64144b Merge "Most accept/accept4 calls in system/core don't actually want the remote address." 2016-08-23 22:48:24 +00:00
Mark Salyzyn
305374cf0f logger: validate hdr_size field in logger entry
- check hdr_size to make sure it is in the expected range
  from sizeof entry_v1 to entry (entry_v4).
- alter msg() method to report NULL on invalid hdr_size
- alter all users of msg() method.

Bug: 30947841
Change-Id: I9bc1740d7aa9f37df5be966c18de1fb9de63d5dd
2016-08-23 14:51:50 -07:00
Josh Gao
c8146aa39f Merge "debuggerd: don't display fault addr for manually sent signals." am: ad52cbb9ec
am: 504d4ccd7c

Change-Id: Iac8f64e01b5dd3fa9ab6e34c2c151800142ccc69
2016-08-23 21:24:53 +00:00
Josh Gao
504d4ccd7c Merge "debuggerd: don't display fault addr for manually sent signals."
am: ad52cbb9ec

Change-Id: I34284b398c32dbdfe2074d44d316f81fc45deee8
2016-08-23 21:23:15 +00:00
Treehugger Robot
ad52cbb9ec Merge "debuggerd: don't display fault addr for manually sent signals." 2016-08-23 21:03:18 +00:00
Elliott Hughes
50a99aa6cb Merge "debuggerd: set SOCK_NONBLOCK in accept rather than later." am: 82b67fff06
am: 0d2ef3dc86

Change-Id: Ie8ae5707455f4d1741ca87ef515ea9a142e05aa5
2016-08-23 20:10:01 +00:00
Elliott Hughes
0d2ef3dc86 Merge "debuggerd: set SOCK_NONBLOCK in accept rather than later."
am: 82b67fff06

Change-Id: I6f2e72a4847fbfac8e1ba78321be7e026f7629bd
2016-08-23 20:05:48 +00:00
Elliott Hughes
3dcfa3fb1c Most accept/accept4 calls in system/core don't actually want the remote address.
So don't write the extra code for it or waste the kernel's time
copying it around.

Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
2016-08-23 12:50:00 -07:00
Josh Gao
344ca5a681 debuggerd: don't display fault addr for manually sent signals.
Bug: http://b/30819045
Change-Id: Ic8ab21298dcba6acdfa876e7c729b14b0bf2afbb
Test: `killall -TRAP surfaceflinger` no longer shows fault addr,
      crasher still does
2016-08-23 12:31:14 -07:00
Elliott Hughes
874c674c60 debuggerd: set SOCK_NONBLOCK in accept rather than later.
Change-Id: I95586984dd7aec798d75b150be238d5f6f7c91da
2016-08-22 14:17:25 -07:00
Josh Gao
27259667ec Merge "debuggerd: remove unnecessary arguments." am: 7a746f3a68
am: 60083bed75

Change-Id: I6f575a9662319db0dffeb121e0400eaa8f8cee55
2016-08-13 00:41:56 +00:00
Josh Gao
60083bed75 Merge "debuggerd: remove unnecessary arguments."
am: 7a746f3a68

Change-Id: I0a01639dd3096372eb5bbbe28362cdbf1c1da4af
2016-08-13 00:38:54 +00:00
Josh Gao
4a984ced34 Merge "debuggerd: remove useless timeout from wait_for_signal." am: 5f2bc28ebf
am: 4c4a172ee9

Change-Id: Ibbf4ff52d9349e8ceee5a6550c997328b204f332
2016-08-12 20:17:41 +00:00
Josh Gao
4c4a172ee9 Merge "debuggerd: remove useless timeout from wait_for_signal."
am: 5f2bc28ebf

Change-Id: Iee4f22c04ad330c91f86ca03583f8e36b2816039
2016-08-12 20:02:10 +00:00
Josh Gao
a04c80255c debuggerd: remove unnecessary arguments.
These were previously required when bionic used tgkill to reraise
signals, but now that we use rt_tgsigqueueinfo to reraise signals, they
are no longer necessary.

Change-Id: I46ba9f14039a727d0a2c4c3a9d93a3532ba8f263
2016-08-12 11:00:18 -07:00
Josh Gao
f5a960a187 debuggerd: remove useless timeout from wait_for_signal.
The watchdog already handles things for us, so the timeout logic in
wait_for_signal is pointless.

Change-Id: Id81ad5f294068216b73e04c4e2ceca072ae1bbc0
2016-08-12 11:00:18 -07:00
Josh Gao
98c4d5c4fe Merge "Define TARGET_IS_64_BIT when building libdebuggerd_client for android64." am: 07f14c9cdd
am: 40efc4c664

Change-Id: If6889e54994c39280a39cc700f46470b6b760dda
2016-08-10 22:25:57 +00:00
Josh Gao
40efc4c664 Merge "Define TARGET_IS_64_BIT when building libdebuggerd_client for android64."
am: 07f14c9cdd

Change-Id: Ieac230f7a5cd0107420f0f5dfc84d1d9a19e70e0
2016-08-10 22:23:06 +00:00
Robert Sesek
9eb02c973f Define TARGET_IS_64_BIT when building libdebuggerd_client for android64.
This is needed to connect to the right debuggerd server for the crashing
process. Without this change, the following errors are observed, because a
32-bit process is trying to connect to the 64-bit debuggerd (as opposed to
debuggerd32):

  Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 14153 (static_crasher)
  debuggerd: handling request: pid=14153 uid=0 gid=0 tid=14153
  debuggerd: Not allowed to redirect action 0 to 32 bit debuggerd

Bug: 24414818
Change-Id: I2f275fbc804b0abc6e876a743e51dd8494817103
2016-08-09 14:04:05 -04:00
Chih-hung Hsieh
e59bc67fa4 Merge \\"Fix google-explicit-constructor warnings in system/core.\\" am: 6dc68cb5f9
am: 89cc78b77f

Change-Id: I71cb106685a21a0cd0e49af76bd457889d0b1f13
2016-07-29 17:04:17 +00:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Stephen Hines
09dd6b7bee Merge \\"Disable warnings triggered in Clang r271374\\" am: fa1a21d085
am: 89cc8a57f4

Change-Id: Ibf67e2b6ca9cbeef3e3c97efbcdeaf7d97563e39
2016-07-19 23:52:24 +00:00
Pirama Arumuga Nainar
89cc8a57f4 Merge \"Disable warnings triggered in Clang r271374\"
am: fa1a21d085

Change-Id: I8ae8ec5436e7dc1173e463307ba0e925861156a0
2016-07-19 23:41:49 +00:00
Josh Gao
2b50c4a37d Merge \"debuggerd: verify that traced threads belong to the right process.\" into nyc-dev
am: d3d04f4d72

Change-Id: I65cd7507a24b7148dd67d748dede8e664dd70328
2016-07-19 20:34:43 +00:00
Pirama Arumuga Nainar
6fbbc4cdfa Disable warnings triggered in Clang r271374
http://b/28149048
http://b/29823425

Disable -Wvarargs that gets triggered in
system/core/debuggerd/test/ptrace_fake.cpp:ptrace_fake.  The second bug
above tracks that this warning gets re-enabled.

Test: Tested build, boot and common usage for Arm, Arm64, x86, x86_64,
Mips images in AOSP and internal branch.

Change-Id: Ife68675a77431bcc4717b4da297c14dc486d1413
2016-07-19 20:29:05 +00:00
Josh Gao
4a875ce6ff debuggerd: verify that traced threads belong to the right process.
Fix two races in debuggerd's PTRACE_ATTACH logic:
  1. The target thread in a crash dump request could exit between the
     /proc/<pid>/task/<tid> check and the PTRACE_ATTACH.
  2. Sibling threads could exit between listing /proc/<pid>/task and the
     PTRACE_ATTACH.

Bug: http://b/29555636
Change-Id: I4dfe1ea30e2c211d2389321bd66e3684dd757591
2016-07-13 16:49:02 -07:00
Colin Cross
68bfe51348 Merge \"Rename Android.soong.mk to Android.mk\"
am: b07df4dd3f

Change-Id: I9d9a232539b9991ab935e143140a3b77d896ebc7
2016-07-12 16:20:21 +00:00
Colin Cross
b39e4025ae Rename Android.soong.mk to Android.mk
Soong is always on now, so we don't have to distinguish between
makefiles that should be ignored because Soong is handling them with an
Android.bp file, and makefiles that are still needed with Soong.  All
obsolete Android.mk files have been removed, rename all Android.soong.mk
files to Android.mk.

Change-Id: Iabbddcbfb2c837cfd4556241b570474452cc5d4d
2016-07-11 16:56:51 -07:00
Josh Gao
88347e1430 Merge changes from topic \'debuggerd_client\'
am: abf88685e3

Change-Id: I2a61e4e8b5ec5a4ab6566ab4f8eb31653255fbc5
2016-06-20 20:47:18 +00:00
Treehugger Robot
abf88685e3 Merge changes from topic 'debuggerd_client'
* changes:
  adb: use libdebuggerd_client.
  debuggerd: add libdebuggerd_client.
2016-06-20 20:22:18 +00:00
Christopher Ferris
e1eb2272d6 Merge \"Fix race condition updating local map data.\"
am: 863d8e11b9

Change-Id: I00899ce500c2ae8bc58b6eb42c01d8688dd232c0
2016-06-18 00:05:26 +00:00
Josh Gao
9c02dc5916 debuggerd: add libdebuggerd_client.
Bug: http://b/24414818
Change-Id: I079c534d2c952b6975bf0428eb86cc7a55525737
2016-06-17 13:11:29 -07:00
Christopher Ferris
3a14004c7f Fix race condition updating local map data.
If the underlying local map changes, it's possible for multiple
threads to try and modify the map data associated with the UnwindLocalMap
object. Add a lock when generating the local map to avoid this problem.

In addition, add a read lock whenever any caller gets the maps iterator.
Updated all iterator callers to make this lock.

Bug: 29387050
Change-Id: Ie34822c3d8fd3bdb3dd126aeeb399969c36508c1
2016-06-16 23:28:11 -07:00
Chih-Hung Hsieh
dccd3a3698 Merge "Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace." am: dab7d9de03
am: fa7569c921

* commit 'fa7569c921b9ca0db894287ea826cbd3b041d880':
  Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.

Change-Id: I63223e36f3627d312051c86d54919b6cef33766c
2016-05-19 00:05:39 +00:00
Chih-Hung Hsieh
67867dbd79 Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.
Bug: 28705665
Change-Id: I469b2a882f6d1f399bfc22c75a26da245991fc33
2016-05-18 15:53:15 -07:00
Elliott Hughes
69541606c1 Merge "Add a fortify test to crasher." am: e674d32d2d
am: 4434b42cd0

* commit '4434b42cd0bd36be4ca7702e840886f67daaff2d':
  Add a fortify test to crasher.

Change-Id: I3b8b473aa256b7de7ca5e50e14b32d0c3b0565e1
2016-05-11 17:59:47 +00:00
Elliott Hughes
23d1cad9e0 Add a fortify test to crasher.
Change-Id: I675dbeaa39529583be5877946fd38b94ec341315
2016-05-10 14:44:59 -07:00
Christopher Ferris
8b474de4ac Set groups before dropping privileges.
The code for dumping tombstones tries to read the log data. This was
silently failing after the change to drop root privileges. Fix this
by explicitly setting the groups allowed before dropping privileges.

Bug: 28590884
(cherry picked from commit edc2380109)

Change-Id: I225365edccb11f8752027566fd42f3b10ce10260
2016-05-05 15:47:16 -07:00
Christopher Ferris
f89a23f27b Merge "Set groups before dropping privileges." into nyc-dev
am: fd1eee58f9

* commit 'fd1eee58f985b3d528ca352ff278d7b200390ab2':
  Set groups before dropping privileges.

Change-Id: I85c98abb0e7cc3b36ec714899540d65e6ca908c7
2016-05-05 21:57:30 +00:00