Commit graph

840 commits

Author SHA1 Message Date
Peter Collingbourne
a6fac881b2 Remove dead non-proto tombstone reporting code.
Bug: 197981919
Change-Id: I58a98070198ef0b686229bd54f87b9073df12d66
2022-03-07 17:03:18 -08:00
Christopher Ferris
b999b82eb7 Dump threads in tombstone fallback path.
When dumping a tombstone using the fallback path, only the main
thread was showing up. Modify the code to dump the threads using
a slightly different path for the tombstone generation code.

In addition, while looking at this code, two MTE variables were
not set in the tombstone fallback code. Added those variables
so MTE devices will work properly in this fallback path.

Modified the tombstone unit tests for seccomp to have
multiple threads and verify those threads show up in the tombstone.

Bug: 208933016

Test: Ran unit tests.
Test: Ran debuggerd <PID> on a privileged process and verified
Test: all threads dumped. Also verified that the tagged_addr_ctrl
Test: variable is present on the raven device.
Change-Id: I16eadb0cc2c37a7dbc5cac16af9b5051008b5127
2022-02-16 15:02:38 -08:00
Peter Collingbourne
a2739dae4e Make crash_dump.policy a dependency of crash_dump.
debuggerd_test depends on it, and the easiest way to
ensure that the file is available when running the tests
is to make it a dependency of crash_dump.

Change-Id: Iebea8e0c49d8d49d52a434e4194e870793758988
2022-02-02 17:02:50 -08:00
Christopher Ferris
16a7bc2355 Fix typo.
Change use of new_ to old_ to save the old sigaction data. This hasn't
caused any issues, but it's obviously wrong.

Test: Ran unit tests on coral.
Change-Id: I96be5b0980c323c3aeafb422fbc06202577604a2
2022-01-31 13:08:54 -08:00
Elliott Hughes
9453199683 Merge "debuggerd: add the PAC keys to the tombstones." 2022-01-14 18:52:01 +00:00
Elliott Hughes
d13ea523e1 debuggerd: add the PAC keys to the tombstones.
Hard to get otherwise if you're trying to debug PAC issues.

Bug: http://b/214314197
Test: treehugger
Change-Id: I2e5502809f84579bf287364e59d6e7ff67770919
2022-01-13 15:03:19 -08:00
Christopher Ferris
22ad09b01d Update for MapInfo objects in frame data.
The frame data no longer contains map_XXX fields which represent
the map data. Now there is only a shared pointer to the MapInfo
object with which this frame is associated.

Bug: 120606663

Test: Unit tests pass.
Change-Id: I89282963f742f6fcc07e48533da4108dc16bdce9
2022-01-06 14:37:46 -08:00
Christopher Ferris
bdea3bb56b Remove non-protobuf path.
It is expensive to keep the non-protobuf path around and it hasn't
been used for an entire release without anyone noticing, so remove it.

Create new end-to-end unit tests that cover tests of the non-proto
code paths that are being deleted.

Bug: 197981919

Test: Unit tests pass.
Change-Id: Ia1c45572300bd63e5f196ad61e5e5386830c8ece
2021-11-19 02:07:30 +00:00
Treehugger Robot
a44f269eba Merge "Improvements to tombstone output." 2021-11-12 00:17:12 +00:00
Peter Collingbourne
773acaa18e Improvements to tombstone output.
- Use "likelihood" instead of "probability" since that has connotations
  of being less precise, and our probability ordering isn't very precise
  anyway.

- Hide the fault address with SEGV_MTEAERR because it is not available.

- Pad the fault address with leading zeroes to make it clearer which
  bits of the top byte (and any following bytes such as PAC signature
  bits) are set.

Bug: 206015287
Change-Id: I5e1e99b7f3e967c44781d8550bbd7158eb421b64
2021-11-11 15:05:47 -08:00
Peter Collingbourne
57e19ac46e Merge "Add a human readable description of the tagged_addr_ctrl value to tombstones." 2021-11-10 18:56:59 +00:00
Peter Collingbourne
47d784e9f2 Add a human readable description of the tagged_addr_ctrl value to tombstones.
Change-Id: Ib9860b282cf749891e0f6ef7697669b94235c236
2021-11-05 18:59:26 -07:00
Christopher Ferris
c67760611c Update for libunwindstack shared_ptr MapInfos.
Bug: 120606663

Test: Unit tests pass.
Change-Id: Ieae157388e8571345ed8968a2b5c2aa34464689f
Merged-In: Ieae157388e8571345ed8968a2b5c2aa34464689f
(cherry picked from commit 853733b627)
2021-10-28 15:05:39 -07:00
Steven Moreland
2e1e76b8ff Merge "Revert "strerror: incl enum name"" 2021-10-07 00:25:39 +00:00
Steven Moreland
dde8fefced Revert "strerror: incl enum name"
Revert "strerror: incl enum name"

Revert submission 1833622-usable-strerror

Reason for revert: b/202330586
Bug: 202330586
Reverted Changes:
I4d8f617a0:Track strerror(3) change.
I8ea86220c:strerror: incl enum name
I407bd9f4d:strerror: incl enum name

Change-Id: I293ac322160c6a82ff7004a3de085cafbd514458
2021-10-07 00:19:18 +00:00
Elliott Hughes
79de514910 Merge "strerror: incl enum name" 2021-10-06 19:35:51 +00:00
Christopher Ferris
2b98c82f05 Add CHECK to verify assumptions in the code.
On the main thread, the siginfo pointer will never be nullptr.
Add a CHECK to make sure this is true.

Test: Unit tests pass both 32 bit and 64 bit.
Test: Ran with debug.debuggerd.translate_proto_to_text set to 0
Test: to exercise old path.
Change-Id: I9d5ed0de5d652de8a4f9cd85eb57cbb1ec676404
2021-09-28 16:15:51 -07:00
Christopher Ferris
be17619ccc Merge "Disable scudo when using svelte config." 2021-09-25 01:36:48 +00:00
Christopher Ferris
7aad2567ee Disable scudo when using svelte config.
This code was added, but a svelte config still tries to use scudo
related code that doesn't exist.

Bug: 201007100

Test: Ran unit tests on normal config.
Test: Ran unit tests on svelte config.
Change-Id: Ic84bae37717d213121aef182bac2f82dbee25213
2021-09-24 11:55:36 -07:00
Steven Moreland
575bce5ee8 strerror: incl enum name
strerror is nice, but usually I don't care about the text, I care about
the uppercase enum

Bug: N/A
Test: N/A
Change-Id: I8ea86220cb04cbded701379c47b8aba8ea8864b8
2021-09-23 21:29:50 -07:00
Elliott Hughes
32d3cdda22 libdebuggerd: fix process uptime.
I was here because we have a case where timeout(1) kills logcat, but
debuggerd alleges that the process that was killed had started less than
a second ago. I'm not sure this is the problem there, but I did notice
that far too many tombstones were claiming improbably short process
uptimes. It turns out that the code was measuring the *thread* uptime,
not the *process* uptime.

Also simplify the code a bit by switching to sysinfo(2) rather than
reading a file.

Test: manual, plus the existing unit test
Change-Id: Ie2810b1d5777ad9182be92bfb3f60795dc978b24
2021-09-21 17:30:30 -07:00
Christopher Ferris
2038cc7633 Add a test to verify the dex_pc is correct.
The libunwindstack code will attempt to dlopen the libdexfile.so
when a dex pc is found. Unfortunately, this failed since that
library was not properly listed as a runtime library. To make
sure this doesn't happen again, add an end to end test that
will create a dex pc frame, and will verify the correct
dex function name is in that frame.

Bug: 199043576

Test: Unit test passes on arm/aarch64/x86/x86_64.
Test: Removed the runtime_libs of libdexfile from libunwindstack
Test: and verified the new test fails.
Change-Id: I3a11f9ee44e06e37a547d193b04f7fbb90ccfe0a
2021-09-15 22:14:28 +00:00
Martin Stjernholm
7b0ae4ba7d Merge "Add libdexfile runtime dependency of libdexfile_support (reland)." 2021-09-02 16:36:43 +00:00
Christopher Ferris
ab9f0cd759 Remove double check of fd value.
The output.text.fd value is only ever -1 when there is a failure.
There is no need to check both < 0 or -1, so only check for -1.

Test: Unit tests pass.
Test: Verified the message is seen on intercept and not on
Test: regular crashes.
Change-Id: I1eddcd5d2342b268ceb261b246c98b10cee85bb4
2021-09-01 13:36:03 -07:00
Martin Stjernholm
3784b9de46 Add libdexfile runtime dependency of libdexfile_support (reland).
Necessary since static_libs doesn't propagate transitive dependencies
in Soong.

Test: m droid
Bug: 197856821
Bug: 169779783
Change-Id: Ia70f8596228770451c95610be0e97783dabf3af3
2021-09-01 13:27:48 +01:00
Rex Lin
dc14d16f80 Revert "Add libdexfile runtime dependency of libdexfile_support."
Revert "Allow visibility on libdexfile for all libdexfile_suppor..."

Revert "Add libdexfile runtime dependency of libdexfile_support."

Revert "Add libdexfile runtime dependency of libdexfile_support."

Revert submission 1810760-libdexfile-runtime-2

Reason for revert: DroidMonitor: Potential culprit for Bug 198352910 - verifying through Forrest before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted Changes:
If4da968e4:Add libdexfile runtime dependency of libdexfile_su...
I80162942a:Allow visibility on libdexfile for all libdexfile_...
Iab18abc8e:Add libdexfile runtime dependency of libdexfile_su...
I473d146d8:Add libdexfile runtime dependency of libdexfile_su...

Change-Id: Iacab8e0a5c74e0c3185a155e35c28903aa9acb4a
2021-09-01 01:57:17 +00:00
Martin Stjernholm
832f1ebeec Add libdexfile runtime dependency of libdexfile_support.
Necessary since static_libs doesn't propagate transitive dependencies
in Soong.

Test: m droid
Bug: 197856821
Bug: 169779783
Change-Id: If4da968e4e2f7ab0aaedd097c914242d0e9eb73e
2021-08-31 17:20:22 +01:00
Christopher Ferris
7e4c2a8ccc Add fault address marker in proto to tombstone.
When the switch was made to dump the tombstone from the protobuf,
the fault address marker in the maps section went missing. Re-add
that logic and add new unit tests to verify all of the different
behaviors.

Bug: 193935960

Test: All unit tests pass.
Test: All unit tests pass when setprop debug.debuggerd.translate_proto_to_text 0
Test: The above on cuttlefish, 32 bit and 64 bit.
Test: The above on a flame, 32 bit and 64 bit.
Change-Id: I098bb6ab4bacacae2ca0fc5ec9a73549ed0b9489
2021-08-23 16:25:13 -07:00
Christopher Ferris
c1c2b4f816 Merge "Modify missing output fd message." 2021-08-20 19:45:36 +00:00
Christopher Ferris
64a92413b6 Modify missing output fd message.
The "missing output fd" message can seem like an error, so modify
the message to indicate what is really happening. This message
will occur normally when running the debuggerd command, or when
a bugreport is generated, or when an ANR occurs. In all of those
cases, this is not an error, but an expected action.

Bug: 196189981

Test: Ran debuggerd -b and debuggerd and verified this message is seen.
Test: Ran unit tests.
Change-Id: I6e3d5a76d92b972c77fca301ea7147745bc67c37
2021-08-18 17:01:13 -07:00
Christopher Ferris
80fccb3c9a Merge "Remove trailing newlines from abort message." 2021-08-18 23:10:35 +00:00
Christopher Ferris
e8891458e5 Remove trailing newlines from abort message.
The tombstone will add a newline after the abort message, so remove
any trailing newlines before saving/printing.

Bug: 196414062

Test: Unit tests pass.
Test: Set system property debug.debuggerd.translate_proto_to_text to 0
test: and unit tests still pass.
Change-Id: I0d3dc215eb5d8be93d99e5b9d4f0a14b1d61396d
2021-08-18 14:13:02 -07:00
Elliott Hughes
0589b7eb94 Merge "Split up the system/core/ TEST_MAPPING." 2021-08-18 16:25:15 +00:00
Elliott Hughes
22e082e87a Split up the system/core/ TEST_MAPPING.
A lot of things had moved out of system/core/ without their TEST_MAPPING
entries having gone with them, reducing the amount of presubmit coverage
for those things.

In order to reduce the likelihood of that happening again, I've pushed
all that remained in the system/core/ TEST_MAPPING down into the
individual subdirectories.

Test: treehugger
Change-Id: Ib75d65f9200fa64ae1552471da6fbe5b7023cf94
2021-08-16 16:37:10 -07:00
Yabin Cui
e90a944c8a debuggerd: add -fno-finite-loop to fix test.
After compiler update, infinite side effect free loops are replaced with trap
instructions. So use -fno-finite-loop to disable this behavior.

Bug: 196162833
Test: run debuggerd_test.
Change-Id: I057263360a5df64af18c17a025fab48887d0b470
2021-08-11 13:21:11 -07:00
Christopher Ferris
0ef9b4d365 Remove jmgao from OWNERS files.
Josh no longer works on Android, so remove him from OWNERS files.

Test: NA
Change-Id: I676cd803b5e3167db1b5175a630d85d1edfcaaaf
2021-08-10 21:42:14 -07:00
Christopher Ferris
a3e9a0b2e1 Always use main thread pid for manual dumping.
When running debuggerd from the command line, it's possible that
the signal will happen on a side thread. The original intercept
in tombstoned is set to only handle crashes from the main thread
pid, so in this case, the intercept doesn't occur. To fix this,
modify the code so that running debuggerd always sends the signal
to the main pid. In addition, modify the signal handler is entered
due to the BIONIC_SIGNAL_DEBUGGER signal, then the crashing tid is
set to the main thread pid instead of the current thread.

Add unit test to cover this case.

Bug: 194346289

Test: All unit tests pass.
Test: Verify the new unit test is getting the signal on the non-main
Test: thread and still properly handling the intercept.
Test: Modify the debuggerd code to send the signal to the non main pid
Test: and verify the dump still occurs correctly.

Change-Id: I2dd1bd11fc8ef4a6fe87f05ecc67ae349a101c82
2021-07-30 14:08:03 -07:00
Christopher Ferris
c31ccb44bf Update for new TRAP_PERF value.
For the new kernel 5.13 heders, there is a new TRAP_PERF value that
needs to be handled.

Test: Builds.
Change-Id: I2c6658ca94423c210db9ad6692ec69f6be69b3f5
2021-07-01 03:35:24 +00:00
Elliott Hughes
8d7c887b23 Merge "debuggerd_client: also log errors to the dump file." 2021-06-30 15:45:31 +00:00
Treehugger Robot
9e52385898 Merge "[MTE] Add a HWASan-style tag dump to tombstones." 2021-06-29 22:46:59 +00:00
Kalesh Singh
a9ea7e5b8e debuggerd_client: also log errors to the dump file.
Dumping stack in ANR can fail, but error message is only printed
to logcat. To allow easier debugging of such cases we add the
error messages in the ANR file as well.

Also factor out some duplication, inline single-call functions to
their call sites, and make some of the lambdas clearer by only having
implicit state unrelated to their primary purpose in captures but
passing as arguments things they fundamentally need to do their job
(and actually adding some duplication for time_left() which was subtle
enough to fool me into thinking that we only needed one call of
set_timeout(), which I've renamed to update_timeout()).

Bug: 191172191
Test: Manual
Change-Id: I39a50ca5b72059bfeff48b010d3be44f19eb32fa
2021-06-29 11:59:14 -07:00
Mitch Phillips
5ddcea2924 [MTE] Add a HWASan-style tag dump to tombstones.
We already dump the tags in the regigster dump section by appending the
tag to the memory address. You only get 2 granules before each register
and 13 after.

The HWASan-style tag dump is extremely useful for debugging, as it gives
a pretty comprehensive overview of the memory subsystem. It also
provides enough context bytes (256) to give you a reasonable intuition
about a particular bug.

The tag dump shows up only if PTRACE_PEEKTAGS returns at least one value
in the 256 requested. If the start of end of the region is untagged,
it's omitted. The tag dump looks like this:

Change-Id: Icc33fb97542d9b1fa3ae9e58aba34d524c6ba7b5

---
Memory tags around the fault address (0x60000704414d340), one tag per 16 bytes:
      0x704414d000: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d100: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d200: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
    =>0x704414d300: 0  0  0  0 [2] 2  0  0  0  0  0  0  0  0  0  0
      0x704414d400: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d500: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d600: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d700: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d800: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414d900: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
      0x704414da00: 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
---

Bug: 183992164
Test: atest debuggerd_test on MTE+QEMU and sunfish.

Change-Id: I8d5842e4803ca30b407e866c99eef56f2cb36600
2021-06-28 15:53:10 -07:00
Elliott Hughes
813fd6d1fd License boilerplate.
Bug: http://b/191499510
Test: treehugger
Change-Id: Ie0c34ec4713e04511a31ec033a097cb1c033fe79
2021-06-25 14:42:51 -07:00
Christopher Ferris
bd5d08c135 Merge "Avoid using thread cache in unwinder." 2021-06-24 20:21:12 +00:00
Suren Baghdasaryan
2079c5f0c9 Replace writepid with task_profiles command for cgroup migration
writepid command usage to join a cgroup has been deprecated in favor
of a more flexible approach using task_profiles. This way cgroup path
is not hardcoded and cgroup changes can be easily made. Replace
writepid with task_profiles command to migrate between cgroups.

Bug: 191283136
Test: build and boot
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I945c634dfa7621437d8ea3981bce370d680b7371
2021-06-24 17:24:20 +00:00
yidong zhang
cbf7c466e6 Avoid using thread cache in unwinder.
Using  thread cache will cause SIGSEGV for 32bit+kernel4.9 device.

Bug: 190579082
Bug: 189803009

Test: run cts -m CtsSeccompHostTestCases
Change-Id: I47b13d02674aadbacd8dac36d8382eed0885413c
Signed-off-by: yidong zhang <yidong.zhang@amlogic.com>
2021-06-24 19:04:55 +08:00
Treehugger Robot
a08d328864 Merge "debuggerd: unify licenses." 2021-06-23 01:27:44 +00:00
Elliott Hughes
a029d98ad0 crash_dump: avoid misleading error messages.
I'm guessing that the original

  F crash_dump64: crash_dump.cpp:460] failed to attach to thread 1671, already traced by 0 ()

was probably a race, where there _was_ a tracer but they disappeared?
Whatever, it doesn't seem helpful to show "already traced by nobody",
and we also don't want to clobber errno in the fallthrough case
(previously just where get_tracer() failed, but now also where
get_tracer() returns "nobody").

Bug: http://b/188668580
Test: treehugger
Change-Id: I3fa3b4f7e32531d48dfbb0ef946ff351ed5d9171
2021-06-21 12:39:40 -07:00
Elliott Hughes
b20a3aaa1c debuggerd: unify licenses.
All but three files are Apache-2.0 already.

Bug: http://b/191499510
Test: /google/src/files/head/depot/google3/wireless/android/busytown/ayeaye/analyzers/copyright/tools/scan_android_project.sh ~/aosp/system/core/debuggerd/ | grep -v APACHE
Change-Id: I430c3382dd160e398f02470d7053ecea39c98f41
2021-06-18 15:49:30 -07:00
Christopher Ferris
0c787f0d6b Avoid thread cache in unwinder.
The code in the fallback path calls pthread_key_create when using the
normal thread cache. However, this code is executed out of the linker,
which means that the call doesn't see keys created by the libc version
of pthread_key_create. As of now, simply avoid using the thread cache
to avoid this problem.

Bug: 189803009

Test: debuggerd -b on a media process on a 32 bit Android Go device
Test: and observe no crash.
Test: debuggerd unit tests pass.
Change-Id: I9ca1a55e44d3bb69d49450826d7d64d7a64145c3
(cherry picked from commit 49e5a76544)
2021-06-14 19:57:33 +00:00