Commit graph

2793 commits

Author SHA1 Message Date
Elliott Hughes
38558bad85 Merge "Fix ifunc_test for hwasan builds." 2020-04-14 22:57:21 +00:00
Elliott Hughes
19b2ce8f38 Fix ifunc_test for hwasan builds.
This actually breaks *all* the tests, because the bionic-unit-tests
binary crashes while running this ifunc before hwasan is set up.

A longer term fix would be to have the compiler insert a call to
__hwasan_init at the start of any ifunc resolvers.

Bug: 135772972
Test: ran tests on a hwasan build
Change-Id: I424b3035e1f76aa4b98c11346825b9ed140584ba
2020-04-13 14:16:17 -07:00
Tom Cherry
03581d7aa9 Merge changes I6c9c2bf5,I23991692
* changes:
  Tighten pwd/grp iteration tests.
  Cleanup some trivial TODOs.
2020-04-10 23:04:55 +00:00
Ryan Prichard
e31b510f92 Merge "Reenable signal-frame-unwind test on x86" 2020-04-10 22:36:19 +00:00
Tom Cherry
0816c9050f Tighten pwd/grp iteration tests.
Previously, these tests would fail if vendors modified
private/android_filesystem_config.h to add their custom AIDs, but we
did not have a good alternative that vendors could use, so we added a
special case to ignore the vendor AID ranges.

We've had a proper solution since P for this range, so it's long past
time to remove this special case.

Test: add system, vendor, odm, product, and system_ext AIDs to
      config.fs, ensure that they've taken effect on cuttlefish,
      pass these unit tests
Change-Id: I6c9c2bf5e895c25805222da018188b269777171c
2020-04-10 13:00:42 -07:00
Tom Cherry
6f2e810198 Cleanup some trivial TODOs.
1) "fix the system properties design" is written for the old protocol,
   so we've already changed the design.  There are no other further
   planned changes.
2) "don't drag in all the macros, just the types." is not likely to
   happen or be particularly impactful.
3) "Find a location suitable for these functions ..." is refering to
   legacy code.  More likely that this code will be removed before we
   find a serious reason to fix this TODO.
4) "(73062966) We still don't have a good way ..." is stale; we fixed
   this bug and added the appropriate mechanism.

Test: n/a
Change-Id: I23991692cdeb81ad00844a6a1680900ff384208b
2020-04-10 11:46:03 -07:00
Ryan Prichard
4eb02e2ccd Reenable signal-frame-unwind test on x86
The test was failing due to a kernel vDSO that was linked without
--eh-frame-hdr. The kernel bug is fixed for at least the goldfish and
cuttlefish devices.

3d4b1ffc7e
b66f198bf3

Bug: http://b/132763120
Test: bionic unit tests, on goldfish and cuttlefish
Change-Id: I5e1d819b604a4baf5b9208f0b19471f9abbcfe75
2020-04-09 16:46:53 -07:00
Orion Hodson
e7042a740e Remove unnecessary jni.h
Discovered after removing implicit jni.h include path.

Bug: 152482542
Test: lunch aosp_x86_64 && m checkbuild
Change-Id: I5fcb33b110c8f5ee9db3c910eaaa3e6018979a45
2020-04-07 09:21:41 +01:00
Christopher Ferris
bf8a50f597 Merge "Fix possible issue with cfi_basic test." 2020-04-02 17:40:17 +00:00
Christopher Ferris
f322483b3f Fix possible issue with cfi_basic test.
It's possible for malloc to return a pointer that is not going to
crash with __cfi_slowpath. It's possible to modify the cfi code
to avoid this problem, but I'm not convinced that this will be any
better at catching problems. So I'm just modifying the test so that
it will eventually allocate a pointer that does not overlap.

This previous version of the test failed on jemalloc svelte config,
but there is nothing that would not result in a failure on scudo
leading to a failure every once in a while.

Bug: 142556796
Bug: 140079007

Test: Ran bionic unit tests with jemalloc and scudo.
Change-Id: Iff45bd950d2eb33ff56dc700a2d739b5b578e090
2020-04-02 05:48:05 +00:00
Ryan Prichard
3c5dff4b1d Explain why unit tests need bootstrap bionic
The question of why the unit tests need the bootstrap bionic came up
while I was working on http://b/152572170.

Test: none
Change-Id: I08651200e2193c6ea4d3a734b59f022d69e5f154
2020-03-31 17:34:03 -07:00
Florian Mayer
e7221986c8 Merge "dynamic libc: ignore ART profiling signal by default." 2020-03-28 10:15:32 +00:00
Christopher Ferris
ca885cf249 Remove bionic-unit-tests-scudo.
This is not used at all any more since we've switched to scudo.

Test: Builds.
Change-Id: Iff0b7d4a5ea12103a68ad038de2d82bf5f864285
2020-03-27 17:04:30 -07:00
Florian Mayer
96272df35c dynamic libc: ignore ART profiling signal by default.
These solves the issue that targetting non-profilable apps crashed them.
There is still a race condition between starting the app and the SIG_IGN
being installed, but that will be fixed in follow-ups.

This also does not cover programs that statically link libc, but those are
rare.

This might be reverted if we find a more general solution to
b/151835887.

Bug: 151328035
Test: java profile sysui, doesn't crash
Test: atest CtsBionicTestCases

Change-Id: I6b99352ed50afe15a609f7ddb85312c2676ddf11
2020-03-27 19:22:00 +01:00
Treehugger Robot
e05c449cd8 Merge "Add ffsl(3), ffsll(3)." 2020-03-26 21:14:36 +00:00
Elliott Hughes
4a6899ce0c Add ffsl(3), ffsll(3).
POSIX added these GNU extensions for issue 8.

I've made these always inline without the usual "until API level X"
proviso because they're single instructions that the compiler can inline
and there's really no point providing these if they add function call
overhead --- everyone should just use __builtin_ffs() and friends
instead in that case.

Bug: https://austingroupbugs.net/view.php?id=617
Test: treehugger
Change-Id: I33fc4b8648ea25917329e81c1b4c60eb9a66d667
2020-03-26 11:43:05 -07:00
Hans Boehm
a1ab838acc Merge "Increase iteration count for ordering test" 2020-03-26 01:21:19 +00:00
Hans Boehm
376106436c Increase iteration count for ordering test
This should make it less likely that the writer finishes before the
reader even starts. It makes the test run longer, but devices have
gotten faster suince this test was written.

Bug: 152218463
Test: Treehugger
Change-Id: I409e59071991095fb17e067760f2a5f29ede0ba2
2020-03-25 12:50:21 -07:00
Treehugger Robot
8d1849930f Merge "Rewrite sigwait tests in the style of the sigwaitinfo tests." 2020-03-21 01:36:16 +00:00
Elliott Hughes
50fca4d2bd Rewrite sigwait tests in the style of the sigwaitinfo tests.
I can't reproduce locally, but treehugger is seeing 6% flake in the
signal.sigwait64_SIGRTMIN test. It's the only test in the file with a
sleep() in it, which always makes me suspicious, and we aren't having
trouble with the (in principle) very similar sigwaitinfo() tests, so
switch over to their style.

Bug: http://b/149934069
Test: treehugger
Change-Id: I2a1193b0cbec50f6548badf7dc7175bb6a49e45f
2020-03-20 16:27:57 -07:00
Peter Collingbourne
2528dab741 Clean up untag_address.
We had two copies of this function, one (not quite correct) in tests/utils.h
and another in bionic/macros.h. Delete the former and have the users include
the latter.

Also, create an overload of the function that takes a uintptr_t, which will
be useful for out-of-process scenarios such as the MTE support in debuggerd.

Bug: 135772972
Change-Id: Ia3c2652c97797663146b3f05fa786afe09f7ea97
2020-03-20 15:35:54 -07:00
Christopher Ferris
140220bd23 Disable branch protection for arm64.
This causes failures in signal handler tests, because it looks like clang
doesn't understand how to enable the stack protection in a signal handler.
Clang winds up scribbling on the real stack.

Bug: 149934069
Bug: 151372823

Test: Ran all unit tests on bonito/taimen and the signal handler tests pass.
Change-Id: If73f55e7505b6d7f35b340be0b03c798b21e2829
2020-03-13 00:18:42 +00:00
Ryan Prichard
afa983c8d4 Rewrite __cxa_atexit / __cxa_finalize
Simplify:
 - Use a single memory-mapped region to hold the table of destructors.
   Double its capacity each time it is expanded.
 - Add a recompaction pass at the end of __cxa_finalize that shifts
   entries forward and uses madvise to clean pages.

Bug: http://b/148055738
Test: bionic-unit-tests
Change-Id: Ieb9da2b88640a8a5277d217b43826b5b7e246781
2020-03-06 21:04:32 -08:00
Treehugger Robot
b274746dd3 Merge "Remove return after GTEST_SKIP." 2020-03-04 18:29:33 +00:00
Elliott Hughes
edaf03ea18 Remove return after GTEST_SKIP.
Test: treehugger
Change-Id: I5efc31f82a979fcd8d3051c72ed8e6201b3b0d1b
2020-02-28 18:27:09 -08:00
Peter Collingbourne
c00691aa9e Merge "Handle the alternate signal stack correctly in android_unsafe_frame_pointer_chase." 2020-02-28 01:28:37 +00:00
Peter Collingbourne
b8d1348788 Handle the alternate signal stack correctly in android_unsafe_frame_pointer_chase.
If an alternate signal stack is set and the frame record is in bounds of
that stack, we need to use the top of the alternate signal stack for bounds
checking rather than the normal stack.

Bug: 150215618
Change-Id: I78b760d61b27da44f8e0cfee3fe94a791011fe58
2020-02-27 10:44:15 -08:00
Tamas Petz
d901ec6964 [unit tests] Add '-mbranch-protection=standard' flag to arm64
This change adds standard branch protection to bionic unit tests
for arm64 targets. For more information see
https://developer.arm.com/search#q=branch-protection

Both Armv8.3-A Pointer Authentication (using the A-key) hint-space
instructions and Armv8.5-A Branch Target Identification hint-space
landing pads are added to the generated code.

Test: 1. Tested on flame
      2. Tested on FVP

Change-Id: Ice991c538a9101448dea64c357f3f6bfb93877eb
2020-02-27 12:58:13 +01:00
Elliott Hughes
33318f5197 Merge "Add a libc wrapper for statx(2)." 2020-02-25 16:37:09 +00:00
Elliott Hughes
c5d9036f80 Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>.
Noticed by ARM when adding BTI support to the linker.

Test: treehugger
Change-Id: If3b87d0bd4682ff478b7805251fc9a88a7f439f9
2020-02-24 09:52:14 -08:00
Elliott Hughes
733cedd1c4 Add a libc wrapper for statx(2).
Bug: http://b/127675384
Bug: http://b/146676114
Test: treehugger
Change-Id: I844edc12f62717e579870a040cf03dfe60dc280b
2020-02-23 11:36:53 -08:00
Peter Collingbourne
45819dde10 Allow android_mallopt(M_SET_HEAP_TAGGING_LEVEL) to control scudo heap tagging.
The tag level may now be async, which is now the default. When the tag level
is set to none, memory tagging is disabled in the allocator using the new
API proposed in https://reviews.llvm.org/D70762 .

Bug: 135772972
Change-Id: I847f5822a70913c446ed9ffa13792177bbfc96af
2020-02-20 15:25:08 -08:00
Peter Collingbourne
c8cef93f24 Allow nested usage of ScopedDisableMTE.
An upcoming change to scudo will cause us to start calling
android_unsafe_frame_pointer_chase() from within the allocator. Since this
function uses ScopedDisableMTE, this would otherwise make it unsafe to use
the allocator from within ScopedDisableMTE. This seems like an unreasonable
restriction, so make ScopedDisableMTE save the PSTATE.TCO state in the
constructor and restore it in the destructor.

Bug: 135772972
Change-Id: I47e18d5fb2929efd5a58676488180cd85731007b
2020-02-18 13:13:57 -08:00
Ivan Lozano
c65b55cded Merge "Remove XOM properties." 2020-02-14 14:42:49 +00:00
Ivan Lozano
3e928edc77 Remove XOM properties.
XOM is no longer supported by the build system, so remove these
properties.

Bug: 123034666
Bug: 147300048
Test: Build succeeds.
Change-Id: I77efc98241f45b1a78b1cca5560f64eef5ef22f4
2020-02-13 14:20:44 -05:00
Elliott Hughes
6a65ccdf52 Remove mips test workarounds.
The mips/mips64 targets were never able to pass these tests, and the
supported architectures don't need any of these workarounds.

Test: treehugger
Change-Id: I640a8b7a98ae13d9d9cdb09b0fbef61d31d4c79a
2020-02-13 09:48:14 -08:00
Christopher Ferris
cce88c0a03 Update malloc_info test for scudo.
Scudo implemented malloc_info for the primary allocator, so add some
small amount of validation.

Test: Ran the malloc_info tests and verified they pass.
Change-Id: Ib7c609e46cc1ed73fa5c042df92fa9b568880f21
2020-02-12 17:41:01 -08:00
Mitch Phillips
242387d0cf [GWP-ASan] [malloc-tests] Scan GWP-ASan regions in maps.
GWP-ASan is part of the native allocator, and may allocate some memory.
When GWP-ASan is enabled, the malloc tests need to look inside of
GWP-ASan regions as well for native allocations.

Bug: 135634846
Test: atest bionic-unit-tests
Change-Id: Ibb78f9c9e7e96a437cffce013facd18708799b0e
2020-02-11 16:08:17 -08:00
Mitch Phillips
892d0286c4 [Elf TLS] [GWP-ASan] Update ELF TLS test.
GWP-ASan introduces two Initial-Exec thread-local variables into
libc.so. This causes the ELF TLS test to understandably fail, and needs
to be patched up.

Bug: 148606979
Test: atest bionic-unit-test
Change-Id: I77500a00edb55cb7bcd3cd3faffb76d2339ab42c
2020-02-07 01:40:05 +00:00
Ryan Prichard
f7c40da307 Merge changes from topic "import-lib-access"
* changes:
  Ignore symbols of imported libs' dependencies
  Comment two linker namespace functions
  Rename dlsym_handle_lookup:6 to dlsym_handle_lookup_impl
2020-02-04 21:46:15 +00:00
Ryan Prichard
22fa3dde07 Ignore symbols of imported libs' dependencies
When a library is present in a namespace via the secondary_namespaces
list (i.e. the executable, LD_PRELOAD, DF_1_GLOBAL, or
android_create_namespace inheritance), then we want to search that
library's symbols, but not the symbols of its dependencies. Otherwise,
we want to search the dependencies to handle cross-NS dependency.

Bug: http://b/148569846
Test: bionic unit tests
Change-Id: If798d69de28ed5c0f1a155e4ff85c7e08934e531
2020-02-03 14:20:40 -08:00
Peter Collingbourne
5f45c18a7f Add an android_unsafe_frame_pointer_chase function.
This function will be used by Scudo and GWP-ASan to efficiently collect
stack traces for frames built with frame pointers.

Bug: 135634846
Bug: 135772972
Change-Id: Ic63efdbafe11dfbb1226b5b4b403d53c4dbf28f3
Merged-In: Ic63efdbafe11dfbb1226b5b4b403d53c4dbf28f3
2020-02-03 10:30:45 -08:00
Peter Collingbourne
4fe5b783a4 Merge "Add some MTE-related helpers." 2020-01-31 00:00:44 +00:00
Josh Gao
7596250722 Move fdtrack APIs to LLNDK.
Test: logcat -c; fdtrack_test; logcat -d
Change-Id: Ib6f75a7c8bbc4d6efa0708dcbbfe4ad3c0641022
2020-01-30 13:55:10 -08:00
Josh Gao
97271920bf Add a tool to track down fd leaks.
Add a hook that's called upon file descriptor creation to libc, and a
library that uses it to capture backtraces for file descriptor creation,
to make it easier to hunt down file descriptor leaks.

Currently, this doesn't capture all of the ways of creating a file
descriptor, but completeness isn't required for this to be useful as
long as leaked file descriptors are created with a function that is
tracked. The primary unhandled case is binder, which receives file
descriptors as a payload in a not-trivially-parsable byte blob, but
there's a chance that the leak we're currently trying to track down
isn't of a file descriptor received over binder, so leave that for
later.

Bug: http://b/140703823
Test: manual
Change-Id: I308a14c2e234cdba4207157b634ab6b8bc539dd9
(cherry picked from commit b7eccd4b15)
2020-01-30 13:55:10 -08:00
Peter Collingbourne
6f1fd68817 Add some MTE-related helpers.
mte_supported() lets code efficiently detect the presence of MTE, and
ScopedDisableMTE lets code disable MTE RAII-style in a particular region
of code.

Bug: 135772972
Change-Id: I628a054b50d79f67f39f35d44232b7a2ae166afb
2020-01-30 10:56:50 -08:00
Elliott Hughes
09e77f35ab _FILE_OFFSET_BITS=64 support for fcntl.
On Android, fcntl is always implemented by fcntl64(2). This means that
an LP32 binary can `fcntl(F_SETLK, struct flock)` (because fcntl64(2)
passes through to the 32-bit fcntl(2) to handle F_SETLK), and it can
also `fcntl(F_SETLK64, struct flock64)`. What it can't do before this
patch is set _FILE_OFFSET_BITS=64 and then `fcntl(F_SETLK, struct
flock)` where that `struct flock` is actually implicitly `struct
flock64`.

Move the kernel uapi structs out of the way, define them ourselves based
on __LP64__ and _FILE_OFFSET_BITS, and fix up the relevant F_ constants.

(Also add a .clang-format to turn off clang-format in libc/include/.)

Bug: N/A
Test: treehugger (and strace!)
Change-Id: Iccd6c83d9133e1efcf93a7b49a6ae0f1bbd3d58b
2020-01-29 19:36:14 -08:00
Christopher Ferris
201dcf491b Add a disabled test to verify alloc after fork.
The alloc after fork is a test that should pass, but jemalloc
doesn't right now. Leave the test disabled until the native
allocator can pass this.

Test: Ran the test 1000 times on glibc to verify it passes.
Test: On device, verified it does not run.
Change-Id: I482af4db2fee81c947ac081c7a6f25a2aff80350
2020-01-29 14:40:37 -08:00
Elliott Hughes
35a09a3493 Merge "Test all four supported relocation encodings." 2020-01-29 16:44:20 +00:00
Elliott Hughes
6dd1f587c8 Test all four supported relocation encodings.
Test (a) that we can load the library, but also (b) that readelf thinks
it contains the relocation encoding we were expecting. Do this for all
four of RELR, ANDROID_RELR, relocation packer, and the original ELF
relocation encoding.

Bug: http://b/147452927
Test: treehugger
Change-Id: I5fab72f99d46991c1b206a1c15c76e185b7148b3
2020-01-28 17:59:23 -08:00