Commit graph

181 commits

Author SHA1 Message Date
Florian Mayer
cdf55585a7 Use correct stack depot size in __scudo_get_error
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

Bug: 309446692
Change-Id: Ib64b9d042b2a2088484ec5e61944c089a1d85314
2023-12-13 22:21:19 +00:00
Treehugger Robot
1f5b0f9fee Merge "Handle scudo_stack_depot_size = 0" into main 2023-12-12 01:24:03 +00:00
Florian Mayer
f9566853bd Merge "Use scudo_stack_depot_size from process_info" into main 2023-12-11 23:38:13 +00:00
Siim Sammul
73ade16187 Merge "Move tombstone_proto_to_text out of libdebuggerd." into main 2023-12-06 10:13:18 +00:00
Treehugger Robot
1772cd427c Merge "Match upstream API change" into main 2023-12-06 01:28:10 +00:00
Florian Mayer
6757ecd2a3 Match upstream API change
Change was done in
e68c265543

Change-Id: Id1a288dfdb5edb7cb7d639ec4548926cc4085d8c
2023-12-06 00:16:43 +00:00
Siim Sammul
c08a34e3dc Move tombstone_proto_to_text out of libdebuggerd.
This is done so that we could depend on it elsewhere without needing all the unrelated methods.
Needed for ag/24553347

Bug: 296207744
Test: refactoring build
Change-Id: I7c6733208f3ae63ba9559753a24cffcb8e1b9d1e
2023-12-05 10:14:27 +00:00
Florian Mayer
4841207b53 Handle scudo_stack_depot_size = 0
Bug: 309446692
Change-Id: Ic55294316137847041f1e829cb0243aae8926379
2023-12-04 17:29:23 -08:00
Florian Mayer
e8fcfee409 Use scudo_stack_depot_size from process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

We already did the equivalent change for the ring buffer size in
https://r.android.com/q/topic:%22scudo_ring_buffer_size%22

Bug: 309446692
Change-Id: I761a7602c54a1f8f2d0575c5e011820d8dbaab63
2023-12-04 16:48:45 -08:00
Christopher Ferris
c7cc571fa1 Avoid crashing on bad architecture value.
The only way to get a bad architecture value in the protobuf is if
the data was corrupted or an unsupported architecture was added without
the register support.

If the protobuf is corrupted, this is strictly better since it
still produces a tombstone with the data present.

If there is an unsupported architecture, it will still result in a tombstone,
only the registers would not be present. It would also be very obviously
a problem that needs to be fixed. Again, this is strictly better since
the crash in generation is not necessarily visible unless you look at
the log. Here, the data is in the log and in the tombstone.

This also removes the only dependency in this file on the async_safe
library.

Test: Ran unit tests.
Test: Forced an invalid architecture and verified tombstone is present
Test: with error message, and error message printed in the log.
Change-Id: I8e4a2e3f778fafb5b7241c2f23d5f867f1341ed8
2023-11-17 22:12:14 +00:00
Christopher Ferris
6aa72490dc Add new segv type SEGV_CPERR.
The new 6.6 kernel headers added a new segv type, SEGV_CPERR. Add this
to the switch statement.

Test: Unit tests pass.
Change-Id: I77eb4748e51c7e7d7291bfd2180b0ccb3b5a6ded
2023-10-31 14:01:09 -07:00
Christopher Ferris
3a0833c9cd Fix potential miscellaneous debuggerd issues.
Check for the log opening failing.

Add the ability to put error messages in the log and tombstone so
that it's clear if the log reading failed in some way.

Adjust test so that if there is a log or if no log exists, the test
will still pass.

Print an <unknown> if the command line is unreadable instead of nothing.

Test: Ran unit tests.
Test: Induced error and verified error message is save in tombstone.
Change-Id: I2fce8078573b40b9fed3cd453235f3824cadb5e3
2023-08-09 17:31:55 -07:00
Kelvin Zhang
786dac3d50 Update some fs_mgr/debuggerd to use getpagesize() instead of PAGE_SIZE
Test: th
Bug: 279808236
Change-Id: I9d30cfe19d2b1a7d624cc5425e4315dc6e3b2ad2
2023-06-27 10:50:07 -07:00
Christopher Ferris
98d6242dc7 Limit the number of log messages in a tombstone.
Some testing environments can have a test that is sending many
thousands of messages to the log. When this type of process crashes
all of these log messages are captured and can cause OOM errors
while creating the tombstone.

Added a test to verify the log messages are truncated. Leaving this
test disabled for now since it is inherently flaky due to having to
assume that 500 messages are in the log.

Added a test for a newline in a log message since it's somewhat
related to this change.

NOTE: The total number of messages is capped at 500, but if a message
contains multiple newlines, the total messages will exceed 500.
Counting messages this way seems to be in the spirit of the cap,
that a process logging a large message with multiple newlines does
not completely fill the tombstone log data.

Bug: 269182937
Bug: 282661754

Test: All unit tests pass.
Test: The disabled max_log_messages test passes.
Change-Id: If18e62b29f899c2c4670101b402e37762bffbec6
2023-05-24 20:10:55 +00:00
Christopher Ferris
bda1064160 Re-add code to skip gettings logs on logd crashes.
Also add new unit tests to verify this behavior.

Bug: 276934420

Test: New unit tests pass.
Test: Ran new unit tests without pthread_setname_np call and verified
Test: the tests fail.
Test: Force crash logd and verify log messages are not gathered.
Test: Force crash a logd thread and verify log messages are not gathered.
Change-Id: If8effef68f629432923cdc89e57d28ef5b8b4ce2
2023-04-24 18:31:29 -07:00
Florian Mayer
152de539df Merge "Print number of frames" 2023-04-10 20:59:18 +00:00
Florian Mayer
59e632a292 Print number of frames
liblog can drop data when debuggerd is overloaded, which leads to
truncated tombstones. by adding the count separately, automation can
easily see whether it is dealing with a truncated tombstone or not.

Bug: 269537146
Change-Id: Ia991537efc0d6b57cbff23ee45af6521467aa20d
2023-04-06 23:38:40 +00:00
Elliott Hughes
f9cd73f851 Remove floating point register cruft.
We stopped showing floating point registers years ago, but some cruft
remains.

Test: treehugger
Change-Id: Ib89032db90a31a49d090bc5d99f9c401af734e7a
2023-03-17 00:38:26 +00:00
Christopher Ferris
22035ccb01 Display offset in backtraces if necessary.
When moving to a proto tombstone, backtraces no longer contain
an offset when a frame is in a shared library from an apk.
Add the offset display again if needed, and add a test to
verify this behavior.

Bug: 267341682

Test: All unit tests pass.
Test: Dumped a process running through an apk to verify the offset
Test: is present.
Change-Id: Ib720ccb5bfcc8531d1e407f3d01817e8a0b9128c
2023-01-31 17:53:45 -08:00
Florian Mayer
1d79a07586 [MTE] add link to SAC docs to tombstones
Test: m, flash, look at tombstone
Change-Id: I091d3dc9207d0ba7e692dcc28adc04aec33cf336
2023-01-26 02:09:57 +00:00
Florian Mayer
8b91862b8f [Refactor] move memory map printing to helper
An early return out of this function makes it harder to add new prints
after the memory maps.

Test: m, flash, look at tombstone
Change-Id: Id06e432918d69ac3307761b244473b6b7ab769e8
2023-01-26 01:39:15 +00:00
Florian Mayer
3d11890797 Merge "[MTE] warn about async crashes being imprecise" 2023-01-20 02:12:42 +00:00
Florian Mayer
5fcdfd2504 [MTE] warn about async crashes being imprecise
Bug: 175335730
Change-Id: If666c98b53dee1c63c48887f4448bc54f78a0a9f
2023-01-20 00:33:29 +00:00
Treehugger Robot
a812f45678 Merge "Pass fault address to GWP-ASan's changed API." 2023-01-17 20:29:46 +00:00
Florian Mayer
30a25286c4 Handle scudo_ring_buffer_size = 0
Bug: 263287052
Change-Id: I0bec3a817d7a16c72d5dfeddd0dcc86830f5a311
2023-01-12 16:06:10 -08:00
Mitch Phillips
8a34b179ad Pass fault address to GWP-ASan's changed API.
GWP-ASan changed one of the APIs upstream to now take the fault address
as well. This is to support the recoverable mode.

Add the fault address as well.

Test: gwp_asan_unittest
Bug: N/A
Change-Id: I8a4edd3fad159d91cc036050d330bbb8f9c8d435
2023-01-12 09:48:11 -08:00
Florian Mayer
bd49c387f0 Use scudo_ring_buffer_size from process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the buffer size at process startup time, and as such we will no
longer be able to call __scudo_get_ring_buffer_size in debuggerd.

Bug: 263287052
Change-Id: I350421d1fcdf22ce3b8b73780b88c1e10fa8a074
2023-01-05 15:14:56 -08:00
Christopher Ferris
fac411d97c Remove unnecessary logging.
Test: Extra logging no longers happens.
Change-Id: Ia179ebe5d16e0bde7d6ec66e39d4484ff18f2b1e
2022-10-27 17:56:27 -07:00
Liu Cunyuan
8c0101b971 Add tomstone proto support for riscv64
Signed-off-by: Liu Cunyuan <liucunyuan.lcy@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: Ie22c2895fc30fab68eddc18713c80e403f44b203
2022-10-12 22:31:45 +00:00
Peter Collingbourne
7827991d7f Fix scudo MTE tests.
r.android.com/2108505 was intended to fix a crash in Scudo in
the case where the stack depot, region info or ring buffer were
unreadable. However, it also ended up introducing a number of bugs into
the code. It failed to call __scudo_get_error_info if the page at the
fault address was unreadable. This can happen in legitimate crash cases
if a primary allocation was close to the boundary of a mapped region,
or if the allocation was a secondary allocation with guard pages. It
also used long as the type for tags, whereas Scudo expects it to be
char. In combination this ended up causing most of the MTE tests to
fail. Therefore, mostly revert that change.

Fix the original crash by null checking the pointers returned by
AllocAndReadFully before proceeding with the rest of the function.

Bug: 233720136
Change-Id: I04d70d2abffaa35fe315d15d9224f9b412a9825d
2022-06-30 18:54:19 -07:00
Christopher Ferris
d17cefe7e4 Merge "Fix scudo fault address processing." 2022-06-01 20:20:09 +00:00
Christopher Ferris
7c2e7e31f6 Fix fallback paths for dumping threads.
In the fallback path, if the non-main thread is the target
to be dumped, then no other threads are dumped when creating
a tombstone. Fix this and add unit tests to verify that
this all threads, including the main thread are dumped.

Bug: 234058038

Test: All unit tests pass.
Test: debuggerd -b media.swcodec process
Test: debuggerd media.swcodec process
Change-Id: Ibb75264f7b3847acdbab939a66902d986c0d0e5c
2022-05-27 13:05:56 -07:00
liyong
381b89c8db Fix scudo fault address processing.
The code doesn't properly check if data is not read properly, so
make it fail if reads fail. Also, change the algorithm so that
first try and read the faulting page then 16 pages before and 16
pages after. Rather than trying to read every one of these pages,
stop as soon as one is unreadable. This means that the total memory
passed to the scudo error function is all valid data, rather than
potentially being some uninitialized memory.

Added new unit tests to cover scudo address processing.

Bug: 233720136

Test: All unit tests pass.
Test: atest CtsIncidentHostTestCases
Change-Id: I18a97bdee9a0c44075c1c31ccd1b546d10895be9
2022-05-26 18:50:52 -07:00
Christopher Ferris
3b7b7ba90e Use the new AndroidUnwinder object.
This simplifies most of the calls to avoid doing any Android
specific code.

Bug: 120606663

Test: All unit tests pass.
Change-Id: I511e637b9459a1f052a01e501b134e31d65b5fbe
2022-05-12 15:18:46 -07:00
Mitch Phillips
5411905232 Merge "[GWP-ASan] Enable debuggerd to pull more allocation metadata." 2022-04-21 18:12:43 +00:00
Christopher Ferris
c6d428343c Update for SetProcessMemory removal.
Bug: 120606663

Test: All unit tests pass.
Change-Id: Icf8a3ceb75b8962f8f215501c2bac631b40a1527
2022-04-19 22:06:58 -07:00
Mitch Phillips
1e0969997a [GWP-ASan] Enable debuggerd to pull more allocation metadata.
With the addition of runtime-configurable GWP-ASan, there might be many,
many more than 1,000 allocations. Have support for them, but keep a
hopefully-won't-crash-the-device limit.

Bug: 219651032
Test: atest bionic-unit-tests

Change-Id: I7b8e2bf5ab7c723ab6c61365f0dc610e400dbbce
2022-04-14 11:30:05 -07:00
Christopher Ferris
c95047dd20 Update for accurate unreadable elf files.
The functionality moved from the Unwinder object to the MapInfo
object and means that the individual unreadable files can be
displayed now.

Included adding the unreadable elfs per thread in the protobuf.

Updated the unwinder test.

Test: All unit tests pass.
Change-Id: I7140bde16938736da005f926e10bbdb3dbc0f6f5
2022-03-15 09:50:48 -07:00
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
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