Commit graph

2831 commits

Author SHA1 Message Date
Evgenii Stepanov
071416b700 Use PROT_NONE on the unused parts of CFI shadow.
This replaces a single 2Gb readable memory region with a bunch of tiny
regions, and leaves the bulk of 2Gb mapped but unaccessible. This makes
it harder to defeat ASLR by probing for the CFI shadow region.

Sample CFI shadow mapping with this change:
7165151000-716541f000 ---p 00000000 00:00 0                              [anon:cfi shadow]
716541f000-7165420000 r--p 00000000 00:00 0                              [anon:cfi shadow]
7165420000-71654db000 ---p 00000000 00:00 0                              [anon:cfi shadow]
71654db000-71654dc000 r--p 00000000 00:00 0                              [anon:cfi shadow]
71654dc000-71654dd000 r--p 00000000 00:00 0                              [anon:cfi shadow]
71654dd000-71654f0000 ---p 00000000 00:00 0                              [anon:cfi shadow]
71654f0000-71654f1000 r--p 00000000 00:00 0                              [anon:cfi shadow]
71654f1000-71e5151000 ---p 00000000 00:00 0                              [anon:cfi shadow]

This change degrades CFI diagnostics for wild jumps and casts (i.e. when
the target of a CFI check is outside of any known library bounds). This
is acceptable, because CFI does not have much to tell about those cases
anyway. Such bugs will show up as SEGV_ACCERR crashes inside
__cfi_slowpath in libdl.so from now on.

Bug: 158113540
Test: bionic-unit-tests/cfi_test.*
Test: adb shell cat /proc/$PID/maps | grep cfi

Change-Id: I57cbd0d3f87eb1610ad99b48d98ffd497ba214b4
Merged-In: I57cbd0d3f87eb1610ad99b48d98ffd497ba214b4
2020-06-12 12:22:32 -07:00
Elliott Hughes
cdb4a26d29 Update upstream OpenBSD gdtoa.
Also add a test for the bug that this fixes.

Bug: http://b/152588929
Test: treehugger
Change-Id: I58055b3ebaef457721bb4f5d8a8710025122b2e7
2020-06-11 12:57:37 -07:00
Evgeny Eltsin
15cbad3f59 Merge "Skip pthread.pthread_create__mmap_failures with native_bridge" 2020-06-09 19:38:23 +00:00
Evgeny Eltsin
45b36c2921 Skip pthread_leak* tests with native_bridge
Bug: 37920774
Bug: 157394871
Test: bionic-unit-tests --gtest_filter=*leak*
Change-Id: Ifc5b66e4b640d1abae4dcf8dbc28612d24c7e972
2020-06-09 19:24:25 +02:00
Evgeny Eltsin
b4f7aaac5c Skip pthread.pthread_create__mmap_failures with native_bridge
The test reserves all memory but the minimum required to create a
thread. However, after the thread is created, native_bridge needs more
memory to translate and run the thread function.

This might be prevented by native_bridge preallocating a memory buffer
to be used for translation. But, first, this complication seems to be
needed just for this kind of tests, and, second, it is pretty flaky
regarding changes both in native_bridge and bionic.

Looks better to disable this test with native_bridge.

Bug: 67745607
Bug: 148608153
Bug: 157394871
Test: bionic-unit-tests --gtest_filter=pthread.pthread_create__mmap_failures
Change-Id: I42ce2b5a01a7d9f10d952a5fc7b75d51fa89072a
2020-06-09 15:58:49 +02:00
Evgeny Eltsin
b56d1182d1 Add util to skip tests with native_bridge
Bug: 37920774
Bug: 157394871
Test: bionic-unit-tests
Change-Id: Id949c9e568fd068daaf405a377813ee1480c2df7
2020-06-08 21:12:56 +02:00
Treehugger Robot
7ce3f2cb39 Merge "Trivial test for difftime(3)." 2020-06-06 03:51:46 +00:00
Elliott Hughes
208fdd1963 Trivial test for difftime(3).
pirama made me do this.

Test: treehugger
Change-Id: I0cf4466e494d92c96802e763b99346f7517bf3d7
2020-06-05 17:19:00 -07:00
Treehugger Robot
6a642f7760 Merge "Add newline at end of error message" 2020-06-01 18:43:33 +00:00
Pirama Arumuga Nainar
cb4a7c81e0 Add newline at end of error message
So the message gets flushed before the following abort.

Test: bionic-unit-tests without bionic-loader-test-libs at the expected
      relative path shows the error message.
Change-Id: I53bb27a88b73c9d8f4bb76560752f99a104d71ca
2020-05-30 16:46:20 -07:00
vichang
cacda52a0a Merge "Revert "Disable dlfcn#dlopen_system_libicuuc_ tests due to test failures on cuttlefish"" 2020-05-20 16:01:53 +00:00
Josh Gao
54e502e66a Revert "Temporarily disable FdsanTest.vfork."
This reverts commit b4cbff351f.

Bug: http://b/156400255
Test: none
Change-Id: I3a936542ccff8989b4671f3e03dd9d1d5559d6ff
2020-05-18 12:59:38 -07:00
vichang
b8cd7e7f58 Revert "Disable dlfcn#dlopen_system_libicuuc_ tests due to test failures on cuttlefish"
This reverts commit 01fb8d7120.

Reason for revert: Re-land the test after fixing b/156397945

Bug: 156397945
Change-Id: Ie9ec5fef7a308e28d512c6438c5c06758bdbcf06
2020-05-15 22:01:00 +00:00
Christopher Ferris
11f92fe9b9 Remove reference to deprecated option.
Test: atest CtsBionicTestCases
Change-Id: Ib23bb8dd1bac5f84d73516fd74a41bd9a81ca2da
2020-05-14 16:48:44 -07:00
Josh Gao
b4cbff351f Temporarily disable FdsanTest.vfork.
Bug: http://b/156400255
Test: none
Change-Id: I48e09e0ea84742933bea88d009f8ff0bffacfdc3
2020-05-12 15:17:02 -07:00
Victor Chang
01fb8d7120 Disable dlfcn#dlopen_system_libicuuc_ tests due to test failures on cuttlefish
Bug: 156315785
Test: atest CtsBionicTestCases
Change-Id: I6d61a2dcf55ebf67587ccf2653af3aca493b022d
2020-05-12 10:10:32 +00:00
Treehugger Robot
e3bc50d44f Merge changes If42905f3,Id351a993,I8a082fd0
* changes:
  fdtrack: don't do anything while vforked.
  fdsan: don't do anything when vforked.
  Track whether a thread is currently vforked.
2020-05-12 07:04:58 +00:00
vichang
10bad3e882 Merge "Move libicuuc.so into com.android.i18n module." 2020-05-11 11:37:06 +00:00
Josh Gao
4129113128 fdtrack: don't do anything while vforked.
Bug: http://b/153926671
Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator
Change-Id: If42905f3d6a76ed70a45e5b9edd029ffd7789045
2020-05-07 20:18:45 -07:00
Josh Gao
65fb2a7f03 fdsan: don't do anything when vforked.
Bug: http://b/153926671
Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator
Change-Id: Id351a993e396774b68239edfef83d9e81205290b
2020-05-07 20:18:40 -07:00
Josh Gao
2303283740 Track whether a thread is currently vforked.
Our various fd debugging facilities get extremely confused by a vforked
process closing file descriptors in preparation to exec: fdsan can
abort, and fdtrack will delete backtraces for any file descriptors that
get closed. Keep track of whether we're in a vforked child in order to
be able to detect this.

Bug: http://b/153926671
Test: 32/64-bit bionic-unit-tests on blueline, x86_64 emulator
Change-Id: I8a082fd06bfdfef0e2a88dbce350b6f667f7df9f
2020-05-07 19:44:27 -07:00
Victor Chang
f248d2de84 Move libicuuc.so into com.android.i18n module.
Change the location set in the linker

Bug: 130219528
Bug: 138994281
Test: atest CtsBionicTestCases
Test: atest CtsJniTestCases
Change-Id: I215a8e023ccc4d5ffdd7df884c809f8d12050c8f
2020-05-07 23:15:01 +00:00
Peter Collingbourne
144a6ab341 Merge "Introduce a new heap tagging level, M_HEAP_TAGGING_LEVEL_SYNC." 2020-05-07 17:51:51 +00:00
Peter Collingbourne
d3060019de Introduce a new heap tagging level, M_HEAP_TAGGING_LEVEL_SYNC.
The SYNC tagging level enables stack trace collection for allocations and
deallocations, which allows allocation and deallocation stack traces to
appear in tombstones when encountering a tag check fault in synchronous tag
checking mode.

Bug: 135772972
Change-Id: Ibda9f51b29d2c8e2c993fc74425dea7bfa23ab1e
2020-05-05 13:28:16 -07:00
Alistair Delva
bed98c0deb Fix argument order in api level test
Looks like the arguments were unintentionally swapped?

Bug: 155526611
Change-Id: I39d49f94387cfd337c89becb5eb6f85ca638bef1
Signed-off-by: Alistair Delva <adelva@google.com>
2020-05-03 20:10:51 -07:00
Yabin Cui
e75527347a Merge "Fix foritfy test for clang update." 2020-05-01 05:28:39 +00:00
Treehugger Robot
9e42d38e21 Merge "fdtrack: fix accept test, add test for accept4." 2020-05-01 00:25:47 +00:00
Josh Gao
9413ae7366 fdtrack: fix accept test, add test for accept4.
accept creates an additional socket behind the scenes to communicate
with netd. Filter out events for temporarily created, but then closed
fds to allow for this.

Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I2168ddc60f307278e3257ffcdf591272d61d45bb
2020-04-30 16:17:04 -07:00
Martin Stjernholm
82c1096cac Merge "Reland "Make bionic_platform_headers available only for Bionic targets"." 2020-04-30 14:11:50 +00:00
Josh Gao
b107eab5ef fdtrack: add wrapper for socketpair.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I8b25accf00dc01f6fab351f3ba612f6b0ff9d094
2020-04-29 17:21:16 -07:00
Josh Gao
7de412443d fdtrack: add wrapper for eventfd.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I59013f0c4da0debbcc50269c64ae9db0cdc4eaa0
2020-04-29 17:21:16 -07:00
Josh Gao
a38331d833 fdtrack: add wrappers for epoll_create, epoll_create1.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I6c881e5d67596c543526536541d5b8086e21d9e9
2020-04-29 17:21:16 -07:00
Josh Gao
1fad5283a0 fdtrack: add wrappers for pipe, pipe2.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I66826f312a65ab9f1bd8193bf684e330baa952dc
2020-04-29 17:21:16 -07:00
Josh Gao
9d512402d4 fdtrack: add tests for individual wrappers.
Add tests for all of our existing wrappers (with one commented out,
because it's unexpectedly generating multiple events).

Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I552692aef952237c2eee0dabec61b7ea7fd230e3
2020-04-29 17:21:12 -07:00
Martin Stjernholm
a276343e14 Reland "Make bionic_platform_headers available only for Bionic targets".
The triggering reason for this change is that the SDK snapshot
generation cannot readily handle header libraries that are required for
targets that the SDK itself isn't available for. However, these include
files shouldn't be used without Bionic anyway.

Relanding unchanged - the build problem was due to a split topic.

Test: m checkbuild (on aosp_taimen)
Test: m (on aosp_taimen_hwasan)
Test: atest CtsBionicTestCases
Test: lunch fvp-userdebug && mmm bionic
Bug: 152255951
Change-Id: Iaf49597ea265e6f2a042de5ee873238073b2e545
2020-04-29 18:14:11 +01:00
Martin Stjernholm
ed95d0134d Revert "Make bionic_platform_headers available only for Bionic t..."
Reason for revert: Breaks rvc-d1-dev-plus-aosp: http://ab/6443190
Reverted Changes:
Ide447b89a:bionic_libc_platform_headers is only available whe...
Ia93cd3ec8:bionic_libc_platform_headers is only available whe...
Icdc495588:Make bionic_platform_headers available only for Bi...
Idfd7c87dc:bionic_libc_platform_headers is only available whe...

Bug: 152255951
Bug: 155269399
Change-Id: I214f1165bb0a7e59d3b35a13b3cceb1965be922b
2020-04-29 12:18:36 +00:00
Martin Stjernholm
249f726583 Make bionic_platform_headers available only for Bionic targets.
The triggering reason for this change is that the SDK snapshot
generation cannot readily handle header libraries that are required for
targets that the SDK itself isn't available for. However, these include
files shouldn't be used without Bionic anyway.

Test: m checkbuild (on aosp_taimen)
Test: m (on aosp_taimen_hwasan)
Test: atest CtsBionicTestCases
Test: lunch fvp-userdebug && mmm bionic
Bug: 152255951
Change-Id: Icdc49558893c5355860f78d23275c49ba0119900
2020-04-27 19:07:01 +01:00
Yabin Cui
ae1745d375 Fix foritfy test for clang update.
When doing checkbuild for make_fortify_compile_test.mk:
bionic/tests/clang_fortify_tests.cpp
error: 'error' diagnostics seen but not expected:
  Line 171: 'mempcpy' will always overflow; destination buffer has size 8, but size argument is 9
1 error generated.

Bug: 149839606
Test: run checkbuild.
Change-Id: I97371600f6183b5cee8c2a6b976f5bf33e1f781d
2020-04-17 19:07:36 +00:00
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