Commit graph

1025 commits

Author SHA1 Message Date
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
David Srbecky
d8ab48b4db Update API of MapInfo from libunwindstack
Use accessors to for all the fields.

Test: build
Change-Id: I68d149d914d4a4b088aaf822fe222a5d9e56ae80
2021-05-13 01:51:58 +01:00
Peter Collingbourne
dc47634ec4 Test that out-of-bounds UAF is not detected with MTE.
This type of error is unlikely and attempting to detect it with MTE
is likely to produce false positive reports. Make sure that this type
of error is not detected by the allocator.

Change-Id: I90676d1a031411d6b725890311317802bc24b459
2021-05-12 15:56:43 -07:00
Paul Duffin
69caa70145 Add missing //apex_available:platform to debuggerd
This does not currently cause any problems but it does block progress
on the referenced bugs.

Bug: 187910671
Bug: 187914588
Test: m droid
Change-Id: I977cd842101187441ddbc873eac25598295aab06
2021-05-12 11:22:55 +01:00
Christopher Ferris
fe751c5a61 Re-add backtrace note about unreadable elf.
When moving to the proto-ized tombstones, the note about unreadable
elf files in a backtrace got lost. This re-adds it and adds a test
to verify that the note properly shows up.

Bug: 185428454

Test: Ran unit tests.
Change-Id: I1150cc737772e1b79fd73ec5c782caadc4629421
2021-05-03 15:21:11 -07:00
Christopher Ferris
6702256e0c Allow another prctl call.
A change was made so that pthread_create is calling
prctl(PR_PAC_RESET_KEYS, ...) on aarch64. It's possible that other
seccomp policies might need to change to allow this.

Test: CrasherTest.seccomp_backtrace passes on aarch64.
Change-Id: I9c4d1b3dca5f19a6285bf904bb942f1f52e42bd0
2021-04-16 13:35:16 -07:00
Josh Gao
007d7941c8 Merge "debuggerd: store commandline instead of process name." 2021-03-31 08:29:54 +00:00
Josh Gao
31348a74e0 debuggerd: store commandline instead of process name.
Bug: http://b/180605583
Test: debuggerd_test
Change-Id: I018d399a5460f357766dc1b429f645f78fe88565
2021-03-30 12:15:56 -07:00
David Srbecky
847b2a371f Adjust libunwindstack MapInfo API
Test: m debuggerd_test
Change-Id: I63a2379bad3ace4755ae48bf0a83eaa0070f9077
2021-03-23 23:20:37 +00:00
Josh Gao
777148f9f2 Merge "libdebuggerd: store process uptime." 2021-03-23 06:46:05 +00:00
Peter Collingbourne
f4a40c0edd Merge "Support MTE and GWP-ASan features in proto tombstones." 2021-03-19 23:42:23 +00:00
Peter Collingbourne
d0f5eb5716 Merge "[GWP-ASan] Add debuggerd end-to-end tests and remove unique wording." 2021-03-19 23:42:23 +00:00
Treehugger Robot
15ab143bea Merge "debuggerd: prepare to abandon ship^Wgdb." 2021-03-18 13:35:50 +00:00
Peter Collingbourne
d9bb7106bc Merge "Add support for a hw_timeout_multiplier system property." 2021-03-17 18:18:51 +00:00
Elliott Hughes
e4781d54a5 debuggerd: prepare to abandon ship^Wgdb.
Talk of "gdb" when we currently mean "gdb or lldb" and will soon mean
"lldb" is starting to confuse people. Let's use the more neutral
"debugger" in places where it really doesn't matter.

The switch from gdbclient.py to lldbclient.py is a change for another
day...

Test: treehugger
Change-Id: If39ca7e1cdf4c8bb9475f1791cdaf201fbea50e0
2021-03-17 10:03:25 -07:00
Pirama Arumuga Nainar
bb03b3626f Merge "Ignore deliberate free() of non-heap memory" 2021-03-17 03:56:07 +00:00
Pirama Arumuga Nainar
982e2a5018 Ignore deliberate free() of non-heap memory
Bug: http://b/181927912

Clang already has -Wfree-nonheap-object but it became a default warning
with clang-r416183

Test: compile crasher.cpp
Change-Id: Ice532e9f373a628e07acd08a4fc7bfa7cf5d4e08
2021-03-16 18:16:15 -07:00
Elliott Hughes
b68b07391a debuggerd: remove unused file.
Test: treehugger
Change-Id: I17f5f88e91be3dccbf01b93ca93b0879a997bb4d
2021-03-16 17:35:33 -07:00
Peter Collingbourne
1a1f7d79a4 Support MTE and GWP-ASan features in proto tombstones.
Proto tombstones were missing tagged fault addresses, tagged_addr_ctrl,
tags in memory dumps and Scudo and GWP-ASan error reports. Since text
tombstones now go via protos, all of these features broke when we
switched to text tombstones generated from protos by default. Fix
the features by adding support for them to the proto format,
tombstone_proto and tombstone_proto_to_text.

Bug: 135772972
Bug: 182489365
Change-Id: I3ca854546c38755b1f6410a1f6198a44d25ed1c5
2021-03-16 10:59:39 -07:00
Mitch Phillips
7168a217b9 [GWP-ASan] Add debuggerd end-to-end tests and remove unique wording.
Looks like we unintentionally had a breakage after aosp/1595302, where
both GWP-ASan and MTE tests started failing because the extra
information wasn't plumbed through the tombstones. MTE has end-to-end
tests but aren't run continuously, and GWP-ASan was missing the e2e
tests.

Also remove some unique wording for GWP-ASan, a UaF on the free'd
pointer is now "0 bytes into a 16-byte allocation" instead of "on a
16-byte allocation". The former is more descriptive and is more
ubiquitously used in our tooling.

This patch adds the E2E tests, but the underlying problem needs to be
fixed as well, before this patch can land.

Bug: 182489365
Test: atest debuggerd_test
Change-Id: I0fe8aba7ea443b3071724987f46b19a6525cda3c
2021-03-11 15:56:35 -08:00
Peter Collingbourne
fb5eac9445 Add support for a hw_timeout_multiplier system property.
In order to test the platform in emulators that are orders of magnitude
slower than real hardware we need to be able to avoid hitting timeouts
that prevent it from coming up properly. For this purpose introduce
a system property, ro.hw_timeout_multiplier, which may be set to
an integer value that acts as a multiplier for various timeouts on
the system.

Bug: 178231152
Change-Id: I6d7710beed0c4c5b1720e74e7abe3a586778c678
Merged-In: I6d7710beed0c4c5b1720e74e7abe3a586778c678
2021-03-11 14:04:18 -08:00
Peter Collingbourne
90947d442c Merge "Teach debuggerd to pass the secondary ring buffer to __scudo_get_error_info()." 2021-03-11 01:15:49 +00:00
Treehugger Robot
3f24fefe29 Merge "Untag addresses in registers before looking up the mapping." 2021-03-06 02:41:05 +00:00
Josh Gao
dbb83de0d5 libdebuggerd: store process uptime.
Application developers would like to know how long their process has
been alive for to distinguish between crashes that happen immediately
upon startup and crashes in regular operation.

Test: manual
Change-Id: Ia31eeadfcced358b478c7a7c7bb2e8a0252e30f4
2021-03-01 23:45:29 -08:00
Josh Gao
8b0a9e06ba libdebuggerd: delete unused code.
Test: none
Change-Id: I87b62f306d287e9356c639f6d0c49566c71f7f29
2021-03-01 23:07:40 -08:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Christopher Ferris
d57652f15b Merge "Update for new kernel 5.11 headers." 2021-02-19 19:47:44 +00:00
Christopher Ferris
a4807cba22 Merge "Don't hard-code number of tombstones." 2021-02-19 17:46:54 +00:00
Josh Gao
3be68745ae Generate text tombstones from proto tombstones by default.
We're running into timeouts from death tests because we're ~doubling the
cost of crash dumping by doing it twice.

Bug: http://b/180605583
Test: treehugger
Change-Id: If5b40434171323a09960b70af0124ec08bd3fbe8
2021-02-18 16:57:53 -08:00
Christopher Ferris
35da288199 Don't hard-code number of tombstones.
On cuttlefish, the number of tombstones allowed is much larger
than 50, so change the algorithm to search for any tombstone
file.

Test: Ran unit tests on cuttlefish with > 50 tombstones.
Test: Ran unit tests on device.
Change-Id: Ia1d885fe19a7f7751fe3386d40b48750d1e21bd5
2021-02-18 15:29:13 -08:00
Christopher Ferris
95b026f976 Update for new kernel 5.11 headers.
Add new SYS_USER_DISPATCH to SIGSYS case.

Test: Builds, unit tests pass.
Change-Id: Id470053c167d7ffe51d622356c867815cd773fbc
2021-02-18 11:59:11 -08:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Peter Collingbourne
bb4b49c63c Teach debuggerd to pass the secondary ring buffer to __scudo_get_error_info().
With this change we can report memory errors involving secondary
allocations. Update the existing crasher tests to also test
UAF/overflow/underflow on allocations with sizes sufficient to trigger
the secondary allocator.

Bug: 135772972
Change-Id: Ic8925c1f18621a8f272e26d5630e5d11d6d34d38
2021-02-12 12:30:52 -08:00
Josh Gao
517d64f0c6 Merge "tombstone.proto: reserve numbers for future growth." 2021-02-12 02:58:17 +00:00
Josh Gao
fc4fb216d1 tombstone.proto: reserve numbers for future growth.
Test: treehugger
Change-Id: I66adbe70e95363b0083d6eed746de3bc6d17ae28
2021-02-10 16:59:50 -08:00
Mitch Phillips
2aaad2a696 [GWP-ASan] Update metadata field name.
Bug: N/A
Test: Build succeeds.
Change-Id: I889fbc6722695c9c738352c174c8817548a0faa1
2021-02-10 11:38:28 -08:00
Treehugger Robot
4abe7c4165 Merge "Unlink the tombstone proto file before linking the temporary fd." 2021-02-08 19:23:44 +00:00
Peter Collingbourne
1e1d920785 Unlink the tombstone proto file before linking the temporary fd.
We were already doing this for the text tombstones but not for protos,
which meant that we stopped producing protos once we hit the limit
on the number of tombstones. Move the code for the text tombstones
into a common location and call it for both types.

Change-Id: I4951150da51a32d50821d147458fc5c18200c9d4
2021-02-05 16:41:48 -08:00
Peter Collingbourne
0ea08c2f0b Untag addresses in registers before looking up the mapping.
Otherwise we can fail to find map entries for tagged addresses,
such as those of heap objects.

Bug: 135772972
Change-Id: Ia626b0587c8461eb575b2de5c08562c73ba4a66e
2021-02-05 15:01:12 -08:00
Josh Gao
3a2f885ec6 Merge "Let system_server truncate tombstones." 2021-02-05 20:35:19 +00:00
Josh Gao
4b24f09124 Merge "Expose libtombstone_proto srcs." 2021-02-04 02:43:10 +00:00
Peter Collingbourne
939d074236 Fix CrasherTest.smoke in debuggerd_test.
Now that we default to sync MTE in tests, the default tagged_addr_ctrl
in this test needs to be updated.

Bug: 135772972
Change-Id: I9bf6fb29df9799d1ed8c0d8b66f4d2891f487d80
2021-02-02 19:00:48 -08:00
Josh Gao
88846a2ccf Let system_server truncate tombstones.
There's no way to atomically unlink a specific file for which we have an fd from
a path, which means that we can't safely delete a tombstone without coordination
with tombstoned, which is risky. For example, if we use flock on the directory,
and system_server crashes while holding the lock, we risk deadlock.

We do the next best thing, and keep a file descriptor around for every
tombstone, and truncate it, which requires system_server to be able to
write to tombstones (which are owned by the system group).

Test: treehugger
Change-Id: I6ba7f1fe87ee1a4b57bdb3741e8ec9fbc80788c9
2021-02-01 17:48:58 -08:00
Josh Gao
d3df0ae39d Expose libtombstone_proto srcs.
Test: treehugger
Change-Id: I4f993e6bf025120bda82eb60f6c534f43030085c
2021-02-01 17:43:18 -08:00
Evgenii Stepanov
2a55e1adbe Scale timeouts in debuggerd and llkd.
Respect ro.timeout_multiplier property. Some of these are required for
tombstone writing to work on MTE QEMU, the rest are done speculatively.

Test: add crashing code to system_server, observe the tombstone
Bug: 178231152
Change-Id: Ic86e494af571301df7af07d13a6c046a0da6bda7
2021-02-01 20:00:53 +00:00
Josh Gao
618cea3ebd Remove use of libbase logging in libdebuggerd.
libbase logging uses getprogname() to get the default tag, which breaks
for the fallback handler which is statically linked into the dynamic
linker. Switch to libasync_safe for logging.

Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls
Change-Id: Ieeaf33fb26cff4ba7e1589d1d883ac2fcc74cf47
2021-01-27 15:52:43 -08:00
Josh Gao
76e1e30f16 Reland protobuf tombstones.
This reverts the following commits:
    e156ede145.
    eda96eddcb.
    5ec54d1e84.
    1e45d3f223.
    a50f61f8fa.

Test: treehugger
Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls
Change-Id: Ic2b1f489ac9f1fec7d7a33c845c29891f4306bbd
2021-01-26 17:55:17 -08:00
Jerome Gaillard
e156ede145 Revert "tombstoned: switch from goto to RAII."
Revert "Let crash_dump read /proc/$PID."

Revert submission 1556807-tombstone_proto

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Reverted Changes:
Ide6811297:tombstoned: switch from goto to RAII.
I8d285c4b4:tombstoned: make it easier to add more types of ou...
Id0f0fa285:tombstoned: support for protobuf fds.
I6be6082ab:Let crash_dump read /proc/$PID.
Id812ca390:Make protobuf vendor_ramdisk_available.
Ieeece6e6d:libdebuggerd: add protobuf implementation.

Change-Id: I8a77f6b9e1b42902ef7ee250cc3f1fd341ea0e2b
2021-01-26 12:42:09 +00:00
Jerome Gaillard
eda96eddcb Revert "tombstoned: make it easier to add more types of outputs."
Revert "Let crash_dump read /proc/$PID."

Revert submission 1556807-tombstone_proto

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Reverted Changes:
Ide6811297:tombstoned: switch from goto to RAII.
I8d285c4b4:tombstoned: make it easier to add more types of ou...
Id0f0fa285:tombstoned: support for protobuf fds.
I6be6082ab:Let crash_dump read /proc/$PID.
Id812ca390:Make protobuf vendor_ramdisk_available.
Ieeece6e6d:libdebuggerd: add protobuf implementation.

Change-Id: Ib2403c1b61f6cf0513b76361440fbc5909d7554a
2021-01-26 12:42:03 +00:00
Jerome Gaillard
5ec54d1e84 Revert "tombstoned: support for protobuf fds."
Revert "Let crash_dump read /proc/$PID."

Revert submission 1556807-tombstone_proto

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Reverted Changes:
Ide6811297:tombstoned: switch from goto to RAII.
I8d285c4b4:tombstoned: make it easier to add more types of ou...
Id0f0fa285:tombstoned: support for protobuf fds.
I6be6082ab:Let crash_dump read /proc/$PID.
Id812ca390:Make protobuf vendor_ramdisk_available.
Ieeece6e6d:libdebuggerd: add protobuf implementation.

Change-Id: I0c4f3a17e8b06d6c65255388c571ebf11d371dbb
2021-01-26 12:41:52 +00:00
Jerome Gaillard
1e45d3f223 Revert "libdebuggerd: add protobuf implementation."
Revert "Let crash_dump read /proc/$PID."

Revert submission 1556807-tombstone_proto

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Reverted Changes:
Ide6811297:tombstoned: switch from goto to RAII.
I8d285c4b4:tombstoned: make it easier to add more types of ou...
Id0f0fa285:tombstoned: support for protobuf fds.
I6be6082ab:Let crash_dump read /proc/$PID.
Id812ca390:Make protobuf vendor_ramdisk_available.
Ieeece6e6d:libdebuggerd: add protobuf implementation.

Change-Id: Ia0a1ee57e7630e01c495dc166218f665340aad7f
2021-01-26 12:41:20 +00:00
Jerome Gaillard
a50f61f8fa Revert "Fix build breakage."
This reverts commit 675cb30f05.

Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug

Change-Id: I82d228f2bc3e6b426d4703732e1c8766815ccc97
2021-01-26 12:40:51 +00:00
Josh Gao
675cb30f05 Fix build breakage.
Test: mma
Test: treehugger
Change-Id: I2d08c9b6e7776e69ca1e7f0d83838830f3c9b15c
2021-01-25 15:11:49 -08:00
Josh Gao
6bf6a9fc61 Merge changes from topic "tombstone_proto"
* changes:
  libdebuggerd: add protobuf implementation.
  tombstoned: support for protobuf fds.
  tombstoned: make it easier to add more types of outputs.
  tombstoned: switch from goto to RAII.
2021-01-25 22:18:48 +00:00
Mitch Phillips
1d792bf90a Merge "[MTE] Cleanup tagged si_addr refs to fix mappings OOB bug." 2021-01-25 17:20:40 +00:00
Mitch Phillips
e4adff0721 [MTE] Cleanup tagged si_addr refs to fix mappings OOB bug.
Currently, all MTE failures end up displaying 'Fault address falls at
0x<addr> after any mapped regions'. Clearly when scanning, we should use
the untagged address to figure out which ranges it's in.

I've taken the liberty of removing all si_addr parsing and moving it
into the common ProcessInfo, as well as making it really explicit
whether you want the (possibly tagged) original si_addr, or whether you
want the untagged variant (for scanning /proc/maps or whatever).

This is not particularly easily testable, as ReadCrashInfo isn't easily
injectable and `dump_all_maps` should already be passed the untagged
pointer to scan for. I've tested this locally on FVP under SYNC MTE with
a simple UaF binary and noted the problem is fixed. Given that this is
making the code more clear, I'm hoping the owners see no need for a
regression test :).

Bug: 135772972
Test: On FVP, run 'adb shell MEMTAG_OPTIONS=sync sanitizer-status' and
      check that the use-after-free test ends up with the /proc/maps
      desription in the right place.
Change-Id: I220e4200c75a72474a95a67e5bbc36173a438dd2
2021-01-21 20:49:06 -08:00
Josh Gao
92317d82c9 libdebuggerd: add protobuf implementation.
This commit implements protobuf output for tombstones, along with a
translator that should emit bytewise identical output to the existing
tombstone dumping code, except for ancillary data from GWP-ASan and
Scudo, which haven't been implemented yet.

Test: setprop debug.debuggerd.translate.translate_proto_to_text 1 &&
        /data/nativetest64/debuggerd_test/debuggerd_test
Test: for TOMBSTONE in /data/tombstones/tombstone_??; do
        pbtombstone $TOMBSTONE.pb | diff $TOMBSTONE -
      done
Change-Id: Ieeece6e6d1c26eb608b00ec24e2e725e161c8c92
2021-01-21 15:40:23 -08:00
Elliott Hughes
d8af5b5e4f Remove unnecessary #includes.
Sadly, it looks like we do still really use libcutils for some of the
socket functions.

Test: treehugger
Change-Id: Ic71f97507c89b10d2f3b7a2971064a9e6b1d349d
2021-01-19 09:21:52 -08:00
Elliott Hughes
03b283a65f Move debuggerd_test over to mallopt().
Bug: http://b/135772972
Test: treehugger
Change-Id: I178f2a753b5608d9e72cee8874524ad4faf701d7
2021-01-15 11:34:26 -08:00
Josh Gao
1091d24c16 tombstoned: support for protobuf fds.
Test: debuggerd_test
Change-Id: Id0f0fa2856e4b8e57d7dc0e1495134e943b289da
2021-01-13 13:35:45 -08:00
Josh Gao
e2aa621c83 tombstoned: make it easier to add more types of outputs.
While we're at it, switch to unlinkat.

Test: debuggerd_test
Change-Id: I8d285c4b4e94effa1acb8f69ac3af4ff8c37defb
2021-01-13 13:35:45 -08:00
Josh Gao
9a61f685d8 tombstoned: switch from goto to RAII.
Test: debuggerd_test
Change-Id: Ide6811297bf59776619aac6ed96653ae5cc84040
2021-01-13 13:35:45 -08:00
Peter Collingbourne
cd27807bfe Remove ANDROID_EXPERIMENTAL_MTE.
Now that the feature guarded by this flag has landed in Linux 5.10
we no longer need the flag, so we can remove it.

Bug: 135772972
Change-Id: I02fa50848cbd0486c23c8a229bb8f1ab5dd5a56f
2021-01-11 10:55:51 -08:00
Christopher Ferris
6ddc2c56c9 Update for v5.10 kernel headers.
Test: Builds.
Change-Id: I6c4b04751df026ef7cbb91627174188c5e6d137c
2020-12-14 22:36:37 -08:00
David Srbecky
8efcd6325c Adjust to MapInfo to new api.
Change-Id: Ic3818a8b001657e6b54ba6fcbf68f8c1d7ef2683
2020-11-24 17:27:05 +00:00
Peter Collingbourne
48c35f0cf6 Merge "Change the android_mallopt(M_SET_HEAP_TAGGING_LEVEL) API." 2020-11-18 20:57:36 +00:00
Peter Collingbourne
71ad49554f Change the android_mallopt(M_SET_HEAP_TAGGING_LEVEL) API.
- Make it apply to every thread, and thus remove the restriction
  that it must be called while the program is single threaded.
- Make it change TCF0 itself (on all threads), instead of requiring
  callers to do it themselves, which can be error prone.

And update all of the call sites.

Change the implementation of
android_mallopt(M_DISABLE_MEMORY_MITIGATIONS) to call
android_mallopt(M_SET_HEAP_TAGGING_LEVEL) internally. This avoids
crashes during startup that were observed when the two mallopts
updated TCF0 unaware of each other.

I wouldn't expect there to be any out-of-tree callers at this point,
but it's worth noting that the new interface is backwards compatible
with the old one because it strictly expands the set of situations in
which the API can be used (i.e. situations where there are multiple
threads running or where TCF0 hadn't been updated beforehand).

Bug: 135772972
Change-Id: I7746707898ff31ef2e0af01c4f55ba90b72bef51
2020-11-18 10:24:29 -08:00
Peter Collingbourne
ebc78cc852 Switch to the new kernel API for obtaining fault address tag bits.
The discussion on LKML is converging on v16 of the fault address tag
bits patch [1]. In this version of the patch the presence of the tag
bits in si_addr is controlled by a sa_flags bit, and a protocol is
introduced to allow userspace to detect kernel support for sa_flags
bits. Update the tombstone signal handler to use this API to read
the tag bits, update the interceptors in libsigchain to implement
the flag support detection protocol and hide the tag bits in si_addr
from chained signal handlers that did not request them to match the
kernel behavior.

[1] https://lore.kernel.org/linux-arm-kernel/cover.1605235762.git.pcc@google.com/

Change-Id: I57f24c07c01ceb3e5b81cfc15edf559ef7dfc740
2020-11-13 16:08:27 -08:00
Treehugger Robot
485505c06d Merge "Fix the expected tagged_addr_ctrl in a test." 2020-11-03 03:12:02 +00:00
Peter Collingbourne
2b6764a625 Fix the expected tagged_addr_ctrl in a test.
It turns out that I had originally written the test with a local
patch applied that forces TCF0 to SYNC, so it was testing for the
wrong tagged_addr_ctrl value. Fix it.

Bug: 135772972
Change-Id: Ibb9b25e5f5635372ad5de7825c31d7264ff02590
2020-11-02 16:00:08 -08:00
Yifan Hong
2ec92cfc28 libdebuggerd_handler_fallback: make vendor_ramdisk_available.
Test: builds
Bug: 156098440
Change-Id: I11466de73bbb3a30c10a7a9088954e37772b7a00
2020-10-28 10:57:51 -07:00
Josh Gao
81c94cdce6 Start tombstoned early in post-fs-data.
Bug: http://b/169659307
Test: manual
Change-Id: Ie19de31e7e2b6cd43402cfd3a2e9274728e9e6b4
2020-10-01 14:25:36 -07:00
Treehugger Robot
d0642a373d Merge "Improve error message in debuggerd fallback handler." 2020-10-01 21:00:16 +00:00
Josh Gao
68083003b8 Improve error message in debuggerd fallback handler.
Bug: http://b/164014625
Test: none
Change-Id: I4f1e61be93c511676e66b909a15735bba963eff0
2020-09-25 13:51:02 -07:00
Christopher Ferris
b05c472421 Add arch member into Unwinder object.
This simplifies some of the logic and removes the need to pass an
Arch value to functions that should already know about the arch
it is operating on.

Includes fixes for debuggerd/libbacktrace.

Added new unit tests to cover new cases.

Test: All unit tests pass.
Test: Faked unwinder failing to verify debuggerd error messages display
Test: properly in backtrace and tombstone.
Change-Id: I439fcae0695befcfb1cb4c0a786cc74949d33425
2020-09-24 18:46:23 -07:00
Peter Collingbourne
864f15dd6d Dump the per-thread TAGGED_ADDR_CTRL value if available.
This value indicates whether memory tagging is enabled on a thread,
the mode (sync or async) and the set of excluded tags. This information
can sometimes be important for understanding an MTE related crash,
so include it in the per-thread tombstone output.

Bug: 135772972
Change-Id: I25a16e10ac7fbb2b1ab2a961a5279f787039000b
2020-09-15 21:32:36 -07:00
Elliott Hughes
713ec25103 libdebuggerd: do a to-do.
Until 77fdb22cf6, logd started as
AID_ROOT and then dropped its privileges. Since then, there's been no
reason to use string comparisons rather than checking the uid.

Test: pkill -SEGV logd
Test: treehugger
Change-Id: Ia709f8f59cb0ab9abac7df84c96c701b5d0a83ea
2020-08-03 18:56:35 +00:00
Jeff Sharkey
7b21637782 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Change-Id: Iafcccbdbdf3ff1078e87000e2ce560ff09b43f68
2020-07-31 16:36:06 -06:00
Elliott Hughes
ba1bd64ca2 Merge "debuggerd: use One True timestamp function." 2020-07-24 15:47:03 +00:00
Elliott Hughes
a660cb3f13 debuggerd: use One True timestamp function.
An OEM asks for sub-second granularity, and that's most easily done if
we only have one timestamp generator. I'm not convinced sub-second
granularity is particularly useful myself, and I definitely don't think
that nanosecond resolution is meaningful but I do like this cleanup, and
if I'm going to use sub-second precision I may as well use the maximum
precision available to me.

Also reduce some duplication of code reading cmdline/comm.

Bug: https://issuetracker.google.com/161860597
Test: head /data/tombstones/*
Change-Id: I035ecfd4a3338ccd84dae0ef973a998a7c7c5056
2020-07-23 16:33:53 -07:00
Peter Collingbourne
fe8997aff8 Include memory tags in memory dump output.
Tags appear in the addresses printed in the memory dump, which seems
like a reasonable place to put them because tagged addresses will
also appear in other places in the tombstone, such as registers and
the fault address.

Bug: 135772972
Change-Id: I52da338347ff6b7503cf5ac80763c540695dc061
2020-07-21 19:05:16 -07:00
Peter Collingbourne
b1fcedb928 Adjust conditions for dumping the memory around a register.
Previously, we would do a simple bounds check before deciding
whether to dump the memory around a register. On 64-bit platforms,
the register's value was required to be less than (4 << 60). However,
after stripping tags on AArch64 as part of r.android.com/1365229, all
pointer values became less than (4 << 60), so the check became useless
for filtering out invalid pointers. As a result, we would attempt to
dump memory for all registers, which for a register not containing
a valid pointer would typically consist of 16 lines of dashes.

One possible fix may be to replace the constant (4 << 60) with the
process's actual address space limit (known as TASK_SIZE inside the
kernel; typically 39 bits on AArch64 and 48 bits on x86_64), but the
kernel provides no API for retrieving a process's TASK_SIZE value. We
could guess it by looking at for example the highest bit set in the
value of getauxval(AT_EXECFN), which points to an address on the stack
which typically is mapped at the end of the address space on program
startup, but at least on AArch64 it is possible to dynamically extend
TASK_SIZE at runtime by providing a hint to mmap(), so this is not
always sufficient.

Instead, it seems best to remove most of the early bounds check, and
simply issue ptrace() calls for each register value, bailing out of
the entire output if none of the calls ended up succeeding. This also
has the nice side effect of avoiding 16 lines of noise per register
whose value looks like a pointer but actually points to unmapped
memory. We still retain part of the bounds check in order to avoid
integer overflow during the dump (including overflows into the tag
part of the address on architectures that support tagging).

Bug: 154272452
Change-Id: I94e4b7124b7735b92fd83a49c80ebded3483cd4e
2020-07-21 16:59:24 -07:00
Peter Collingbourne
d00a577c97 Statically link libminijail to debuggerd_test.
We do not install a 32-bit version of libminijail to 64/32 devices,
which means that "atest -a debuggerd_test" always fails on 32-bit.
Fix it by statically linking libminijail.

Change-Id: I1e5610d1353b4f5b718c1259825421c0c07d7c24
2020-07-21 16:59:24 -07:00
Peter Collingbourne
10e428dd77 Fix dumping of heap memory.
After r.android.com/1288984 we started failing to dump memory contents
for heap addresses because the tag started causing any addresses to
fail this bounds check. Add an untag_address() call to the bounds check
so that the tag is ignored.

Bug: 154272452
Change-Id: I3a6d1a078b21871bd93164150a123549f83289f6
2020-07-17 17:35:49 -07:00
Peter Collingbourne
bbe6905d7e Add stack trace coverage to MTE tests.
It's impractical to test the contents of the stack trace, but we
should at least test that *a* stack trace is present, which would
have caught the bug fixed by r.android.com/1306754 .

Bug: 135772972
Change-Id: Ic5e0b997caa53c7eeec4e5185df5c043c9d4fe3d
2020-05-08 10:14:47 -07:00
Peter Collingbourne
f86225206d Add support for MTE error reports in tombstones.
Teach debuggerd to use the new scudo APIs proposed in
https://reviews.llvm.org/D77283 for extracing MTE error reports from crashed
processes, and include those reports in tombstones if possible.

Bug: 135772972
Change-Id: I082dfd0ac9d781cfed2b8c34cc73562614bb0dbb
2020-04-27 13:15:49 -07:00
Tom Cherry
c5c6d7d326 Don't include log/log_read.h in log/log.h
log/log.h primarily concerns itself with writing logs.  The few users
who read logs should directly include log/log_read.h.

Bug: 78370064
Test: build
Change-Id: Ie95c55ea2ffc76fc95768323d445ada6ad4f2520
2020-04-17 15:31:34 -07:00
Josh Gao
c40a7515eb debuggerd: don't leave a zombie child if crash_dump is killed.
If crash_dump dies before it gets a chance to write to the pipe we use
to let the debugged-process know that it successfully started, we
weren't cleaning up the child we fork to start it, leaving a zombie
child.

Bug: http://b/152119184
Test: debuggerd_test
Change-Id: Id01cc05f693995e9998941774f74ab8e3d8b4d8a
2020-04-10 10:09:39 -07:00
Peter Collingbourne
cd63cae6b2 Merge "Read fault address on arm64 using proposed kernel API." 2020-03-30 21:40:58 +00:00
Peter Collingbourne
5677803cb7 Merge "Create a debugger_process_info data structure with the process info pointers." 2020-03-30 21:36:41 +00:00
Peter Collingbourne
e2b76c5b00 Merge "Move crash_dump into the runtime APEX." 2020-03-30 19:03:41 +00:00
Peter Collingbourne
f03af8844a Read fault address on arm64 using proposed kernel API.
On aarch64, the top 8 bits of the address (i.e. the tag bits) of
the fault address in si_addr are always clear. This isn't ideal for
MTE which will require these bits in order to correctly diagnose
tag mismatches.

A proposed kernel patch [1] exposes the full fault address including
the tag bits as part of the ucontext. Change debuggerd to read this
fault address if available.

[1] https://patchwork.kernel.org/patch/11435077/

Bug: 135772972
Change-Id: Ia05be574113860f4e9ecc36a310c4b740e0c4afb
2020-03-27 20:00:06 -07:00
Mitch Phillips
b9c072c551 Move PC-only unwind frame generation to libunwindstack.
GWP-ASan uses frame-pointer based unwinding internally on
allocation/deallocation to collect stack traces that are used when
crashes are reported.

This should be generic, so pull it out into libunwindstack so it can be
used by MTE as well.

Bug: 152412331
Test: atest debuggerd_test
Change-Id: I27b32263aac63446f5fe398af108676b70cd3971
2020-03-26 13:39:05 -07:00
Peter Collingbourne
f3d542fe9f Create a debugger_process_info data structure with the process info pointers.
Similar to r.android.com/1247247 I'll be adding more of them for MTE.

Also, change the protocol between the crasher and crash_dump to make
it easier to add new fields and change the referenced data structures
without needing to worry about versioning. The version number for
static executables is now always 1 (where the protocol will never
change), while the version number for dynamic executables is always
4 (where the protocol can change, because the linker and crash_dump
are version locked).

Bug: 135772972
Change-Id: Ib4696d0544d7c87cb429aaaa15f18c3640059e16
2020-03-24 17:23:15 -07:00
Tom Cherry
7581e86a72 Merge "Remove ANDROID_LOG_RDONLY, etc" 2020-03-24 21:00:57 +00:00
Tom Cherry
907b2d0349 Remove ANDROID_LOG_RDONLY, etc
These macros haven't been meaningful in years.

Test: logging unit tests
Change-Id: I796ec6d9b450f8a84bc85c3f15ddd988724c5e08
2020-03-23 13:43:27 -07:00
Martin Stjernholm
6d4e47a165 Merge "Remove use of static libdexfile to avoid linking in ART internal code." 2020-03-23 20:15:14 +00:00
Peter Collingbourne
5ac3927878 Make GetPcAdjustment a free function.
We're now using it in contexts that don't have all of the registers available,
such as GWP-ASan and soon MTE, so it doesn't make sense to have it be a
member function of Regs.

Bug: 135772972
Change-Id: I18b104ea0adb78588d7e475d0624cefc701ba52c
2020-03-19 17:51:20 -07:00
Martin Stjernholm
a2cc893044 Remove use of static libdexfile to avoid linking in ART internal code.
- Create a static library libunwindstack_no_dex without DEX support.
- Use it in libdebuggerd_handler_fallback, whose only use is in the
  linker, which shouldn't need that support.
- Use it in init_first_stage, which doesn't need DEX support either.
- Also need a libbacktrace_no_dex since it's in the dependency chain
  from init_first_stage to libunwindstack_no_dex.

Also restrict the *_no_dex libs and libdebuggerd_handler_fallback as
much as possible to avoid inadvertent use of these reduced
functionality libs.

Test: m init_first_stage on Cuttlefish
  where BOARD_BUILD_SYSTEM_ROOT_IMAGE=false
Test: m system_image com.android.runtime
Test: Build & boot
Test: atest linker-unit-tests libunwindstack_unit_test debuggerd_test
Bug: 142944931
Bug: 151466650
Change-Id: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
2020-03-19 22:23:54 +00:00
Peter Collingbourne
b72e74810c Move crash_dump into the runtime APEX.
A future change will introduce a version lock between linker and
crash_dump. Move crash_dump into the runtime APEX alongside linker in order to
ensure that they will be the same version even if the runtime APEX is updated.

Bug: 135772972
Change-Id: Ic2eae31b6927eb0e8a62315ac141f50933c00bcc
Merged-In: Ic2eae31b6927eb0e8a62315ac141f50933c00bcc
2020-03-18 10:38:04 -07:00
Elliott Hughes
151e74894f Merge "debuggerd: add an opt-out for OEMs that would rather collect core dumps." 2020-03-06 17:17:51 +00:00
Peter Collingbourne
843f7e645d Create a ProcessInfo structure with the process-wide information from the crasher.
We're now passing around a couple of addresses for GWP-ASan in addition
to abort_msg_address and fdsan_table_address, and I'm going to need to add
more of them for MTE. Move them into a data structure in order to simplify
various function signatures.

Bug: 135772972
Change-Id: Ie01e1bd93a9ab64f21865f56574696825a6a125f
2020-02-28 19:12:19 -08:00
Elliott Hughes
530ab81e42 debuggerd: add an opt-out for OEMs that would rather collect core dumps.
On userdebug/eng devices, check a system property to see whether we
should create tombstones or not. OEMs that would rather have core dumps
can set this property and configure /proc/sys/kernel/core_pattern
appropriately.

Bug: https://issuetracker.google.com/149663286
Test: set the property, cause a crash
Change-Id: If894b4582a1820b64bdae819cec593b7710cb6e3
2020-02-25 09:28:24 -08:00
Elliott Hughes
f77f6f003c Remove various bits of dead code and unused workarounds.
Test: treehugger
Change-Id: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
Merged-In: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
2020-02-22 16:53:24 +00:00
Mitch Phillips
e0b4bb1b2e [GWP-ASan] Add GWP-ASan information to tombstones.
GWP-ASan can provide information about a crash that it caused. Grab the
GWP-ASan regions from the globals shared by the linker for crash-handler
purpopses, pull the information from GWP-ASan, and display it.

This adds two regions:
 1. Causality tracking by GWP-ASan. We now print a cause header about
 the crash, like `Cause: [GWP-ASan]: Use After Free on a 1-byte
 allocation at 0x7365bb3ff8`
 2. Allocation and deallocation stack traces.

Bug: 135634846
Test: atest debuggerd_test

Change-Id: Id28d5400c9a9a053fcde83a4788f971e677d4643
2020-02-18 16:49:50 -08:00
Ray Essick
bd3ba782f2 build crash_dump.policy files using Android.bp
use Android.bp instead of Android.mk to build and install the
crash_dump.policy files. This also allows mainline modules to pull
the files into their apex (dependency wasn't handled for Android.mk)

Bug: 147914640
Test: build, examine generated filesystem
Change-Id: Iae92d4f9d683ccfddf1716e7eb2877b7bff0c737
2020-02-03 08:57:46 -08:00
Elliott Hughes
f8c0350eaa Merge "debuggerd: remove the raw stack dump." 2020-01-23 16:07:42 +00:00
Elliott Hughes
627928e059 debuggerd: remove the raw stack dump.
This takes a lot of space, isn't convincingly useful, and makes it
likely that the far more valuable stuff that comes after it gets
truncated. So let's just drop it.

Bug: http://b/139860930
Test: manual crasher, presubmit
Change-Id: Ie417ffc07e3cb17e95fdb3d183f8c87de0f34b89
2020-01-22 14:13:46 -08:00
Josh Gao
55c7ed4e2e debuggerd_handler: increase thread stack size.
1 page isn't enough to log on AArch64, and clean pages are free, so
increase the stack size to 8 pages.

Bug: http://b/144887737
Test: treehugger
Change-Id: I731b3bc27ab37f4b830a9478a04cd34d4f7648d3
2020-01-17 17:25:30 -08:00
Steven Moreland
e40e4270e8 remove deprecated bp 'subdirs'
noticed some, so thought I would remove them everywhere here

Bug: N/A
Test: N/A
Change-Id: I2978673b158d6c253914ea22f7f0129e446a5f91
2020-01-14 12:18:40 -08:00
Josh Gao
a48b41bcb8 debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.
Test: treehugger
Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
2019-12-17 16:36:05 -08:00
Treehugger Robot
82a31b8749 Merge "Add variadic logging to libdebuggerd internal." 2019-11-19 19:04:55 +00:00
Mitch Phillips
aadebd8982 Add variadic logging to libdebuggerd internal.
GWP-ASan's crash information retrieval services requires a Printf()
function (declared by the system/implementing allocator). In this
instance, because _LOG is called with additional arguments (the log_t),
this function must be wrapped to conform to printf_t defined by
GWP-ASan.

We can easily wrap the variadic version.

Bug: 135634846
Test: atest debuggerd_test
Change-Id: I17209cd2b7455ce889e2f8194969f606cac329eb
2019-11-19 09:49:05 -08:00
Treehugger Robot
ba5351692e Merge "Include PSTATE in tombstones on arm64." 2019-11-19 14:07:37 +00:00
Peter Collingbourne
bb2f941f57 Include PSTATE in tombstones on arm64.
A thread's PSTATE can sometimes be critical for understanding a crash,
especially with MTE and other new features that store per-thread state
in PSTATE.

Bug: 135772972
Change-Id: I1bee25bffe7eea395f04b6449dc9227298cf866e
2019-11-18 17:57:37 -08:00
Tom Cherry
441054aa1e Remove old logger_entry_v* formats
logger_entry and logger_entry_v2 were used for the kernel logger,
which we have long since deprecated.  logger_entry_v3 is the same as
logger_entry_v4 without a uid field, so it is trivially removable,
especially since we're now always providing uids in log messages.

liblog and logd already get updated in sync with each other, so we
have no reason for backwards compatibility with their format.

Test: build, unit tests
Change-Id: I27c90609f28c8d826e5614fdb3fe59bde22b5042
2019-10-24 10:53:14 -07:00
Treehugger Robot
ecc9b1bd7f Merge "debuggerd_client_test: massively increase timeouts." 2019-10-17 21:33:46 +00:00
Josh Gao
f10d4a15d2 debuggerd_client_test: massively increase timeouts.
debuggerd_client.race seems to have suddenly started to flake, for no
apparent reason. This doesn't seem to reproduce locally, so increase
the timeouts to rule out our test VMs being slow.

Bug: http://b/142571257
Test: treehugger
Change-Id: Ic54a78b8da36cb1163cec7e7976c73c3da628a30
2019-10-17 12:09:49 -07:00
Nick Desaulniers
67d52aa0f6 [debuggerd] fix -Wreorder-init-list
C++20 wants members to be ordered unlike C99.

Bug: 139945549
Test: mm
Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-10-10 14:54:35 -07:00
Elliott Hughes
ec220cd877 debuggerd: increase the default limit on tombstones to 32.
We're missing useful crashes, especially on hwasan builds.

Bug: http://b/140580637
Test: run crasher
Change-Id: Ib5d8d3bd3fc4d7fec77d0b10302e5595f97a3515
2019-09-26 14:36:01 -07:00
Christopher Ferris
11555f0961 Increase timeouts.
There is still some flakiness, so increase the timeout values.
Also remove the TEMP_FAILURE_RETRY macro usage in TIMEOUT calls.
That macro disables the ability of the alarm code to interrupt
the system call.

Bug: 141045754

Test: Unit tests pass.
Change-Id: Ia3c95dccc3076a3fd5ef6432097a57e4ccee4df3
2019-09-20 15:07:03 -07:00
Christopher Ferris
172b0a0834 Add TEMP_FAILURE_RETRY where appropriate.
Bug: 141045754

Test: Ran unit tests in a loop on walleye and cuttlefish.
Change-Id: I87b912e76889ed207ab17b862e4786ee44a382ba
2019-09-18 19:05:25 -07:00
Christopher Ferris
ab60668ef4 Allow getrlimit/ugetrlimit syscalls in tests.
The fdsan code uses getrlimit/ugetrlimit so need to allow that when
running the debuggerd unit tests.

Bug: 141045754

Test: Ran the offending tests hundreds of times without failure.
Change-Id: Iece94f03e7895d61ca8a8f3ab17dce7e54ddf9cd
2019-09-17 15:31:47 -07:00
Josh Gao
6cad139bcc Mark some tests as requiring root.
Bug: http://b/140123924
Test: mma
Change-Id: I3ad277179018631c50d9295cdb173dd9dfa7ac59
2019-08-27 16:09:32 -07:00
Josh Gao
8ad965ae5e tombstoned: start immediately after /data is mounted.
Catch as many early-boot crashes as we can by starting tombstoned
immediately after /data is mounted.

Bug: http://b/139864948
Test: adb shell su 0 dmesg | grep "starting service"
Change-Id: I7f8821102191a445e87020f3efa59a2e0620d9db
2019-08-22 15:19:44 -07:00
Treehugger Robot
44e343837f Merge "Add wchan data to ANR dump" 2019-07-20 16:40:54 +00:00
Kalesh Singh
1489e27bda Add wchan data to ANR dump
Since only privileged processes with CAP_SYS_ADMIN can read kernel
stack traces from /proc/*/stack, we dump the waiting channels
instead to provide some insight as to where the process might
be stuck in the kernel.

Bug: 135458700
Fixes: 135458700
Test: adb shell am hang; Check /data/anr/<anr-file> for
      wchan data.
Change-Id: I9f13511ad89a259ce5e5465155db15d45d2c46d8
2019-07-18 16:02:57 -07:00
Christopher Ferris
481e8379d3 Add cause message when stack overflow is detected.
Test: Ran new unit tests.
Test: Ran crasher stack-overflow, crasher64 stack-overflow and verified
Test: stack overflow cause is shown.
Test: Ran stack overflow app and verified tombstone includes stack-overflow
Test: message.
Change-Id: I9bb01186dff5ed81c77d84b6aaedb5332ddd7256
2019-07-17 14:14:26 -07:00
Christopher Ferris
afc0ff7fe0 Increase timeout to avoid flaky tests.
Also, print extra information when an error occurs.

Test: Ran unit tests.
Change-Id: I3404549db0ac18a4a82a99b2620556db96376bca
2019-06-26 15:08:51 -07:00
Josh Gao
5df504c5f8 crash_dump: populate uid field.
Bug: http://b/132359035
Test: manual
Change-Id: I99d8446024fc2d9395132dea45f03317976a9b62
2019-05-09 12:49:57 -07:00
Misha Wagner
39c5b8c21c Add UID printing to tombstone headers
This is for Android Telemetry to be able to categorise the processes
that produce tombstones.

Test: atest debugerd_test:TombstoneTest

Change-Id: Ie635347c9839eb58bfd27739050bd68cbdbf98da
2019-04-23 09:53:07 +01:00
Christopher Ferris
4ae266ccbd Add indicator that an elf is memory backed.
Modify the unwinder library to indicate that at least one of the stack
frames contains an elf file that is unreadable.

Modify debuggerd to display a note about the unreadable frame and a possible
way to fix it.

Bug: 129769339

Test: New unit tests pass.
Test: Ran an app that crashes and has an unreadable file and verified the
Test: message is displayed. Then setenforce 0 and verify the message is
Test: not displayed.
Change-Id: Ibc4fe1d117e9b5840290454e90914ddc698d3cc2
2019-04-18 15:37:52 -07:00
Treehugger Robot
371180bb72 Merge "debuggerd: call setsid in our children." 2019-04-16 23:29:04 +00:00
Josh Gao
18cb681247 debuggerd: call setsid in our children.
There appears to be a kernel bug that causes SIGHUP and SIGCONT to be
sent to the parent process group we spawn from if the process group
contains stopped jobs (e.g. the parent itself, because of wait_for_gdb).

Call setsid in all of our children to prevent this from happening.

Bug: http://b/31124563
Test: adb shell 'setprop debug.debuggerd.wait_for_gdb 1; killall -ABRT surfaceflinger'
Change-Id: I1a48d70886880a5bfbe2deb80d48deece55faf09
2019-04-16 13:17:08 -07:00
Treehugger Robot
e1d4648f46 Merge "crasher: add execute-only memory ("xom")." 2019-04-16 12:28:25 +00:00
Elliott Hughes
dd04c658c3 crasher: add execute-only memory ("xom").
Test: `crasher thread-xom`
Change-Id: Ia121848df966040968370e1e9cb840034d780e4f
2019-04-15 13:03:48 -07:00
Christopher Ferris
3336c7bce0 Remove include of backtrace/Backtrace.h.
Somehow the code was still including this include from libbacktrace.
I think the libbacktrace include directory was coming from some
transitive includes. I verified that nothing in debuggerd is using
the libbacktace.so shared library.

Bug: 120606663

Test: Builds, unit tests pass.
Change-Id: I85c2837c5a539ccefc5a7140949988058d21697a
2019-04-08 17:18:24 -07:00
David Srbecky
b9cc4fbb26 Revert "Check for data races when reading JIT/DEX entries."
This reverts commit 85b5fecec9.

Reason for revert: Breaks ART tests, reverting to investigate.

Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
2019-04-05 18:23:32 +00:00
David Srbecky
85b5fecec9 Check for data races when reading JIT/DEX entries.
Update the entries only when the list is modified by the runtime.

Check that the list wasn't concurrently modified when being read.

Bug: 124287208
Test: libunwindstack_test
Test: art/test.py -b --host -r -t 137-cfi
Change-Id: I87ba70322053a01b3d5be1fdf6310e1dc21bb084
2019-03-29 14:01:32 +00:00
Christopher Ferris
7813345faa Add BuildId to frame information.
Update debuggerd to print BuildId information by default.

Bug: 120975492

Test: New unit tests pass.
Test: debuggerd -b <PID> shows build id information.
Test: tombstones include build id information.
Change-Id: I019b031113d0b77385516223c63455b868924440
2019-03-26 08:04:40 -07:00
Josh Gao
5e8d68c2b2 debuggerd_handler: demote abort on exec failure to log.
If a process is ptraced already, we might not be able to exec crash_dump
due to selinux. Since we can be called for non-fatal events, we
shouldn't abort in that case.

Bug: http://b/128054996
Test: treehugger
Change-Id: I1442041caa7af908df2ab87b9e010c44082e7587
2019-03-18 14:39:47 -07:00
Florian Mayer
3d67d347f5 Fix copy / move behaviour of Maps object.
Currently, moving or copying a Maps object leads to double free of MapInfo.

Even moving a Maps object  did not prevent this, as after a move
the object only has to be in an "unspecified but valid state", which can
be the original state for a vector of raw pointers (but not for a vector
of unique_ptrs).

Changing to unique_ptrs is the most failsafe way to make sure we never
accidentally destruct MapInfo.

Test: atest libuwindstack_test
      Failed LocalUnwinderTest#unwind_after_dlopen which also fails at master.

Change-Id: Id1c9739b334da5c1ba532fd55366e115940a66d3
2019-03-05 13:05:36 +00:00
Martin Stjernholm
852b64e549 Fix libdexfile dependencies to avoid direct dependency on libdexfile_external.
It should be dlopen'ed lazily by libdexfile_support now.

Also change debuggerd_test to not link libunwindstack and its dependencies
statically - the static libs can overlap with the dynamic ones.

Test: mmma system/core/debuggerd/
Test: atest debuggerd_test
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests (cannot get atest to work)
Bug: 124827589
Bug: 123186083
Change-Id: I9e7bf9bcbae499af4e1be4c9854bce441e2a7b55
2019-02-24 22:04:11 +00:00
Josh Gao
8954d0bc98 Merge changes from topic "base_cmsg"
* changes:
  adb: switch to base::{Send,Receive}FileDescriptors.
  debuggerd: switch to base::{Send,Receive}FileDescriptors.
  base: add helpers for sending/receiving file descriptors.
2019-02-19 20:53:01 +00:00
Josh Gao
5f87bbdb0a debuggerd: switch to base::{Send,Receive}FileDescriptors.
Bug: http://b/12204763
Test: debuggerd_test
Change-Id: I0be40916214de51ab36fd6bd6d44090a84312e51
2019-02-13 13:21:54 -08:00
Martin Stjernholm
e31cfb609d Use new static target for libdexfile_support.
This is necessary since the dynamic one is now using dlopen(), which isn't
available in static builds.

Test: m
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests (cannot get atest to work)
Bug: 123403798
Bug: 123186083
Change-Id: I06a9cdfe7e7cc01427ffd54b66c8ebab88782260
2019-02-12 22:03:48 +00:00
Christopher Ferris
60eb19795b Replace libbacktrace with libunwindstack directly.
Small modifications to the dump_stack method and added unit tests to
verify the output.

Bug: 120606663

Test: Unit tests pass, debuggerd run on processes on target.
Change-Id: Id385a915b751abda3dd6baebed6c3ce498c3bf6e
2019-01-29 17:57:14 -08:00
Greg Kaiser
3fa9a59ea3 debuggerd: Fix return type in error case
With our method returning 'bool', a "return -1" is interpretted
as 'true'.  We change this to an explicit 'false', as desired.

Test: TreeHugger
Change-Id: I222858b797bc4242a2dc6d4fe81df3d2586d055a
2019-01-08 06:29:22 -08:00
Josh Gao
4175cee3cc debuggerd_client: resolve tid to tgid when dumping Java stacks.
Bug: http://b/121438213
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I4d114c8b0c4586ba64de5b45b47b0ec5c10354f8
2019-01-04 13:57:09 -08:00
Martin Stjernholm
bb4f2b440a Revert^2 "Use libdexfile external API in libunwindstack."
This reverts commit cacf5bf6bc.

Reason for revert: Re-apply with proper fix for VNDK visibility on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: atest CtsRenderscriptTestCases
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Test: Forrest cts/art/gce-all: https://android-build.googleplex.com/builds/forrest/run/L00300000240828791
Test: Forrest cts/bionic/gce-all: https://android-build.googleplex.com/builds/forrest/run/L05600000240682947 (shows 27/2958 failed, but it doesn't pass on Blackbox either: http://screen/xbjioEf6UgR)
Test: Forrest cts/renderscript/gce-all: https://android-build.googleplex.com/builds/forrest/run/L66200000240680523
Bug: 119632407
Change-Id: I601aa97eac8127e30d753405f8bc1fc4ae7f849f
2018-12-19 21:04:35 +00:00
Martin Stjernholm
cacf5bf6bc Revert "Use libdexfile external API in libunwindstack."
This reverts commit 444e23d2fc.

The rest of the topic doesn't need to be reverted.

Reason for revert: Breaks renderscript on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: "atest CtsRenderscriptTestCases" on that branch
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Bug: 121110092, 119632407
Change-Id: If1976b19ce386c95bc5bd4fd6d523745c167de18
2018-12-19 00:11:04 +00:00
Josh Gao
ac64da1637 Merge "libdebuggerd: add timestamp to tombstones." 2018-12-15 00:12:24 +00:00
Josh Gao
6f4644d15b libdebuggerd: add timestamp to tombstones.
Bug: http://b/120099273
Test: debuggerd_test
Change-Id: I457506f8d9920d969e1eba0265f85693b484f1a9
2018-12-14 13:29:52 -08:00
Martin Stjernholm
444e23d2fc Use libdexfile external API in libunwindstack.
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Bug: 119632407
Change-Id: I370f089a1b20ba432e136818b4325d46f99df708
2018-12-13 17:58:23 +00:00
Elliott Hughes
3c59cb8420 C++17 is the default now.
Test: builds
Change-Id: I6814455e9ad2cdcf99ad66de38a3ad0bfb440d80
2018-12-03 09:02:18 -08:00
Elliott Hughes
894da4e0fd Merge "tombstoned: fixed tombstones failed issue" 2018-11-29 01:48:29 +00:00
Jinguang Dong
8ac2f27cc2 tombstoned: fixed tombstones failed issue
There is a problem about tombstone, which it will fail to
generate tombstone file in some scenarios due to socket
communication exception.

Reproduce step:
step 1: reboot device
step 2: ps -ef |grep zygote , get the pid of zygote64
(Attention: zygote64 should never been killed or reboot,
otherwise we can get the tombstone file)
step 3: kill -5 pid of zygote64
step 4: cd data/tombstones/, and could not find the tombstone
file of zygote64.

[Cause Analysis]
1. There are following logs by logcat:
11-19 15:38:43.789   569   569 F libc : Fatal signal 5 (SIGTRAP),
code 0 (SI_USER) in tid 569 (main), pid 569 (main)
11-19 15:38:43.829  6115  6115 I crash_dump64: obtaining output
fd from tombstoned, type: kDebuggerdTombstone
11-19 15:38:43.830   569  5836 I Zygote  : Process 6114 exited
cleanly (0)
11-19 15:38:43.830   777   777 I /system/bin/tombstoned: received
crash request for pid 569
11-19 15:38:43.831  6115  6115 I crash_dump64: performing dump of
process 569 (target tid = 569)
...
11-19 15:38:43.937   777   777 W /system/bin/tombstoned: crash
socket received short read of length 0 (expected 12)
2. The last log was print by function of crash_request_cb in
file of tombstoned.cpp, following related code:
  rc = TEMP_FAILURE_RETRY(read(sockfd, &request, sizeof(request)));
  if (rc == -1) {
    PLOG(WARNING) << "failed to read from crash socket";
    goto fail;
  } else if (rc != sizeof(request)) {
    LOG(WARNING) << "crash socket received short read of length " << rc << " (expected "
                 << sizeof(request) << ")";
    goto fail;
  }

Tombstoned read message by socket, and now the message length is
zero. Some socket communication exception occurs at that time.
We try to let crash_dump resend the socket message when the
communication is abnormal. Just as this CL.

Test: 1 reboot device
      2 ps -ef |grep zygote , get the pid of zygote64
       (Attention: zygote64 should never been killed or reboot,
       otherwise we can get the tombstone file)
      3 kill -5 pid of zygote64
      4 cd data/tombstones/, and could find the tombstone file of
       zygote64.

Change-Id: Ic152b081024d6c12f757927079fd221b63445b18
2018-11-28 14:00:27 +08:00
Ivan Lozano
df3cec925f Tombstone support for XOM-related SIGSEGVs.
Make XOM related crashes a little less mysterious by adding an abort
cause explaining the crash.

Bug: 77958880
Test: Abort cause in tombstone for a XOM-related crash.

Change-Id: I7af1bc251d9823bc755ad98d8b3b87c12bbaecba
2018-11-27 09:00:54 -08:00
Mark Salyzyn
9f1cf25332 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I4f7ad84743e974b4b4d1d7256088f6c8b749a237
2018-11-14 09:35:34 -08:00
Treehugger Robot
e26b8b0181 Merge "debuggerd_fallback: fix fd leak." 2018-10-31 06:05:28 +00:00
Josh Gao
08163cb032 debuggerd_fallback: fix fd leak.
Previously, when we received simultaneous dump requests, we were CASing
a file descriptor value into a variable, and then failing to close it
if the CAS failed.

Bug: http://b/118412443
Test: debuggerd_test
Change-Id: I075c35a239426002eb9416da3d268c3d1a18e9d2
2018-10-30 15:33:58 -07:00
Christopher Ferris
461baeb44e Update for v4.19 kernel headers.
Add new trap type TRAP_UNK.

Test: Unit tests pass.
Change-Id: I2b9cb8ddd1d993aa4819831aaca34f8da4286b52
(cherry picked from commit ead88bc88e)
2018-10-30 09:22:12 -07:00
Stephen Hines
8395de6927 Fix two clang-tidy issues in crasher.cpp.
TEMP_FAILURE_RETRY's result was unused for the call to read(), so now
mark it as such to silence a possible unused result warning. For
__read_chk(), this function is an internal implementation detail of
FORTIFY in Bionic. Under clang-tidy, FORTIFY checks are actually
removed, so this now results in an unknown function being called. The
code should not be explicitly depending on an implementation detail, but
we can just suppress the failing case to retain test coverage of the
actual implementation.

Bug: http://b/110779387
Test: Build using WITH_TIDY=1
Change-Id: If83ac1d6f3b6dc32c0d0fb56d8e675e53b586f78
2018-09-24 13:18:22 -07:00
Treehugger Robot
2d4b48d155 Merge "crash_dump: annotate intended fallthrough." 2018-09-19 20:50:31 +00:00
Josh Gao
8d44b14543 crash_dump: annotate intended fallthrough.
Bug: http://b/116020901
Test: treehugger
Change-Id: I5d059d051fb257efe7f7e1790fd0bc2abd364167
2018-09-18 13:22:22 -07:00
Josh Gao
2b22ae132f tombstoned: don't generate tombstones for native backtraces.
Previously, if an intercept ends before we ask for a file descriptor
when doing a backtrace, we'll create a tombstone file instead.

Bug: http://b/114139908
Bug: http://b/115349586
Test: debuggerd_test32
Change-Id: I23c7bb8ae5a982a4374a862d0a4f17bee03eb1d9
2018-09-14 14:06:47 -07:00
Josh Gao
6f9eeecd2b Fix multithreaded backtraces for seccomp processes.
Add threads to the existing seccomp backtrace test to prevent
regressing this.

Bug: http://b/114139908
Bug: http://b/115349586
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I07fbe1619b60f0008deb045a249f9045404478c2
2018-09-12 18:12:13 -07:00
Josh Gao
be0c1af6f0 debuggerd_client: improve error logging.
system_server is sometimes failing to dump with the following error:

    libdebuggerd_client: received packet of unexpected length from tombstoned: expected 128, received -1

Improve the logging to try to figure out what's going on.

Bug: http://b/114139908
Test: treehugger
Change-Id: Iee1bdc0891b9fc7bd80a330495ec22a530febddb
2018-09-06 13:00:57 -07:00
Josh Gao
8808f6c1c9 libdebuggerd: decode fdsan owner tags.
Test: debuggerd `pidof system_server` | grep " fd "
Change-Id: Ic4bb30b8602acf5912e776a61825d9645ec93c65
2018-08-28 13:48:08 -07:00
Josh Gao
bf06a40a0d debuggerd_test: add test for fdsan abort message.
Bug: http://b/112770187
Test: debuggerd_test
Test: bionic-unit-tests
Change-Id: Ia93761e89074aea4629b8d0f232c580d6f0f249c
2018-08-27 16:55:07 -07:00
Josh Gao
4843c18634 debuggerd_handler: receive abort messages via sigqueue(DEBUGGER_SIGNAL).
Make it possible for code such as fdsan that generates debugging
tombstones via raise(DEBUGGER_SIGNAL) to pass an abort message as well.

Bug: http://b/112770187
Test: debuggerd_test
Change-Id: Idc34263241c18033573e466da3a45aa6f716ddb3
2018-08-27 16:55:07 -07:00
Josh Gao
3e27bd5a8f debuggerd: delete accidentally merged log spam.
Test: none
Change-Id: I4237b4f0c8d5cdc559766fc3c73742b013c1df86
2018-08-21 13:54:31 -07:00
Josh Gao
ce841d91fb libdebuggerd: extract and print the fdsan table.
This commit only prints the raw value of the owner tag, pretty-printing
will come in a follow-up commit.

Test: debuggerd `pidof adbd`
Test: static_crasher fdsan_file + manual inspection of tombstone
Change-Id: Idb7375a12e410d5b51e6fcb6885d4beb20bccd0e
2018-08-06 18:50:10 -07:00
Josh Gao
9da1f51c10 crash_dump: pass the address of the fdsan table.
Pass the address of the fdsan table down to crash_dump so that we can
dump the fdsan table along with the open file descriptor list.

Test: debuggerd_test
Test: manually ran an old static_crasher
Change-Id: Icbac5487109f2db1e1061c4d46de11b016b299e3
2018-08-06 18:50:10 -07:00
Josh Gao
3fa9637e81 crasher: add close(fileno(FILE*)) and close(dirfd(DIR*)).
Add some cases to trigger fdsan aborts.

Test: crasher fdsan_file; crasher fdsan_dir
Change-Id: I48152d333dc25900f1c8d8e0f2e8728154643508
2018-07-18 18:11:46 -07:00
Josh Gao
c954ec09c5 debuggerd_handler: use syscall(__NR_close) instead of close.
Avoid bionic's file descriptor ownership checks by calling the close
syscall manually.

Test: debuggerd_test
Change-Id: I10af6aca0e66fe030fd7a53506ae61c87695641d
2018-07-18 18:11:46 -07:00
Christopher Ferris
c637ada7e4 Clean up logging code.
Test: Verify that tombstones still contain the log message data.
Change-Id: I303dec944e58a0c4f5edfed22caaf1f2462ea3e8
2018-07-16 15:57:38 -07:00
Christopher Ferris
432791e0dc Add support for new defines in v4.17.3 headers.
Test: Builds and unit tests pass.
Change-Id: Ibd5711effb1e599d3239d45124383fe91e0f573d
2018-06-29 16:43:21 -07:00
Treehugger Robot
60e9dad71e Merge "debuggerd: add support for Java traces." 2018-06-15 00:40:41 +00:00
Josh Gao
24113ae641 debuggerd: add support for Java traces.
Test: `debuggerd -j $(pidof com.android.settings)`
Change-Id: I051c9b6d313e5350416b3d0743c3fc75f43fbd0c
2018-06-14 15:40:06 -07:00
Jiyong Park
011ee12b1d Shared libs are supported in recovery mode
adbd has been built as a static executable since the same binary was
copied to the recovery partition where shared library is not supported.
However, since we now support shared library in the recovery partition,
adbd is built as a dynamic executable.

In addition, the dependency from adbd to libdebuggerd_handler is removed
as debuggerd is handled by the dynamic linker.

A few more modules in /system/core are marked as recovery_available:
true as they are transitive dependencies of the dynamic linker.

This change also includes ld.config.recovery.txt which is the linker
config file for the recovery mode. It is installed to /etc/ld.config.txt
and contains linker namespace config for the dynamic binaries under
/sbin.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: Select 'mount /system' in the recovery mode, then `adb shell`.
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: I363d5a787863f1677ee40afb5d5841321ddaae77
2018-06-10 08:32:24 +09:00
Elliott Hughes
2baf443a21 Improve SIGILL support.
Include the illegal instruction in the header if we get a
SIGILL. Otherwise (since these tend to be one-off bit flips), we don't
usually have any information to try to confirm our suspicion that any
given instance is actually a one-off bit flip.

Also add `SIGILL` as a crasher option to easily generate such crashes.

Before:
  signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xab1456da

After:
  signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xab1456da (*pc=0xe7f0def0)

Bug: http://b/77274448
Test: ran crasher
Change-Id: I5f8dedca5eea2b117b1b1e48430214b38e1366ed
2018-05-30 12:58:43 -07:00
Jiyong Park
a0e75045e6 Build adbd for recovery
adbd (and its dependencies) are marked as recovery_available:true so
that recovery version of the binary is built separately from the one for
system partition. This allows us to stop copying the system version to
the recovery partition and also opens up the way to enable shared
libraries in the recovery partition. Then we can also build adbd as a
dynamic executable.

Bug: 79146551
Test: m -j adbd.recovery
Change-Id: Ib95614c7435f9d0afc02a0c7d5ae1a94e439e32a
2018-05-24 14:11:11 +09:00
Treehugger Robot
74bf81443f Merge "debuggerd: fix CrasherTest.seccomp_crash_oom." 2018-05-19 02:14:33 +00:00
Josh Gao
d2b15dd674 debuggerd: fix CrasherTest.seccomp_crash_oom.
Switch from _exit to raising SIGABRT when we recurse in the fallback
handler, so that waiters see an abort instead of a regular exit.

Bug: http://b/79717060
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: Iddee1cb1b759690adf07bbb8cd0fda2faac87571
2018-05-16 00:16:09 -07:00
Chih-Hung Hsieh
3249b3a8dd Expect optional (offset ...) in frame dump.
* New lld could create files that map to non-zero
  offset at run time.

Test: debuggerd_test
Bug: 79590156
Change-Id: I12db0ebef489ba8a1e648a29d214f8d3c3703996
2018-05-14 11:07:54 -07:00
Christopher Ferris
00c81fefd3 Merge "Remove unnecessary references to libunwind." 2018-05-04 20:40:42 +00:00
Christopher Ferris
25e2bbf874 Remove unnecessary references to libunwind.
Bug: 79209464

Test: Builds.
Change-Id: I4193ac664e3b118270a17fcc0131fb6c6e384c41
2018-05-03 17:59:45 -07:00
Josh Gao
f5974aedc4 tombstoned: make missing O_TMPFILE workaround actually work around.
We can't actually link an unlinked file back onto disk if it wasn't
opened with O_TMPFILE. Switch to using a temporary filename instead.

Bug: http://b/77729983
Test: agampe
Change-Id: I1970497114f0056065a1ba65f6358f08b51ec551
2018-05-03 16:05:32 -07:00
Josh Gao
28f8cf0f97 tombstoned: don't bail out if we fail to unlink a file that isn't there.
Test: crasher with no tombstones
Change-Id: I20e0537a347dd1f83877150ab13f53441dd65d95
2018-05-03 14:31:08 -07:00
android-build-prod (mdb)
294d41cb83 Merge "tombstoned: don't create tombstones for failed dumps." 2018-05-02 21:43:03 +00:00
Elliott Hughes
89722709b4 Fix a debuggerd test expectation.
70d8f28945 broke a test that was not
expecting to see the new detail about the signal's sender.

Bug: http://b/78594105
Test: ran tests
Change-Id: Idfa3a53b9e664308efdba560ffbb1401c1904530
2018-05-02 10:49:13 -07:00
Elliott Hughes
4e6f3d9603 Merge "Add test_suites lines." 2018-04-28 16:02:40 +00:00
android-build-prod (mdb)
c314d4db9f Merge "crash_dump: defuse our signal handlers earlier." 2018-04-27 23:29:00 +00:00
Elliott Hughes
40fdf3f4ab Add test_suites lines.
Bug: N/A
Test: builds
Change-Id: Ic5e2b9206bcfcb53c774989013b5db6aab462e42
2018-04-27 16:12:06 -07:00
Josh Gao
38ac45df17 crash_dump: defuse our signal handlers earlier.
We have a LOG(FATAL) that can potentially happen before we turn off
SIGABRT. Move the signal handler defusing to the very start of main.

Bug: http://b/77920633
Test: treehugger
Change-Id: I7a2f2a0f2bed16e54467388044eca254102aa6a0
2018-04-27 13:31:47 -07:00
Elliott Hughes
70d8f28945 Show signal sender for SI_FROMUSER signals.
Suicide doesn't change:

  signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------

But homicide now looks like this (this is `sleep 666` killed by
`kill -SEGV` as root:

  signal 11 (SIGSEGV), code 0 (SI_USER from pid 4446, uid 0), fault addr --------

Bug: http://b/78594105
Test: manual
Change-Id: I8c2feafba8cc5a3db85e8250004d428a464c5d9e
2018-04-26 08:19:17 -07:00
Josh Gao
83b8ac24b6 libdebuggerd: fix out of bounds write.
Bug: http://b/78363964
Test: treehugger
Change-Id: I79ae818e4e0c29f064335d59789afc3b1bf87c69
2018-04-20 17:46:50 -07:00
Josh Gao
5d1c14f41b libdebuggerd: clone registers before we Unwind with them.
Bug: http://b/77296294
Test: manual inspection of tombstone generated by crasher
Change-Id: I4b017701d7d2041db4aefbbb90977e99b844c328
2018-04-20 13:23:20 -07:00
Josh Gao
48383c806a tombstoned: don't create tombstones for failed dumps.
Instead of creating tombstone FDs in place and passing them out to
crash_dump directly, create them as O_TMPFILEs and link them into place
when crash_dump reports success, to avoid creating empty tombstones
in cases like an aborting thread racing with another thread that
manages to cleanly exit_group before the dump finishes.

Bug: http://b/77729983
Test: debuggerd_test
Test: adb shell 'for x in `seq 0 50`; do crasher; done'
Change-Id: I31ce4fd4a524abf8bde57152450209483d9d0ba9
2018-04-19 14:33:18 -07:00
Josh Gao
1cc7bd80a6 debuggerd: remove maximum abort message length.
Let the logging implementation be the imposer of limits.

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

Bug: 73904572
Test: lunch aosp_mips-eng; m nothing
Test: lunch aosp_arm-eng; m crash_dump.policy
Test: lunch aosp_arm64-eng; m crash_dump.policy
Test: lunch aosp_x86-eng; m crash_dump.policy
Test: lunch aosp_x86_64-eng; m crash_dump.policy
Change-Id: I28864b5af59267f1ab83084128f2c59b04039374
2018-02-27 15:35:11 -08:00
Josh Gao
70adac6a8a debuggerd_fallback: don't recursively abort.
Calls to abort() will always result in our signal handler being called,
because abort will manually unblock SIGABRT before raising it. This
can lead to deadlock when handling address space exhaustion in the
fallback handler. To fix this, switch our mutex to a recursive mutex,
and manually keep track of our lock count.

Bug: http://b/72929749
Test: debuggerd_test --gtest_filter="CrasherTest.seccomp_crash_oom"
Change-Id: I609f263ce93550350b17757189326b627129d4a7
2018-02-22 16:31:38 -08:00
Treehugger Robot
0609e8d231 Merge "bpfmt." 2018-02-20 02:02:59 +00:00
Josh Gao
edd28f6ede debuggerd seccomp: explain why we define PROT_READ/WRITE.
Add a comment explaining why we define PROT_READ/PROT_WRITE, even
though a current libminijail supports both cosntants.

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

Bug: 73273658
Test: use the new policy in OMR1 devices
Change-Id: I936a733340ad4df8aef6562c03eb10c29ffdada2
2018-02-19 10:42:42 +09:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00