Commit graph

582 commits

Author SHA1 Message Date
Josh Gao
1cc7bd80a6 debuggerd: remove maximum abort message length.
Let the logging implementation be the imposer of limits.

Bug: http://b/64759619
Test: debuggerd_test
Change-Id: I8bc73bf2301ce071668993b740880224846a4e75
2018-04-13 17:34:20 -07:00
Dan Willemsen
e2b6cd28f2 Mark crash_dump.policy as not supported on mips
The recent change to detect missing source files broke reading makefiles
for mips, since this didn't specify a source file.

Bug: 73904572
Test: lunch aosp_mips-eng; m nothing
Test: lunch aosp_arm-eng; m crash_dump.policy
Test: lunch aosp_arm64-eng; m crash_dump.policy
Test: lunch aosp_x86-eng; m crash_dump.policy
Test: lunch aosp_x86_64-eng; m crash_dump.policy
Change-Id: I28864b5af59267f1ab83084128f2c59b04039374
2018-02-27 15:35:11 -08:00
Josh Gao
70adac6a8a debuggerd_fallback: don't recursively abort.
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-22 16:31:38 -08:00
Treehugger Robot
0609e8d231 Merge "bpfmt." 2018-02-20 02:02:59 +00:00
Josh Gao
edd28f6ede debuggerd seccomp: explain why we define PROT_READ/WRITE.
Add a comment explaining why we define PROT_READ/PROT_WRITE, even
though a current libminijail supports both cosntants.

Bug: http://b/73273658
Test: treehugger
Change-Id: I51c1be1b1b569e94dbc9045a90bc28221b7dc9c7
2018-02-18 23:50:19 -08:00
Justin Yun
40ecb9abf2 Define PROT_READ and PROT_WRITE when generating the policy files
When generating crash_dump.*.policy, replace PROT_READ and PROT_WRITE
to numeric constants to make the policy backward compatible with old
libminijail.so.

Bug: 73273658
Test: use the new policy in OMR1 devices
Change-Id: I936a733340ad4df8aef6562c03eb10c29ffdada2
2018-02-19 10:42:42 +09:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Elliott Hughes
e1415a5c3b Include the map name when dumping memory around a register.
Bug: http://b/19590178
Test: ran tests, ran crasher
Change-Id: Ib9afa34c860d8732ef1943eb4decd0b7c8fb55fd
2018-02-15 16:28:50 -08:00
Josh Gao
c531ed6648 debuggerd_fallback: fix race.
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-02-09 15:35:40 -08:00
Josh Gao
08cd23e732 debuggerd: update policy for recent sigaction changes.
Commit 3e235911 in bionic switched LP32's sigaction implementation over
to using the rt_sigaction syscall, matching LP64. Update our seccomp
policy to match.

Bug: http://b/73119572
Test: debuggerd_test32
Change-Id: I0a662a1c874298d434468d2dcdb4ebf9f276110c
2018-02-08 16:48:03 -08:00
Christopher Ferris
0b06a590d9 Add extra frame when dex_pc is non-zero.
Use the art dex file library to read the dex data.

Add unit tests for the UnwindDexFile code.

Bug: 72070049

Test: All unit tests continue to pass.
Test: Dumped the backtrace of the 137-cfi test while running in interpreter
Test: mode and verified that the stack trace is correct. Did this on host
Test: and for arm/arm64.

Change-Id: Ia6f343318c5dd6968a954015a7d59fdf101575b0
2018-01-23 13:17:48 -08:00
Christopher Ferris
e36afb0429 Fix regression caused by libbacktrace API change.
The stack dump was not printing leading zeros for data after the
change to remove uintptr_t types from the libbacktrace API.

Bug: 65682279

Test: Created an arm tombstone and an arm64 tombstone and verified
Test: that the stack data has leading zeros.
Change-Id: I1fbec2c4fa7c8b0fab18894c5628d18c5a580299
2018-01-20 00:59:11 -08:00
Josh Gao
fd0e0db391 Merge "debuggerd: add seccomp policies and tests." 2018-01-20 02:45:37 +00:00
Christopher Ferris
7937a36c8e Change all uintptr_t to uint64_t in API.
In order to support the offline unwinding properly, get rid of the
usage of non-fixed type uintptr_t from all API calls.

In addition, completely remove the old local and remote unwinding code
that used libunwind.

The next step will be to move the offline unwinding to the new unwinder.

Bug: 65682279

Test: Ran unit tests for libbacktrace/debuggerd.
Test: Ran debuggerd -b on a few arm and arm64 processes.
Test: Ran crasher and crasher64 and verified tombstones look correct.
Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
2018-01-18 17:26:20 -08:00
Josh Gao
e04ca2794a debuggerd: add seccomp policies and tests.
Bug: http://b/38508369
Test: debuggerd_test32/64 on walleye and aosp_x86_64
Change-Id: I7e69e37bcd1823d271b9f2b0a13b8c9cba9a8e84
2018-01-18 13:49:56 -08:00
Treehugger Robot
be10cae468 Merge "debuggerd_handler: set PR_SET_PTRACER before running crash_dump." 2018-01-08 23:32:22 +00:00
Treehugger Robot
1406d991a3 Merge "Change seccomp to the system filter" 2018-01-08 20:15:16 +00:00
Luis Hector Chavez
4841e744c2 debuggerd_handler: set PR_SET_PTRACER before running crash_dump.
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-27 13:19:31 -08:00
Victor Hsieh
9a0e12d405 Change seccomp to the system filter
Test: build
Bug: 63944145
Change-Id: I55da5354b90def14b024add7979099189943d9e6
2017-12-22 14:35:28 -08:00
Josh Gao
34c2556d11 debuggerd: restore the location of abort message.
The abort message was accidentally relocated to be printed below the
registers, backtrace, and stack, which isn't very helpful. Move it back
to its rightful place.

Test: treehugger
Change-Id: I8aa5b63e58081f27ccdb42481fed8d9eb3a892a4
2017-12-22 14:20:12 -08:00
Josh Gao
7302097e77 debuggerd: wait for dump completion on crashes.
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-22 14:20:12 -08:00
Treehugger Robot
df9fbc7d75 Merge "base: extract {ASSERT,EXPECT}_MATCH helpers from debuggerd_test." 2017-12-20 03:24:39 +00:00
Josh Gao
30171a8b47 base: extract {ASSERT,EXPECT}_MATCH helpers from debuggerd_test.
Add some helper macros that perform regex string matching to
<android-base/test_utils.h>.

Test: libbase_test32/64 on host
Change-Id: I1b0f03dc73f8b4fdfb8ac6c75d59ef421e0e9640
2017-12-19 17:16:12 -08:00
Josh Gao
a42314e436 debuggerd: add pause time benchmark.
Add a benchmark to measure how long we pause a process when dumping.

Bug: http://b/62112103
Test: manually ran it
Change-Id: Iceec2f722915b0ae26144c86dcbeb35793f963da
2017-12-19 16:36:04 -08:00
chirag honnavar
def0888a80 Increased number of Android log lines for tombstones
5 lines are not enough for debug

Bug: b/69815742

Change-Id: I3117f221f4945941ec277064ffd2765dda74e192
2017-12-18 09:28:49 +09:00
Josh Gao
2b2ae0c88e crash_dump: fork a copy of the target's address space.
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-12-15 14:11:12 -08:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Christopher Ferris
b7de5f5429 Demand read load bias for a map.
Add a static GetLoadBias method to the Elf object that only reads just
enough to get the load bias.

Add a method to MapInfo that gets the load bias. First attempt to get
it if the elf object already exists. If no elf object was created, use
the new static method to get the load bias.

In BacktraceMap, add a custom iterator so that when code dereferences
a map element, that's when the load bias will be retrieved if it hasn't
already been set.

Bug: 69871050

Test: New unit tests, verify tombstones have non-zero load bias values for
Test: libraries with a non-zero load bias.
Change-Id: I125f4abc827589957fce2f0df24b0f25d037d732
2017-12-05 13:12:47 -08:00
Christopher Ferris
664d2a9093 Force call the fallback handler.
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-16 20:07:13 -08:00
Treehugger Robot
dbef1eeb45 Merge "crash_dump: don't inherit environment from parent." 2017-11-08 00:44:47 +00:00
Josh Gao
cdea750576 crash_dump: don't inherit environment from parent.
Bug: http://b/68381717
Test: debuggerd_test
Change-Id: Ie1b342bc9901cb9ae9b79147899928a19052cbad
2017-11-03 16:57:56 -07:00
Chih-Hung Hsieh
122352d983 Use -Werror in system/core
* Move -Wall -Werror from cppflags to cflags.
* Fix/suppress warning on unused variables.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I1e05e96a1d0bcb2ccef1ce456504b3af57167cc5
2017-11-01 11:32:55 -07:00
Christopher Ferris
d9f183b83b Merge "Only call one unwinder." 2017-10-29 04:40:01 +00:00
Josh Gao
18ea0978cf Delete obsolete debuggerd references.
Test: treehugger
Change-Id: Ic1a8cfb867decd76443fdc26333f2bcaa98b61bb
2017-10-27 16:12:49 -07:00
Christopher Ferris
ab9cf8b4cc Only call one unwinder.
Nobody is looking at the mismatches, and it can cause problems
with tombstone parsers.

Also, fix the dump_header_info test and remove unused properties_fake.cpp.

Test: Ran unit tests, verified tombstones still work.
Change-Id: I4261646016b4e84b26a5aee72f3227f1ce48ec9a
2017-10-27 15:18:27 -07:00
Tom Cherry
4a5a337ef2 Merge "Move some properties users to __system_property_read_callback()" 2017-10-12 16:53:41 +00:00
Treehugger Robot
81dd96c0da Merge "Add missing includes." 2017-10-11 22:17:38 +00:00
Dan Albert
c38057a603 Add missing includes.
Test: mma
Bug: None
Change-Id: I5ee2d09eeac2b4e2056719498916cbdfb79725d2
2017-10-11 13:19:09 -07:00
Tom Cherry
31121cafec Move some properties users to __system_property_read_callback()
This is needed if they will ever handle ro. properties that have
values longer than 92 characters.

Bug: 23102347
Bug: 34954705
Test: read and write properties with value length > 92 characters
Change-Id: I44aa135c97ec010f12162c30f743387810ae2c5d
2017-10-10 15:03:33 -07:00
Josh Gao
1ce8e14568 libdebuggerd: fix tombstone tests.
Update the tests to match new output (and stop pluralizing '1 entries').

Test: `debuggerd_test{32,64} --gtest_filter="TombstoneTest.*" on hikey960
Change-Id: I16b0335715303252fad3a35d6a053a50fefdac30
2017-10-10 13:55:44 -07:00
Treehugger Robot
92c355cc4f Merge "Show the number of VMAs in the tombstone." 2017-09-26 21:01:20 +00:00
Elliott Hughes
868d39a82f Show the number of VMAs in the tombstone.
Tombstones (especially ones with lots of VMAs) are regularly truncated.
We can at least show the number of VMAs, though, for anyone interested
in knowing whether they got close to the default 64Ki limit.

Bug: http://b/66911122
Test: ran crasher, examined tombstone
Change-Id: I286db66f28f132307d573dbe5164efc969dc6ddc
2017-09-26 12:01:06 -07:00
Christopher Ferris
9b91324cb0 Merge "Add a new unwind method on error." 2017-09-25 19:16:59 +00:00
Josh Gao
ce9cc4e428 tombstoned: fix another call to evconnlistener_new.
Apply the same fix from c2e98f63 to intercept_manager.cpp.

Bug: http://b/64543673
Test: debuggerd_test
Change-Id: Ibfb919e059fa62f8336cfc1426d03ef015590136
2017-09-22 18:00:35 -07:00
Christopher Ferris
b9de87f7ed Add a new unwind method on error.
If a function crashes by jumping into unexecutable code, the old method
could not unwind through that. Add a fallback method to set the pc from
the default return address location.

In addition, add a new finished check for steps. This will provide a method
to indicate that this step is the last step. This prevents cases where
the fallback method might be triggered incorrectly.

Update the libbacktrace code to unwind using the new methodology.

Update the unwind tool to use the new unwind methodology.

Add a new option to crasher that calls through a null function.

Create a new object, Unwinder, that encapsulates the a basic unwind. For now,
libbacktrace will still use the custom code.

Added new unit tests to cover the new cases. Also add a test that
crashes calling a nullptr as a function, and then has call frames in
the signal stack.

Bug: 65842173

Test: Pass all unit tests, verify crasher dumps properly.
Change-Id: Ia18430ab107e9f7bdf0e14a9b74710b1280bd7f4
2017-09-22 16:55:12 -07:00
Isaac Chen
06c65ed667 Merge "Enable HAS_VFP_D32 for 32-bit armv8 crasher" 2017-09-18 01:58:02 +00:00
Isaac Chen
6dc21a5ac5 Enable HAS_VFP_D32 for 32-bit armv8 crasher
Android.bp assumed only an armv7-a-neon core needs to set HAS_VFP_D32.
In fact, an armv8 core also has 32 double-word floating point registers
for A32 and T32 ISAs (AArch32 or 32-bit armv8).

Bug: 65568426
Test: lunch aosp_arm64; emulator # on oc-mr1-dev; boot to home screen.
      Check crashglue.o actually uses VFP_D16-31 for 32-bit armv8 core.
Change-Id: I34584a27fa24a55bb4809ccd7f99a8122971df0e
2017-09-15 15:31:22 +08:00
Narayan Kamath
e997ba9d22 Merge "tombstoned: Fix calls to evconnlistener_new." 2017-09-14 08:33:49 +00:00
Treehugger Robot
26123d7ec0 Merge "debuggerd_fallback: print maps." 2017-09-14 05:49:24 +00:00