Commit graph

1053 commits

Author SHA1 Message Date
Florian Mayer
a7da00f4f0 Merge "Test stack buffer size calculation." into main 2024-11-12 18:51:39 +00:00
Florian Mayer
6facd1bfd3 Test stack buffer size calculation.
Bug: 378140560
Change-Id: Idca03cac925bc0d8bd574817391c4eaca11f2bff
2024-11-11 14:03:00 -08:00
Peter Collingbourne
f59ca8c294 Merge "Add support for tombstone symbolization to pbtombstone." into main 2024-10-31 21:16:01 +00:00
Treehugger Robot
539f39e619 Merge "Make pbtombstone a host tool." into main 2024-10-31 19:35:37 +00:00
Peter Collingbourne
cf9f0870e4 Add support for tombstone symbolization to pbtombstone.
This patch teaches pbtombstone to use llvm-symbolizer to symbolize
stack traces and augment the protobuf tombstones with the symbol
information, before printing tombstones with the symbolized stack
traces included.

The main advantage of adding this information to the tombstone
as opposed to having developers use the stack tool is that stack
does not print all of the information in the original tombstone,
which means that both reports may be required to understand a crash.
Furthermore, stack traces printed by stack are not correlated with
the stack traces in the tombstone, making the report harder to read,
especially with GWP-ASan and MTE which may produce multiple stack
traces for the crashing thread.

Although we could teach stack to print more information, this would
continue to be fragile because stack relies on parsing textual
tombstones. Switching stack to read proto tombstones would be
tantamount to a full rewrite and would require duplicating the C++
proto-to-text logic that we already have in Python. It seems better
to reuse the C++ code for the proto-based symbolization tool.

llvm-symbolizer will look up the symbol files by build ID using a
.build-id directory following the standard here:
https://fedoraproject.org/wiki/RolandMcGrath/BuildID

It will look for .build-id directories under paths specified with
--debug-file-directory, which pbtombstone will pass through to
llvm-symbolizer using its own --debug-file-directory flag. The
intent is that tools for platform developers will pass the flag
--debug-file-directory $ANDROID_PRODUCT_OUT/symbols to pbtombstone.
Soong will start creating .build-id under symbols after a corresponding
Soong CL lands.

Bug: 328531087
Change-Id: Ia4676821cf980c69487cf11aefa2a02dc0c1626f
2024-10-30 14:43:25 -07:00
Peter Collingbourne
39a1730a82 Make pbtombstone a host tool.
This is preparation for the next patch, which adds host-side
symbolization capabilities to pbtombstone.

Bug: 328531087
Change-Id: Id5813ae6b121af784643b1ed76084e49fdca118b
2024-10-30 14:42:55 -07:00
Treehugger Robot
07e913e85e Merge "Remove dependencies on the 1-variant fallback" into main 2024-10-23 03:23:18 +00:00
Cole Faust
09c18c17fd Remove dependencies on the 1-variant fallback
When adding a dependencies, if the variants don't match, but the
dependency only has 1 variant anyways, soong will always use that
variant. This makes it hard to add new variants to soong, because the
1-variant fallback stops being used and you start getting missing
variant errors. Make changes to bp files such that all dependencies
correctly specify the variant to use.

Bug: 372091092
Flag: EXEMPT refactor
Test: m nothing
Change-Id: I35a5ac0e6b63080f692be6597edf5f213c4e7acb
2024-10-22 16:33:50 -07:00
Christopher Ferris
3aac36201b Remove log spam.
When dumping, the code checks if a thread is running as a guest.
If it's not, the code always logs an error message if the header
data structure cannot be read. Don't print an error message in
this case.

Test: Crash and no longer see "failed to get the guest state header"
Test: message.
Change-Id: I6971b57b218a4f653682cfdc82118dc576d9e331
2024-10-19 00:25:12 +00:00
Christopher Ferris
cfdfb32d13 Remove define of SA_EXPOSE_TAGBITS.
This is in the uapi headers now.

Test: Builds and treehugger.
Change-Id: I0dcebeec722ae2835a1054ee8b39329cd06799d4
2024-09-19 02:04:16 +00:00
Elliott Hughes
b17d7be2e5 debuggerd: recognize jumps to non-executable memory.
We have fairly fancy detection of stack pointer issues, but nothing for the program counter...

Bug: https://issuetracker.google.com/365602121
Change-Id: I7e7061a1b473089a0f31438df5ebc65b283475bc
2024-09-11 16:23:18 +00:00
Christopher Ferris
469b62a334 Use fallback linker allocator in trace_handler.
There is more than one function that can allocate in the fallback
path. Therefore, make sure that all functions that can allocate have
switched to the fallback linker allocator before allocating. This
is mostly a problem for the trace_handler function call, which iterates
over all known threads and gets backtraces for them.

Add a ScopedUseFallbackAllocator class to do the switching to make it
easier to have the same code everywhere.

Add two tests to verify that no allocations are occuring during
a tombstone or backtrace on the fallback path. These tests are not
comprehensive since they can't verify that the linker allocator is
using the fallback allocator, but they are better than nothing.

Remove the debuggerd_fallback_tombstone() function since it only
enables the linker callback and then calls engrave_tombstone_ucontext().
The enabling is now done with the ScopedUseLinkerAllocator.

Restructure the case where sending the signal to a thread fails so
that the fallback allocator can be enabled properly.

Bug: 359692763

Test: Ran debuggerd -b <PID> and debuggerd <PID> on a process that
Test: goes throught the fallback path.
Test: Unit tests pass along with two new tests.
Test: Forced a fallback process to crash and verified tombstone generated.
Test: Instrumented the linker allocator and verified that the trace_handler
Test: function never calls the normal linker allocator as it runs.
Change-Id: I2710921076634eac97f41bec8c3a29c1d75ae5ec
2024-09-04 01:13:04 +00:00
Christopher Ferris
1e7b7cbc58 Move variable only used on aarch64.
The kTagGranuleSize is only used in aarch64, so you can get
unused variable warnings for other targets. Move this definition
closer to where it's used and in aarch64 code.

Test: Build with unused checking on.
Change-Id: I9baf660430508ee3ca1efb62585ee1b038c6b0f3
2024-08-26 15:30:32 -07:00
Elliott Hughes
4e96338890 host_signal_fixup.h: remove unused file.
We don't need this any more because the glibc headers have been updated, but it looks like it wasn't being used anyway.

Change-Id: Ie98ae473af504c49a8cae07fa06ec7f1568f662d
2024-08-26 12:43:04 +00:00
Florian Mayer
2d75f82aaf Merge "[MTE] write stack history into tombstone" into main 2024-08-21 21:00:41 +00:00
Florian Mayer
e3e7bc7d90 [MTE] write stack history into tombstone
We will change the symbolizer to use this information to output
something like:

Potentially referenced stack object:
  0 bytes inside a stack variable "variableName" in stack frame of function functionName
  at source.cc:1234

Bug: 309446520
Change-Id: I1163ac81ac6b5e184387eb9e058d97a7227e3671
2024-08-20 18:04:01 -07:00
Florian Mayer
3371db1715 Merge "Allow to re-enable MTE a specified time after a permissive fault" into main 2024-08-15 18:33:14 +00:00
Florian Mayer
095f292095 Allow to re-enable MTE a specified time after a permissive fault
The timeout has to be determined experimentally. Generally, it must be
high enough to at least be the next instruction, and can be otherwise as
low as performance reasons allow.

This feature is for debugging only.

Test: atest PermissiveMteTest
Bug: 309604766
Change-Id: I54eff23374ebb239fd75b3b59ae72a7c33654454
2024-08-14 15:02:54 -07:00
Yi Kong
eecb107828 Remove unnecessary std::move
Moving a temporary object prevents copy elision, and could reduce
performance.

This fixes -Wpessimizing-move compiler warning.

Test: presubmit
Bug: 154270751
Change-Id: I4900bcfd14d461f7ded0500eca0a6b386ed59c8f
2024-08-12 18:15:19 +08:00
Christopher Ferris
df5ae06d4c Small clean-up of debuggerd test.
For the debuggerd_test.cpp tests, don't include any libdebuggerd
internal headers.

Test: Compiles and unit tests pass.
Change-Id: I6335dc9e09992f5725a24fc45a8356efab7158e6
2024-08-07 21:29:26 +00:00
Hans Boehm
d9d7f7a8c3 Make timeout messages distinct
... so that we can confirm that it's actually the poll() call that's
timing out.

Bug: 332593241
Test: Treehugger
Change-Id: I529be76a268d7ba1f7f26a953eb84945f3ac4924
2024-07-03 17:33:08 -07:00
Sijie Chen
c438dab75e Merge "[CrashReporting] Correct guest arch init" into main 2024-06-11 20:27:36 +00:00
Sijie Chen
06603fe143 [CrashReporting] Correct guest arch init
Init guest arch to NONE, otherwise Arm32 will be used.

Bug: 288392666
Test: NA
Change-Id: Ib92b0351401b700a18d03e21a68569c2811d163c
2024-06-11 17:51:48 +00:00
Florian Mayer
f2474379e7 Add reserved to CrashDetail proto
Change-Id: I176abc740744907d8559b94b9d1361b44dcbcb14
2024-05-31 22:35:25 +00:00
Sijie Chen
75ed08fb0b [Berberis][CrashReporting] Add riscv case for thread local retrieve
As title.

Bug: 339287219
Test: NA
Change-Id: Ia75659330d1203f4f1fbaf019d41cb72c3986cd4
2024-05-23 17:11:47 +00:00
Treehugger Robot
e77a69d0b1 Merge "No longer require root for PermissiveMteTest" into main 2024-05-20 12:41:30 +00:00
Elliott Hughes
aed74bad41 Remove stray semicolon.
Change-Id: Ic50a84888a7e0c059b4c06716e20e5f120b9b343
2024-05-17 11:31:36 +00:00
Florian Mayer
c4b24f70e6 cleanup: PLOG(FATAL) crashes, does not need else branch
Change-Id: I49a439d444dc9f566a05bab23d8cfd06ce56d4a6
2024-05-16 22:59:16 +00:00
Treehugger Robot
57db6f453c Merge "crasher: hide xom from help when unavailable" into main 2024-05-16 22:36:33 +00:00
Florian Mayer
2df897c1fc No longer require root for PermissiveMteTest
We can now read tombstones as shell user

Change-Id: I2371360e87dc186f37c2d13ebae28b57abe76845
2024-05-16 21:33:51 +00:00
Josh Gao
3a9a989484 crasher: hide xom from help when unavailable
Test: m crasher
Change-Id: Iaf25dd650eb5cf6e8b0933f574b3d4a208b74da9
2024-05-16 13:53:02 -07:00
Sijie Chen
c8027933b3 Reland "[Berberis][CrashReporting] Dump guest thread inf..."
Guest thread information will print out follow host thread.

Revert submission 3081452-revert-3062926-CJGHTRPCBP

Reason for revert: Will make the change base on the original CLs for a reland.

Bug: b/321799516
Test: riscv64, checked tombstone file has wanted block.
https://paste.googleplex.com/6282302317658112
Added arm64 support and tested arm64 unwinding in internal repo.
https://paste.googleplex.com/6545612887818240

Change-Id: Ie54ad6f359d60283442adfcd9ee95f5a116e4b72
2024-05-14 21:28:39 +00:00
Sijie Chen
cb53fe136b Reland "[Berberis][CrashReporting] Extend ThreadInfo to ..."
Revert submission 3081452-revert-3062926-CJGHTRPCBP

Reason for revert: Will make the change base on the original CLs for a reland.

(Original CL commit message)
This CL is to get guest registers information.

Bug: b/321799516
Test: m
Testing for TLS Slot:
Manual testing by: 1. crash the jni tests to produce tombstones file 2.
get the signature field of guest state header 3. verified it is the same
value as NATIVE_BRIDGE_GUEST_STATE_SIGNATURE

Manual test the arm64 by: 1. flash build to pixel phone and verify
retrieving TLS_SLOT_THREAD_ID's tid field is the same as current thread
id.

Testing for register values:
Test and print out registers values for riscv64, looks make sense that
has null zero value slots.

Change-Id: Ieebf845bff517380ee07fac77f24b48efeb53521
2024-05-14 21:28:32 +00:00
Dimitry Ivanov
9fbd7e1026 Merge changes from topic "revert-3062926-CJGHTRPCBP" into main
* changes:
  Revert "[Berberis][CrashReporting] Extend ThreadInfo to have gue..."
  Revert "[Berberis][CrashReporting] Dump guest thread info to tom..."
2024-05-10 16:14:06 +00:00
Dimitry Ivanov
cdf499f9cd Revert "[Berberis][CrashReporting] Extend ThreadInfo to have gue..."
Revert submission 3062926

Reason for revert: We want guest state to be present in all threads - revert to be able to fix the proto field type.

Reverted changes: /q/submissionid:3062926

Change-Id: I32b745cca95a619b78bdce0a7d948ac479d42f21
2024-05-10 10:02:07 +00:00
Dimitry Ivanov
899c1bdfa1 Revert "[Berberis][CrashReporting] Dump guest thread info to tom..."
Revert submission 3062926

Reason for revert: We want guest state to be present in all threads - revert to be able to fix the proto field type.

Reverted changes: /q/submissionid:3062926

Change-Id: I87b282a0d9caebe4eae2e7d8eca8ec8ebaa3eca6
2024-05-10 10:02:07 +00:00
Sijie Chen
a6e1ac8efe Merge changes from topic "berberis-crash-reporting-guest_regs" into main
* changes:
  [Berberis][CrashReporting] Dump guest thread info to tombstone file
  [Berberis][CrashReporting] Extend ThreadInfo to have guest registers
2024-05-09 22:16:44 +00:00
Sijie Chen
4c3a9dfd2f [Berberis][CrashReporting] Dump guest thread info to tombstone file
As title.

Bug: b/321799516
Test: riscv64, checked tombstone file has wanted block.
https://paste.googleplex.com/5958508322750464
Added arm64 support and tested arm64 unwinding in internal repo.
https://paste.googleplex.com/6545612887818240

Change-Id: I4e8a3414d0198de88a577ef4d5672a9ad0286fc5
2024-05-09 20:21:16 +00:00
Sijie Chen
3ff250f6d7 [Berberis][CrashReporting] Extend ThreadInfo to have guest registers
This CL is to get guest registers information.

Bug: b/321799516
Test: m
Testing for TLS Slot:
Manual testing by: 1. crash the jni tests to produce tombstones file 2.
get the signature field of guest state header 3. verified it is the same
value as NATIVE_BRIDGE_GUEST_STATE_SIGNATURE

Manual test the arm64 by: 1. flash build to pixel phone and verify
retrieving TLS_SLOT_THREAD_ID's tid field is the same as current thread
id.

Testing for register values:
Test and print out registers values for riscv64, looks make sense that
has null zero value slots.

Change-Id: Iff44ac5c2b202e44f3fb4e6909fbea141e54ae6b
2024-05-09 18:28:30 +00:00
Christopher Ferris
0455ca3e09 Merge "Clean up usage of 32 bit/64 bit checks." into main 2024-05-08 20:06:18 +00:00
Christopher Ferris
2f77c2a516 Clean up usage of 32 bit/64 bit checks.
Rather than have to create a number of #if defines for the memory
dumping parts of the tombstone, create a single function to generate
these strings for the memory tests.

Make CrasherTest.smoke use a regex that passes on 32 bit and 64 bit.

Make the tests page size agnostic.

Bug: 339017792

Test: Treehugger.
Test: Ran 32 bit and 64 bit versions of tests on a real device.
Test: Ran on the aosp_cf_x86_64_phone_pgagnostic-trunk_staging-userdebug
Change-Id: If9365061b85de23b00a1bf947d85923cde06c068
2024-05-07 15:30:47 -07:00
Devin Moore
87ff7115ef Merge "Add page size info to tombstone" into main 2024-05-07 19:55:51 +00:00
Devin Moore
4647b6b305 Add page size info to tombstone
Now that Android devices can use 16k page size, it's important that we
know what configuration the device is in when see issues.

1) If the device is in 4k mode, we see nothing new.

2) If the device is in 16k mode, we see this line in the tombstones:

Page size: 16

3) If the device is in 4k mode, but was previous in 16k mode we see:

Has been in 16kb mode: yes

Test: atest debuggerd_test
Test: atest debuggerd_test with ro.misctrl.16kb_before="1"
Test: adb shell cat /data/tombstones/tombstone_00
Bug: 335247092
Change-Id: If7ca3b0954a01070ff413758296460ca1d023ca5
2024-05-06 22:20:04 +00:00
Christopher Ferris
94c9cb6447 Merge "Replace malloc_not_svelte with malloc_low_memory." into main 2024-05-06 19:45:05 +00:00
Christopher Ferris
92e3fd78ad Merge "Make sure debuggerd_test is run on device." into main 2024-05-02 21:35:40 +00:00
Xiaohui Niu
7bfbe41714 Fix fallback signal issue.
Add signo for target thread in fallback path;
Update test for seccomp tombstone thread abort.

Bug: 336946834

Test: debuggerd_test
Test: Send fatal signal to process with NO_NEW_PRIVS
Change-Id: Ie9d77a93da9cd89ab7093b8949f311e03d96ec50
2024-04-30 21:22:31 +08:00
Christopher Ferris
1c46a00865 Replace malloc_not_svelte with malloc_low_memory.
The malloc_not_svelte variable name is confusing and makes the
low memory config the default. Change this so that the default is
the regular allocator, and that Malloc_low_memory is used to enable
the low memory allocator.

Update blueprint rules so that scudo is the default action.

Test: Verified scudo config is used by default.
Test: Verfified Android GO config uses the jemalloc low memory config.
Change-Id: Ie7b4b005a6377e2a031bbae979d66b50c8b3bcdb
2024-04-26 13:33:26 -07:00
Christopher Ferris
c76a8937b0 Make sure debuggerd_test is run on device.
Tests starting failing on aarch64, so force presubmit to run the
debuggerd tests on device to close this coverage hole.

Test: Treehugger and verify tests are run on device.
Change-Id: Ie40eab35e46cefd3cebc132d9c0a3d1ebdb0d766
2024-04-25 13:57:52 -07:00
Florian Mayer
2d45331a9e Avoid confusing main_thread name
It is not in fact the main thread of the process, but the thread that crashed

Change-Id: I3af6d0ffc6c0617526a9cbeb36b2a3286aaeb6f6
2024-04-22 23:43:59 +00:00
Florian Mayer
9216490321 Temporarily disable mte_illegal_setjump
Change-Id: I39a770196a79488160b50d7de4c3baa39dd1c57e
2024-04-10 20:24:56 +00:00