Commit graph

1032 commits

Author SHA1 Message Date
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
Frederick Mayle
56abaa0959 debuggerd: simplify output handling
Just noticed some opportunities while skimming.

Test: adb shell debuggerd $(adb shell pidof com.android.systemui)
Test: All unit tests pass (both 32 bit and 64 bit).
Test: Ran unit tests in a loop hundreds of times.
Change-Id: I428d0cf599ed603a21944b084b95594db893cbd5
2023-05-19 15:19:06 -07:00
Frederick Mayle
52205b8206 debuggerd_client_test: less racy test setup
Make sure that all the threads have started up, otherwise the main part
of the test might not be testing as stressful a situation as expected.
Note that the "race" moniker is still valid because of the debuggerd
timeout.

The test is now faster (405ms) when run under good conditions.

Test: atest 'debuggerd_test:debuggerd_client#race'
Test: Ran debuggerd_client.race 1000 times on its own.
Test: Ran the whole suite of debuggerd unit tests 1000 times.
Change-Id: I487e7654a71df9f1799f09c6f385c929ddf2f234
2023-05-17 12:50:51 -07: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
Kevin Jeon
2a70a7432c Merge "Add pointer dereference in debuggerd error msg" 2023-04-05 22:34:51 +00:00
Kevin Jeon
06af624e66 Add pointer dereference in debuggerd error msg
This change adds a missing pointer dereference to the InterceptResponse
when checking for a size mismatch.

Test: build
Bug: N/A
Change-Id: I88afed6f1c0f33fe237d337b0fb8fc0a0c0e3bac
2023-04-05 16:32:39 -04:00
Treehugger Robot
1c324d3559 Merge "Handle with the nonnull case in a tricky way" 2023-04-01 02:46:24 +00:00
zijunzhao
fa8037c207 Handle with the nonnull case in a tricky way
The func readdir() is not allowed to pass a nullptr.
Bug: b/245972273
Test: mm

Change-Id: Idbb3f552b026dc6d727886d22989d3359ed6633b
2023-03-31 23:50:37 +00:00
Mitch Phillips
5a2a302108 Merge "[debuggerd] New protocol to AM to handle recoverable crashes." 2023-03-29 20:28:35 +00:00
Elliott Hughes
3b1e71c63b Merge "riscv64: fix debuggerd_test build." 2023-03-21 18:56:36 +00:00
Shikha Panwar
e11ab73647 Merge "Add tombstone_handler for crashes in Microdroid" 2023-03-21 18:14:12 +00:00
Elliott Hughes
857e29c356 riscv64: fix debuggerd_test build.
This adds the missing assembler for riscv64, even though I don't have a
working tombstoned yet to test it with. There's a distinct possibility
we'll be back to fix the test (because although "register 1" is harmless
for the other architectures, it's the ra register on riscv64; the default
link register), but at least this lets us build the test.

I've also simplified all the assembly to be the simplest sequence I
know that writes 0 to address 0 (because if there was a reason to use
so many instructions before, I want to know what it is so I can write
the missing comment!).

Test: treehugger
Change-Id: I10d117eaedf361d9759a450e0973d07c4f97090e
2023-03-20 17:48:53 -07:00
Elliott Hughes
7e82c0037b riscv64: fix mips-ism.
r29 is the stack pointer on mips, but it's x2 on riscv64 (and the git
history shows that this was indeed copy & pasted from the mips code)
and since bionic always sets up a signal stack with sigaltstack() I
doubt the comment was relevant even on mips (but no-one ever used it,
so who'd know?).

While I'm here, stop using decimal arithmetic --- the whole point was to
have each register contain the value that was obviously appropriate for
that register. (riscv64's mips-like mess of registers all over the place
means that's not going to be super readable, but there's no reason to
make it worse.)

Also, even though I personally prefer the 0xdead from the old mips code,
everyone else is using 0xa5a5, so let's make riscv64 match the others.

Test: treehugger
Change-Id: Ibbae821bc0a02e07164147d621e342224528c2c9
2023-03-20 16:08:15 -07:00
Elliott Hughes
fa4dd04889 Merge "Fix riscv64's crash glue." 2023-03-20 22:16:50 +00:00
Shikha Panwar
abde59e689 Add tombstone_handler for crashes in Microdroid
This changes the crash export mechanism in Microdroid. For this, we
create module tombstone_handler which exports methods very similar to
tombstoned.h

For Microdroid (detected using prop: ro.hardware): It calls newly
introduces microdroid specific methods to connect/notify completion of
crash.

Individual methods:
connect -> For Android, it would connect to
tombstoned which would send it the fd corresponding to newly created
file on /data/tombstone_ . For Microdroid, we connect to tombstone
server on host via vsock & populate these sockets as the output fd.
crash_dump, in the later case, would directly write on the socket(s).

notify_completion: For Microdroid, it would simply shutdown the vsock
connections.

Note when OS is not Microdroid: It calls corresponding methods of
tombstoned_client, essentially serving as a proxy.

Detailed design: go/vm-tombstone
Test: atest MicrodroidHostTests#testTombstonesAreGeneratedUponUserspaceCrash
Bug: 243494912

Change-Id: I68537b967f2ee48c1647f0f923aa79e8bcc66942
2023-03-20 11:46:09 +00:00
Treehugger Robot
a4aab52663 Merge "Remove floating point register cruft." 2023-03-18 00:15:36 +00:00
Elliott Hughes
d284414786 Fix riscv64's crash glue.
When this was translated to riscv64, someone "fixed" the crashing bugs
that were the whole point of these two functions. Fix them back so they
actually crash, and add the CFI directives.

Test: treehugger
Change-Id: I312c51fa4c893d27b0f4e39383521657a5870a0d
2023-03-17 00:42:15 +00:00
Elliott Hughes
d5c90b0337 Match the arm/arm64 style in the x86/x86-64 files.
Test: treehugger
Change-Id: Id67cfeab293c7530aa1905a39455e8513d51e978
2023-03-17 00:40:26 +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
Mitch Phillips
dd5a80dff5 [debuggerd] New protocol to AM to handle recoverable crashes.
See aosp/2485756 for more details, but this patch introduces a new
protocol between debuggerd and ActivityManager. This new protocol allows
ActivityManager to correctly handle recoverable crashes.

Bug: 270720163
Test: atest CtsGwpAsanTestCases
Change-Id: Icac6262d608dd57a5daf51699064ab28b0c4703f
2023-03-14 16:25:44 -07:00
Christopher Ferris
4761355a54 Fix unwind information for crash assembler.
Test: Crash on arm, arm64, x86, x86_64 and verified full stack is
Test: found in tombstone.
Change-Id: I809ec66d6ce9af378c8e8b04cc1c85b51a61779f
2023-03-13 14:44:22 -07:00
Treehugger Robot
b3bf57dbe9 Merge "Accept SEGV_MTESERR in CrasherTest.mte_async test." 2023-03-09 00:34:39 +00:00
Peter Collingbourne
91e816aa0e Accept SEGV_MTESERR in CrasherTest.mte_async test.
This is possible when upgrading to sync mode.

Change-Id: I71c213cb9ddda87765a0dc2ff5455f0eb7b484fe
2023-03-07 21:27:09 -08:00
zijunzhao
f5e1533f2f Suppress the error warning
Bug: https://android-build.googleplex.com/builds/pending/P51300433/aosp_bramble-userdebug/latest/view/logs/build_error.log
Test: None
Change-Id: I2fbd3d8772c50ed9de1c2ba9eb2234966c7dcb84
2023-03-08 02:40:09 +00:00
Treehugger Robot
a010a27da9 Merge "crash_dump: suggest lldbclient.py rather than gdbclient.py." 2023-03-01 04:00:33 +00:00
Elliott Hughes
5a4e62513f crash_dump: suggest lldbclient.py rather than gdbclient.py.
They're the same script right now, but gdbclient.py is a bit misleading,
even if we're not likely to ever actually remove it.

Test: treehugger
Change-Id: Ic514f98bf13b3e699be4dbad2bafef22d41d9ffd
2023-02-28 22:16:19 +00:00
Mitch Phillips
70aa219034 [gwp-asan] fix tests under clang coverage, and extend invariants
1. Fixes this test under clang coverage, which is run under presubmit
   for TEST_MAPPING files. When we spawn under a minijail, and the
   process exited normally (which is the case for recoverable), clang
   coverage would use atexit handlers to dump some stuff using banned
   prctl's and other syscalls. Instead of allow-listing them all which
   sounds like a huge pain, call _exit() which skips those handlers.

2. Extends the invariant testing to make sure that recoverable GWP-ASan
   recovers both the first time, and a second time in a different slot.

Bug: N/A
Test: CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="*" atest debuggerd_test
Change-Id: I6059e21db4c2898b1c9777a00d2a54497d80ef79
2023-02-22 12:27:37 -08:00
Mitch Phillips
8fe5127027 Recoverable GWP-ASan: Don't tell ActivityManager
Currently, debuggerd tells the teacher that an app that received a fatal
signal. On the playground, dobbing on a process that doesn't actually
need to be killed is considered a friendship-ending move.

Because recoverable GWP-ASan is *supposed* to not crash your app,
suppress this behaviour and don't let ActivityManager know about the
crash.

Bug: N/A
Test: Run a use-after-free in an app that's using recoverable GWP-ASan,
through the 'libc.debug.gwp_asan.recoverable.<app_name>=1' and
'libc.debug.gwp_asan.process_sampling.<app_name>=1' sysprops.

Change-Id: I033ea67d577573df10936e37db7302d4f4bc0069
2023-02-07 17:06:32 -08:00
Mitch Phillips
6e0eb996b3 Merge "Add recoverable GWP-ASan." 2023-02-03 18:35:08 +00:00
Mitch Phillips
18ce54241c Add recoverable GWP-ASan.
Recoverable GWP-ASan is a mode landed upstream in
https://reviews.llvm.org/D140173. For more information about why/what it
is, see
https://android-review.git.corp.google.com/c/platform/bionic/+/2394588.

This patch makes debuggerd call the required libc callbacks for GWP-ASan
to recover from the memory corruption. It also adds the functionality
that libart/sigchain eventually ends up calling, which dumps a GWP-ASan
report for the first error encountered.

Test: Build the platform, run sanitizer-status in recoverable mode,
asserting that it doesn't crash but we get a debuggerd report.
Bug: 247012630

Change-Id: I27212f7250844c20a8fd1e961417cdb4e5bd3626
2023-02-01 15:25:29 -08: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
fe9d83251b Merge "Use scudo_ring_buffer_size from process_info" 2023-01-10 21:23:33 +00:00
Elliott Hughes
c0748f0276 Merge "debuggerd: show syscall in SYS_SECCOMP one-liners." 2023-01-05 23:30:08 +00: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
Elliott Hughes
d32733dbc7 debuggerd: show syscall in SYS_SECCOMP one-liners.
The current logging...
```
F libc    : Fatal signal 31 (SIGSYS), code 1 (SYS_SECCOMP) in tid 6640 (logcat), pid 6640 (logcat)
```
...isn't super useful if crash_dump then fails, because you have no idea
what syscall caused the problem.

We already include the fault address in this line for relevant cases,
so include the syscall number in this case.

Bug: http://b/262391724
Test: treehugger
Change-Id: I45ad7d99c9904bab32b65efeb19be232e59ab3a4
2023-01-05 00:55:38 +00:00
Florian Mayer
c3a7e4862c Merge "static_assert to catch struct mismatches earlier" 2023-01-04 23:46:59 +00:00
Chih-Hung Hsieh
7e575a07be Disable clang-tidy on crash test.
Bug: 263274255
Test: presubmit; make tidy-system-core-debuggerd_subset
Change-Id: I2eb5dcb87894b3282ff19e006f6a0209c9153519
2023-01-03 15:58:29 -08:00
Florian Mayer
ab644a0e6e static_assert to catch struct mismatches earlier
Change-Id: Ia6294c6f8848d0d3d0d7d901e3b78ac3babdf7ac
2022-12-21 17:39:54 -08:00
Elliott Hughes
a27f23e61e Remove an unnecessary #include.
This confused me while doing a code search.

Test: treehugger
Change-Id: Ic8d63a3f5b8efb8557d0033d458f5265762da716
2022-12-13 17:08:24 +00:00
Chih-Hung Hsieh
3ec1e81425 Suppress clang-tidy on crasher.cpp
* Intentional crash test code with null/free/escape warnings.

Test: make tidy-system-core-debuggerd_subset
Change-Id: Ib1255c17a374729c82aa246c6a59156dbc4e1b77
2022-12-05 11:28:40 -08:00
Elliott Hughes
2f883314b9 riscv64 doesn't require a 32-bit crash dump policy.
Test: `mm -j` in bionic
Change-Id: I6c2e91b540f544b1ca428692ebfb25697b0cb6e4
2022-11-14 20:06:16 +00:00
Treehugger Robot
da644317e3 Merge "Clean up some unneeded non-neon support." 2022-10-31 18:51:46 +00:00
Elliott Hughes
7a30483996 Clean up some unneeded non-neon support.
It's 2022.

Test: treehugger
Change-Id: If7feede199545cf36ae4759b635a56d1421e505f
2022-10-31 15:38:01 +00:00
Treehugger Robot
cb881e7cf0 Merge "Add riscv support for heap_addr_in_register" 2022-10-29 18:23:31 +00:00
haocheng.zy@linux.alibaba.com
3f4d036cb6 Add riscv support for heap_addr_in_register
Change-Id: I42a93a96c8c9c7a32d32674535ff466380e3c2fa
Signed-off-by: haocheng.zy <haocheng.zy@linux.alibaba.com>
2022-10-29 14:57:23 +00:00
Christopher Ferris
fac411d97c Remove unnecessary logging.
Test: Extra logging no longers happens.
Change-Id: Ia179ebe5d16e0bde7d6ec66e39d4484ff18f2b1e
2022-10-27 17:56:27 -07:00
Nikita Ioffe
75be784fba Switch to tombstoned.microdroid
The long term plan is to completely remove tombstoned from microdroid (b/243494912), however it might take time some time to implement it.

In the meantime, we've recently removed cgroups support from the microdroid kernel. This means that starting a tombstoned results in a bunch of non-fatal errors in the logs that are related to the fact that tombstoned service specifies task_profiles.

To get rid of these error messages we temporary add a microdroid variant of the tombstoned (tombstoned.microdroid) that doesn't specify task_profiles.

Bug: 239367015
Test: microdroid presubmit
Change-Id: Ia7d37ede2276790008702e48fdfaf37f4c1fd251
2022-10-24 15:56:33 +00:00
Elliott Hughes
356e83b23f riscv64 has no "other" to need an sepolicy.
Fixes
```
out/soong/installs-aosp_riscv64.mk:56833: error: overriding commands for target `out/target/product/generic_riscv64/system/etc/seccomp_policy/crash_dump.riscv64.policy', previously defined at out/soong/installs-aosp_riscv64.mk:56829
```

Test: m
Change-Id: I78a1c6b10dac2da704515f33b492ff37cc086dd6
2022-10-17 21:42:32 +00:00
Evgenii Stepanov
4a93612db3 Merge "Harden CrasherTest::Trap under sanitizers." 2022-10-17 20:47:31 +00:00
Evgenii Stepanov
361455eb37 Harden CrasherTest::Trap under sanitizers.
The use of __builtin_abort in CrasherTest::Trap breaks with
-ftrap-function=abort, because then the argument of Trap is no longer in
the first argument register at the time of crash.

This flag is added when *any* sanitizer is enabled on the target, even harmless
ones like memtag-heap. See sanitize.go:769.

Fix CrasherTest::Trap to be a little more reliable.

Test: debuggerd_test with SANITIZE_TARGET=memtag_heap
Change-Id: I150f1c0355bd6f2bfabfa5a7bba125acdde1120e
2022-10-13 16:40:05 -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
Chen Guoyin
a22af66e4b Add seccomp policy for riscv64 crash_dump
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: Ie58bd7cf5dde792d8fba78602b5f53471752ab24
2022-10-12 22:31:39 +00:00
Xia Lifang
b13a10bb5d Add riscv64 support for debuggerd/crasher
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: I521c6da61cf2f6f67a73febf368068c430d94cdb
2022-10-12 22:30:27 +00:00
Florian Mayer
7a6079000c [MTE] add device config for permissive mode
Change-Id: Ifb16c0f29f07870f59ab50522d010689ee232de8
2022-10-03 09:58:39 -07:00
Florian Mayer
1ee1567b93 Merge "Do not use GetBoolProperty in signal handler" 2022-09-16 21:31:12 +00:00
Florian Mayer
094917deb7 Do not use GetBoolProperty in signal handler
This uses an std::string, which causes a heap allocation, which is not
async-safe.

Test: atest --no-bazel-mode permissive_mte_test
Change-Id: I4bd53d42d9a6a659abe62a964f14c81d9ec059d0
2022-09-16 12:01:40 -07:00
Elliott Hughes
b795d6fa4b Fix the build with a newer LLVM.
Unify all our "noinline" variants to the current most common one, not
least because the new [[noinline]] syntax is fussier about where it goes.

Test: treehugger
Change-Id: Icfcb75c9d687f0f05c19f66ee778fd8962519436
2022-09-14 20:16:25 +00:00
Florian Mayer
565305b852 Merge "[MTE] only upgrade to SYNC mode for MTE crashes" 2022-09-14 01:22:45 +00:00
Florian Mayer
d705c2dbcd [MTE] only upgrade to SYNC mode for MTE crashes
Bug: 244471804
Test: atest mte_ugprade_test on emulator
Change-Id: Ie974cf2dec96267012f1b01b9a40dad86551b1be
2022-09-13 15:35:07 -07:00
Elliott Hughes
df2e7eb3cc Explain how to get a tombstone proto.
There's a link here from the javadoc, but a link to the javadoc from
here seems like a good idea.

Test: N/A
Change-Id: I89a29f72d086d08174e72f7d0aa0421fe417f733
2022-09-12 22:24:18 +00:00
Alessandra Loro
7bd6dca855 Resolve ro.debuggable at build time
Test: n/a
Bug: 243645021

Change-Id: I42c4b1e81383d83c73a565c5e74ac22f17389faf
2022-09-01 13:32:36 +00:00
Jiyong Park
eb769d687a Use liblog_for_runtime_apex instead of liblog
liblog_for_runtime_apex is a static variant of liblog which is
explicitly marked as available to the runtime APEX. Any static
dependency to liblog from inside the runtime APEX is changed from liblog
to liblog_for_runtime_apex.

Previously, to support the need for using liblog inside the runtime
APEX, the entire (i.e. both static and shared variants) liblog module
was marked as available to the runtime APEX, although in reality only
the static variant of the library was needed there. This was not only
looking dirty, but also has caused a problem like b/241259844.

To fix this, liblog is separated into two parts. (1) liblog and (2)
liblog_for_runtime_apex. (1) no longer is available to the runtime APEX
and is intended to be depended on in most cases: either from the
non-updatable platform, or from other APEXes. (2) is a static library
which is explicitly marked as available to the runtime APEX and also
visible to certain modules that are included in the runtime APEX.

Bug: 241259844
Test: m and check that liblog depends on stub library of libc
Change-Id: I10edd4487a6f090ef026acffe1ffbd067387a0d3
2022-08-19 13:21:02 +09:00
Peter Collingbourne
73583331a0 Merge "Fix scudo MTE tests." 2022-07-01 17:09:55 +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
Bob Badour
453d3e4924 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  debuggerd/test_permissive_mte/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: Ic48cf8a972147eba8a955136be74204c013ca436
2022-06-16 10:01:01 -07:00
Florian Mayer
514c41c6e2 Merge "Add permissive MTE mode." 2022-06-15 16:58:25 +00: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
Florian Mayer
a8aa25da01 Add permissive MTE mode.
This is not meant to be enabled long-term, but can be used to assess system
stability with MTE before enabling it.

Bug: 202037138
Change-Id: I9fb9b63ff94da2de0a814fd7150f51559d3af079
2022-05-25 16:25:52 -07:00
Christopher Ferris
303c6bef77 Fix check for thread unwind.
If a process requires executing fallback unwinder and the thread
crashing is not the main thread, the wrong unwinder is used.
Fix this case, and add a new unit test that causes an abort in
the non main thread.

Bug: 233721755

Test: New unit test passes with fix and fails without.
Test: Ran debuggerd on swcodec process and it still dumps all threads.
Change-Id: I70fffc5d680256ce867e7a1d427593b584259160
Merged-In: I70fffc5d680256ce867e7a1d427593b584259160
(cherry picked from commit 2d5d46ca85)
2022-05-25 13:07:07 -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
Florian Mayer
378969f949 Add hwasan presubmit for debuggerd.
Change-Id: Ic6b27b89470f4e8fb21dd29f8a8f486b528bdedc
2022-04-18 20:27:52 +00:00
Florian Mayer
b4979293b3 Skip debuggerd tests that do not apply to HWASan.
Change-Id: Ieab61dc61e11c3e55f116a45c37ceb805a6212e0
2022-04-15 15:41:59 -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
4f600fe073 Add two new crash commands.
One is intentionally seeting the abort message. The other is to set
the abort message to null.

Also, make the libseccomp_policy static so that the crasher
executable can be copied to the system afterwards without
requiring libseccomp_policy.so.

Test: Ran both new crash commands on device.
Test: Ran the seccomp crash command to verify seccomp still works.
Change-Id: I255b5f37e6eb188719e5b72302ca3f5911c8d821
2022-04-13 16:38:16 -07:00
Shikha Panwar
757f299842 Make some debuggerd libraries available in apex com.android.virt
Test: Build passed & tested the whole topic
Bug:227443903

Change-Id: I113cd1e559307e191fec405206f23e1b4ce1a5fc
2022-04-05 15:55:16 +00:00
Treehugger Robot
fad82b6c15 Merge "Add Rust wrapper for tombstoned client using cxx." 2022-04-04 22:38:40 +00:00
Andrew Walbran
3b7591248d Add Rust wrapper for tombstoned client using cxx.
Bug: 226162295
Test: atest libtombstoned_client_rust_test
Change-Id: Ibe7c41e2381f0f369a76175d6f71fc60b71cc7d5
2022-03-30 14:17:55 +00:00
Ray Essick
926f753e20 Symbolic constants for older minijails
Inline definitions of a few constants that don't appear on Q/R devices,
so that this works for us in mainline modules that are loaded on those
older devices.

Bug: 225406881
Test: boot on Q, watch logcat
Test: boot on R, watch logcat
Change-Id: Ic5781976d4c1e2d16e230c015fc49d9fde74e289
2022-03-21 16:31:00 -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
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
Mitch Phillips
78f0670dda [MTE] Print cause and alloc/dealloc traces to logcat.
This information clearly meets the bar for being dumped to logcat. If we
omit the info, we may confuse the user into thinking that it's not
available at all, especially if it's their first time seeing an MTE
report.

This also adds some functionality to the integration testing library to
pull logcat messages and scan them to make sure the contents are in both
places.

Bug: 187881237
Test: atest debuggerd_test # on QEMU w/ MTE.
Change-Id: Icc17ea45bda7628331cc4812eaad3bc5c949b7a7
2021-06-01 18:12:22 -07:00
Treehugger Robot
83361ae6fc Merge "tombstoned: fix file creation for ANRs." 2021-05-19 00:33:54 +00:00
Josh Gao
931274862f tombstoned: fix file creation for ANRs.
Bug: http://b/188315622
Test: manual
Change-Id: I2948b929beb3093b59c8d37b706c857e7422a3cc
2021-05-18 16:20:00 -07:00
Peter Collingbourne
93406da189 Merge "Run MTE tests on zero-sized allocations." 2021-05-14 03:58:13 +00:00
Treehugger Robot
a9d1799d3f Merge "Add missing //apex_available:platform to debuggerd" 2021-05-14 01:34:03 +00:00
Peter Collingbourne
aa544796ae Run MTE tests on zero-sized allocations.
Bug: 187879470
Change-Id: I9547f3032af9d1a921f8597a53389d25af33b369
2021-05-13 14:08:41 -07:00
David Srbecky
1cbdc2a530 Merge "Update API of MapInfo from libunwindstack" 2021-05-13 09:49:52 +00:00
Peter Collingbourne
fc7852b741 Merge "Test that out-of-bounds UAF is not detected with MTE." 2021-05-13 02:53:23 +00:00