Commit graph

2783 commits

Author SHA1 Message Date
Elliott Hughes
e7fa613ea9 Merge "Track libziparchive API change." am: 9433a0299e
am: fd03d4a762

Change-Id: I5a9a45503c949d13e5f99afe108e9405ffc6162d
2019-05-06 17:39:10 -07:00
Ryan Prichard
9602fc4ae1 Merge "Revert fwalk/sfp locking to fix concurrent reads" am: f61ca22248
am: ab399dfd4a

Change-Id: Iaa08fc3d6035d9ad7a15a80a7f74b3bfce5d9b04
2019-05-06 17:38:26 -07:00
Ryan Prichard
c8e263becf Revert fwalk/sfp locking to fix concurrent reads
The locking can fail in a couple of ways:

 - A concurrent fread from an unbuffered or line-buffered file flushes
   the output of other line-buffered files, and if _fwalk locks every
   file, then the fread blocks until other file reads have completed.

 - __sfp can initialize a file lock while _fwalk is locking/unlocking it.

For now, revert to the behavior Bionic had in previous releases. This
commit reverts the file locking parts of commit
468efc80da.

Bug: http://b/131251441
Bug: http://b/130189834
Test: bionic unit tests
Change-Id: I9e20b9cd8ccd14e7962f7308e174f08af72b56c6
(cherry picked from commit c485cdb024)
2019-05-06 16:46:30 -07:00
Elliott Hughes
9433a0299e Merge "Track libziparchive API change." 2019-05-06 23:45:16 +00:00
Ryan Prichard
f61ca22248 Merge "Revert fwalk/sfp locking to fix concurrent reads" 2019-05-06 23:38:49 +00:00
George Burgess IV
db48e0c822 tests: use clang's -verify instead of FileCheck
Clang uses this for its own diagnostic tests. The nice feature it adds
here is that it fails if clang emits a diagnostic that we don't expect
(and we get to drop a dependency on FileCheck).

This also tweaks and renames file-check-cxx to reflect its new job.

Bug: 131861088
Test: mma
Change-Id: I77f7ce77869edaa23e2401e622ad7007d2fee06c
2019-05-04 11:53:12 -07:00
Ryan Prichard
c485cdb024 Revert fwalk/sfp locking to fix concurrent reads
The locking can fail in a couple of ways:

 - A concurrent fread from an unbuffered or line-buffered file flushes
   the output of other line-buffered files, and if _fwalk locks every
   file, then the fread blocks until other file reads have completed.

 - __sfp can initialize a file lock while _fwalk is locking/unlocking it.

For now, revert to the behavior Bionic had in previous releases. This
commit reverts the file locking parts of commit
468efc80da.

Bug: http://b/131251441
Bug: http://b/130189834
Test: bionic unit tests
Change-Id: I9e20b9cd8ccd14e7962f7308e174f08af72b56c6
2019-05-04 00:28:00 -07:00
Elliott Hughes
b51bb50471 Track libziparchive API change.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ieccd528a34b66de59fad78586dead6b1df9cae98
2019-05-03 22:45:41 -07:00
Christopher Ferris
f96e450f23 Fix malloc_info missing large allocs.
am: 125d32cb46

Change-Id: Ide2680c0fa59c2b9805f12045047cf1e6ab9f7eb
2019-05-03 07:59:37 -07:00
Christopher Ferris
db9706afc3 Fix malloc_info missing large allocs.
Also change the names of some of the functions to make it very obvious
that the functions being called are in je code.

Write new test to make sure mallinfo and malloc_info match.

Bug: 131864803

Test: New unit tests pass (along with all other bionic unit tests).
Change-Id: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
Merged-In: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
(cherry picked from commit 125d32cb46)
2019-05-03 07:21:45 -07:00
Christopher Ferris
125d32cb46 Fix malloc_info missing large allocs.
Also change the names of some of the functions to make it very obvious
that the functions being called are in je code.

Write new test to make sure mallinfo and malloc_info match.

Bug: 131864803

Test: New unit tests pass (along with all other bionic unit tests).
Change-Id: I26eda7e64f57a8c56cc8d70e3ed6a29dcb87f630
2019-05-03 14:15:12 +00:00
Elliott Hughes
cb28280bf1 Merge "Fix running tests/benchmarks on the host." am: dfa3231fae
am: 766c77f88e

Change-Id: I3672f2695ab95cb36b8c63228b2cf2dee0fc7eb2
2019-04-27 09:35:17 -07:00
Elliott Hughes
dfa3231fae Merge "Fix running tests/benchmarks on the host." 2019-04-27 16:15:21 +00:00
Elliott Hughes
4da99ffe5e Fix running tests/benchmarks on the host.
This was broken by all the mainline modules stuff. It's quite a bit
hairier to set up now, given that we don't have an apexd on the host.
An alternative might be to actually set up a fake /apex that points to
the bootstrap directories?

Test: ./benchmarks/run-on-host.sh 64
Test: ./tests/run-on-host.sh 64
Change-Id: If2c277ba492c7c443cdf51526ea42f56568e2ea6
2019-04-26 17:45:17 -07:00
Elliott Hughes
9082f4fd73 Merge "threads.h: Add C11 thread support." am: 8c3140a612
am: 3716c5320d

Change-Id: Ia843e59dbfa88d30a6f885bafdbb251323748c08
2019-04-24 14:01:38 -07:00
Elliott Hughes
8c3140a612 Merge "threads.h: Add C11 thread support." 2019-04-24 20:33:08 +00:00
Elliott Hughes
4206711352 threads.h: Add C11 thread support.
FreeBSD, glibc, and musl have all implemented C11 threads at this
point. POSIX is looking at how to align with it. Probably time to jump
on the bandwagon ourselves...

Implemented in the same style as <termios.h> so we can provide this
functionality even on older API levels. This does mean that this is
strictly more expensive than calling pthread functions directly.

Although this isn't in POSIX yet, assume that it's going to be basically
the same as C11 and add the header test anyway. We should revisit this
when POSIX actually adds <threads.h>.

Test: new tests
Change-Id: I8602d67ce71ca7f8ed1529daa0a8ea1feb083dd6
2019-04-24 09:12:29 -07:00
Ryan Prichard
53080db75a Merge "PIMutexUnlock: load owner_tid in non-common case" into qt-dev 2019-04-23 20:55:52 +00:00
Torne (Richard Coles)
ebfebd057a Only write main library's RELRO by default.
ANDROID_DLEXT_WRITE_RELRO was inadvertently writing out the RELRO
section of all libraries loaded during a given dlopen() call instead of
only the main library; since the other libraries are loaded at
unpredictable addresses this additional data is rarely useful.

Fix this to only happen when the
ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE flag is being used.

Bug: 128623590
Test: DlExtRelroSharingTest.CheckRelroSizes
Change-Id: I05e8651d06ce2de77b8c85fe2b6238f9c09691ad
(cherry picked from commit 5d10374947)
2019-04-23 12:21:56 -04:00
Ryan Prichard
ea722a0779 PIMutexUnlock: load owner_tid in non-common case
For a recursive or errorcheck PI mutex, the old_owner variable wasn't
being initialized. As a result, unlocking a doubly-locked recursive
mutex owned by another thread decremented the mutex counter. Instead, the
unlock call should fail with EPERM.

Bug: http://b/130841532
Test: bionic-unit-tests
Test: bionic-unit-tests-glibc --gtest_filter='pthread.pthread_mutex_lock*'
Change-Id: I37adb094cb2ce8d51df7b4f48e8d6bc144436418
(cherry picked from commit 4b6c0f5dce)
2019-04-23 00:19:30 -07:00
Torne (Richard Coles)
f0fe5b1bc1 Merge "Only write main library's RELRO by default." am: 401e2efa39
am: 33e88b0caa

Change-Id: I86510268396a09d13ca7b6359cc878670269e665
2019-04-22 17:12:16 -07:00
Treehugger Robot
401e2efa39 Merge "Only write main library's RELRO by default." 2019-04-22 23:26:36 +00:00
Ryan Prichard
2cedfb5291 Merge "PIMutexUnlock: load owner_tid in non-common case" am: b250766282
am: 3a186fa215

Change-Id: I08e060df1dd200142a2cf54f458349f04ffa2da4
2019-04-22 14:27:15 -07:00
Ryan Prichard
4b6c0f5dce PIMutexUnlock: load owner_tid in non-common case
For a recursive or errorcheck PI mutex, the old_owner variable wasn't
being initialized. As a result, unlocking a doubly-locked recursive
mutex owned by another thread decremented the mutex counter. Instead, the
unlock call should fail with EPERM.

Bug: http://b/130841532
Test: bionic-unit-tests
Test: bionic-unit-tests-glibc --gtest_filter='pthread.pthread_mutex_lock*'
Change-Id: I37adb094cb2ce8d51df7b4f48e8d6bc144436418
2019-04-19 17:16:16 -07:00
Torne (Richard Coles)
5d10374947 Only write main library's RELRO by default.
ANDROID_DLEXT_WRITE_RELRO was inadvertently writing out the RELRO
section of all libraries loaded during a given dlopen() call instead of
only the main library; since the other libraries are loaded at
unpredictable addresses this additional data is rarely useful.

Fix this to only happen when the
ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE flag is being used.

Bug: 128623590
Test: DlExtRelroSharingTest.CheckRelroSizes
Change-Id: I05e8651d06ce2de77b8c85fe2b6238f9c09691ad
2019-04-11 13:57:31 -04:00
Treehugger Robot
1701d887ac Merge "Move platform-private symbols out of libdl.so" 2019-04-05 16:45:49 +00:00
Ryan Prichard
3d7ebcdc72 Merge changes I59a8bc4a,Ic437d352 am: 93ea856949
am: 7287d1410f

Change-Id: I2629ec7e26b357ca778a9eb7bf00cf6778f60549
2019-04-04 18:10:17 -07:00
Ryan Prichard
3f05d3e971 Fix dlsym and dladdr for TLS symbols
* dlsym: call __tls_get_addr for TLS symbols

 * dladdr: skip TLS symbols

Bug: b/123772574
Test: bionic unit tests
Change-Id: I59a8bc4a7d455e1018b0d577b027b6417c8487cd
(cherry picked from commit e4d620bc80)
2019-04-04 16:46:59 -07:00
Ryan Prichard
93ea856949 Merge changes I59a8bc4a,Ic437d352
* changes:
  Fix dlsym and dladdr for TLS symbols
  Fix BionicAllocator comment
2019-04-04 20:38:47 +00:00
Dmytro Chystiakov
a9c347ccc2 Merge "Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations" am: 02accd0ff4
am: c011e04df6

Change-Id: Iab81349b19e8df469314a5c6e5ec538105436ec0
2019-04-04 08:56:53 -07:00
Treehugger Robot
02accd0ff4 Merge "Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations" 2019-04-04 14:59:21 +00:00
Ryan Prichard
e4d620bc80 Fix dlsym and dladdr for TLS symbols
* dlsym: call __tls_get_addr for TLS symbols

 * dladdr: skip TLS symbols

Bug: b/123772574
Test: bionic unit tests
Change-Id: I59a8bc4a7d455e1018b0d577b027b6417c8487cd
2019-04-03 18:19:50 -07:00
Torne (Richard Coles)
07603294cd Merge "Fix DLEXT_WRITE_RELRO when loading multiple libs." am: 865866ee2b am: c950489599
am: ce62c05753

Change-Id: I234ee6e837fe2609918cee82121aa3994afbd4d8
2019-04-03 09:12:36 -07:00
Treehugger Robot
865866ee2b Merge "Fix DLEXT_WRITE_RELRO when loading multiple libs." 2019-04-03 15:19:57 +00:00
Pirama Arumuga Nainar
74ce129f90 Merge "Move bionic-unit-tests-static to libclang_rt.builtins" am: 96c21e43b4 am: b993b94d41
am: 55615c7b2c

Change-Id: I40b8dc97589c0a48fed037d3a35be6e25ef1b48a
2019-04-03 08:19:53 -07:00
Pirama Arumuga Nainar
0d16a31664 Move bionic-unit-tests-static to libclang_rt.builtins
Bug: http://b/129728267
Bug: http://b/117167374

This test is now built with XOM (because libm now uses XOM) but it
should also use libclang_rt.builtins since libgcc is not built with XOM.

Test: bionic-unit-tests-static passes (but used to segfault with XOM
exceptions without this change).

Change-Id: I0b1dfe52e48db5f5e9386c7722ecd91e155be56f
2019-04-02 22:45:29 -07:00
Torne (Richard Coles)
fa9f7f28d4 Fix DLEXT_WRITE_RELRO when loading multiple libs.
ANDROID_DLEXT_WRITE_RELRO was causing the GNU RELRO sections of
libraries to become corrupted if more than one library was being loaded
at once (i.e. if the root library has DT_NEEDED entries for libraries
that weren't already loaded). The file offset was not being correctly
propagated between calls, so after writing out the (correct) RELRO data
to the file, it was mapping the data at file offset 0 for all libraries,
which corrupted the data for all but one of the libraries.

Fix this by passing file_offset as a pointer the same way that
phdr_table_map_gnu_relro does.

Bug: 128623590
Test: tbd
Change-Id: I196cd336bd5a67454e89fd85487356b1c7856871
2019-04-02 18:06:12 -04:00
Christopher Ferris
667457767e Merge "Create a lib that uses scudo instead of jemalloc." am: d486e024c6 am: b525ee4a11
am: f3edfb5773

Change-Id: Ie30808227d135bd9b60f0ae8c6c408523e7c6ea7
2019-04-01 19:13:34 -07:00
Christopher Ferris
fc26d71af1 Create a lib that uses scudo instead of jemalloc.
The media processes already use scudo as their allocator. However, it
doesn't really correctly replace the normal allocation functions, so create
a set of wrappers that allow us to use scudo closer to how jemalloc is used.

This is only a temporary change, and should be removed for the next
release of Android. In that version, we will be using standalone
scudo which won't require this wrapper code.

Bug: 123689570

Test: Ran new bionic unit tests. There are failures, but only with
Test: extensions that scudo does not support.

Change-Id: I0516c23d654a9b6c69b157c5501245d2e0b3d264
2019-04-01 13:02:49 -07:00
dimitry
8868d9e900 Move platform-private symbols out of libdl.so
Symbols not intended to be accessible from apps are moved to libdl_android.so

Test: bionic-unit-tests
Bug: http://b/129387775
Change-Id: Ib8ba6147a20cf56550c9a008f66570a2d419565a
(cherry picked from commit 2d6be9a751)
2019-04-01 13:16:33 +02:00
Yi Kong
d116f8d23b Merge "Modernise code to use override specifier" am: 4699cf6174 am: 2e3a19d5b4
am: d3a825fe61

Change-Id: Ia5e05fd2fdf4d6a003fe6960bca1bd41487ecc05
2019-03-29 19:42:35 -07:00
Yi Kong
358603a409 Modernise code to use override specifier
Generated by clang-tidy.

Test: m checkbuild
Change-Id: I8e23da6b8af31b291be2eefe9937ca222ea8a8c3
2019-03-29 14:27:27 -07:00
Dmytro Chystiakov
e712cd185f Fix Bionic dlfcn.dladdr_libc test case for 64bit binary translations
64bit libraries should be located in /system/lib64 directory
instead of /system/lib for platforms with emulated arhitecture.

This patch updated ALTERNATE_PATH_TO_SYSTEM_LIB for 64bit values

Test: run cts -m CtsBionicTestCases -t dlfcn.dladdr_libc

Change-Id: I29d6d36d15d7e61818c7ed1cfd0786745d9ae6a2
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
2019-03-29 13:49:12 -07:00
Dimitry Ivanov
3158355507 Merge "Move platform-private symbols out of libdl.so" 2019-03-28 09:05:52 +00:00
Elliott Hughes
d50f8bc35a Merge "tests: test both upper- and lower-case with strptime %P/%p." am: 2e824e3150 am: 9d1ae96262
am: 6f46e9eeb7

Change-Id: I579faf2ab1a465ce565a6b3631a0e54d8c6c0416
2019-03-27 14:15:26 -07:00
Treehugger Robot
2e824e3150 Merge "tests: test both upper- and lower-case with strptime %P/%p." 2019-03-27 20:54:59 +00:00
Elliott Hughes
1bff6265d1 Merge "Convert new tests to GTEST_SKIP." am: e7ee0731c3 am: 94cd62ccd1
am: cb78141d64

Change-Id: Ibf809532aa5cf8389d09a37bd145991732fc9a49
2019-03-27 13:22:51 -07:00
Treehugger Robot
e7ee0731c3 Merge "Convert new tests to GTEST_SKIP." 2019-03-27 20:04:49 +00:00
Elliott Hughes
cb70a9a700 Merge "strptime: support everything that strftime supports." am: ff923681be am: 06acbcfb64
am: d8dfb05b6b

Change-Id: I58582ccf8c82b89d27ffba0d3ab460f4e09264f2
2019-03-27 09:09:52 -07:00
Elliott Hughes
1167882a87 tests: test both upper- and lower-case with strptime %P/%p.
Test: ran tests
Change-Id: I7275808f2f0ae4f02d057542a13350895022910c
2019-03-27 08:56:49 -07:00
Elliott Hughes
109072038a Convert new tests to GTEST_SKIP.
These went in while we were waiting for the infrastructure to catch up.

Test: treehugger
Change-Id: I1179d1aba8f1369d320f82705958b36c6930babf
2019-03-27 08:51:02 -07:00
Elliott Hughes
7d3ed1435f Merge "bionic tests: use GTEST_SKIP." am: e08288465e am: 64bc28143f
am: 619d7bd404

Change-Id: I69aba8b645516a51dfa66394da67ff854f6e3016
2019-03-26 19:26:10 -07:00
Elliott Hughes
a1fb15bb67 strptime: support everything that strftime supports.
Our strptime was missing `%F`, `%G`, `%g`, `%P`, `%u`, `%V`, and
`%v`. Most of these are already supported upstream (and I've just pulled
their current implementation), but some aren't. We're horribly out of
sync anyway, so I'll upstream the missing pieces and then try to get us
back in sync later.

Test: new tests, but originally found by toybox trying to use %F
Change-Id: Ib1a10801a7a3b9c9189440c3b300109bde535fd9
2019-03-26 19:07:40 -07:00
Elliott Hughes
e08288465e Merge "bionic tests: use GTEST_SKIP." 2019-03-27 02:05:57 +00:00
Elliott Hughes
36fa2647af Merge "Fix running the tests on the host again." am: b0c33ecb99 am: 1f63174243
am: b462788ee1

Change-Id: I87615ed7b66bc3efa0da2ac4b697b31754a646f4
2019-03-26 17:50:24 -07:00
Elliott Hughes
8ceb95c506 Fix running the tests on the host again.
Bug: N/A
Test: ran the tests on the host under glibc
Change-Id: Id05a896bdd11b231304ed1a08ef24e1a661ee20d
2019-03-26 14:47:08 -07:00
Nick Kralevich
d4b46b3896 Merge "Make powerof2 macro ubsan safe" am: 1b6517b601 am: cdfe9d7d96
am: 91479bb201

Change-Id: I7f3513a4c009879a909e0eaeecc06b3990e634d7
2019-03-25 21:05:45 -07:00
Nick Kralevich
c50b6a2b89 Make powerof2 macro ubsan safe
Subtracting one from the smallest value expressable by the provided
variable could cause an underflow operation. In particular, this is
problematic when code similar to:

  uint64_t foo = 0;
  if (powerof2(foo)) {
    ...;
  }

is run with integer sanitization enabled. The macro would subtract one
from zero, underflowing and triggering the sanitizer.

Make the powerof2() macro ubsan safe, by explicitly handling underflows.

Note: This change DOES NOT make powerof2() accurate. We continue to
falsely return "true" for 0 and negative numbers (see attached tests).

Found while investigating Bug: 122975762
Test: see added testcase
Test: atest ziparchive-tests

Change-Id: I5408ce5c18868d797bcae8f115ddb7c4c1ced81e
2019-03-25 13:51:33 -07:00
Evgenii Stepanov
a27b0180a9 Merge "Disable malloc_info test under HWASan." am: e187d92062 am: c1437e8bf0
am: 18c641bbb9

Change-Id: I0902f47bb0e22abf52a341b7d138909bc86c8b7c
2019-03-22 16:03:48 -07:00
Evgenii Stepanov
8de6b46ad8 Disable malloc_info test under HWASan.
HWASan does not implement malloc_info.

Test: bionic-unit-tests with SANITIZE_TARGET=hwaddress
Change-Id: I61d50d9110fbca1784ed39950ed6c5540ca0c9a7
2019-03-22 13:23:18 -07:00
dimitry
2d6be9a751 Move platform-private symbols out of libdl.so
Symbols not intended to be accessible from apps are moved to libdl_android.so

Test: bionic-unit-tests
Change-Id: Ib8ba6147a20cf56550c9a008f66570a2d419565a
2019-03-20 12:16:57 +01:00
Evgenii Stepanov
02e63858d4 Merge "Annotate vfork for hwasan." am: 8b8e7d0461 am: 48c5b26a9a
am: a5446bcd76

Change-Id: I8c813020457a92db956c05eb1812cb9e9df2cd78
2019-03-19 21:39:18 -07:00
Evgenii Stepanov
505168e530 Annotate vfork for hwasan.
Call a hwasan hook in the parent return path for vfork() to let hwasan
update its shadow. See https://github.com/google/sanitizers/issues/925
for more details.

Bug: 112438058
Test: bionic-unit-tests
Change-Id: I9a06800962913e822bd66e072012d0a2c5be453d
2019-03-19 23:36:44 +00:00
Peter Collingbourne
425ea70447 Merge "Add a platform API for setting an allocation limit." am: 9d69d4ccae am: ef4af2fb8c
am: a51cc27724

Change-Id: I9e98264aa3000c381888a61dd2a0e413bb481893
2019-03-15 15:56:00 -07:00
Peter Collingbourne
9d69d4ccae Merge "Add a platform API for setting an allocation limit." 2019-03-15 21:51:46 +00:00
Elliott Hughes
7ce3788d19 Merge "Remove __INTRODUCED_IN_FUTURE." am: ea6c19a44b am: ff72341e77
am: 5d8cab8381

Change-Id: I11c4b80c535396d66e6f5f77bc853b28c917dbff
2019-03-15 14:20:25 -07:00
Elliott Hughes
ea6c19a44b Merge "Remove __INTRODUCED_IN_FUTURE." 2019-03-15 19:54:57 +00:00
Christopher Ferris
1fc5ccfe76 Add a platform API for setting an allocation limit.
Introduce an M_SET_ALLOCATION_LIMIT enumerator for android_mallopt(),
which can be used to set an upper bound on the total size of all
allocations made using the memory allocation APIs.

This is useful for programs such as audioextractor and mediaserver
which need to set such a limit as a security mitigation. Currently
these programs are using setrlimit(RLIMIT_AS) which isn't exactly
what these programs want to control. RLIMIT_AS is also problematic
under sanitizers which allocate large amounts of address space as
shadow memory, and is especially problematic under shadow call stack,
which requires 16MB of address space per thread.

Add new unit tests for bionic.

Add new unit tests for malloc debug that verify that when the limit
is enabled, malloc debug still functions for nearly every allocation
function.

Bug: 118642754
Test: Ran bionic-unit-tests/bionic-unit-tests-static.
Test: Ran malloc debug tests and perfetto integration tests.
Change-Id: I735403c4d2c87f00fb2cdef81d00af0af446b2bb
2019-03-15 10:54:55 -07:00
Yi Kong
8a83ba8fe5 Merge "Reduce reserved size for DlExtTest.ReservedRecursiveTooSmall test" am: 4c95542fdf am: 3251497a3f
am: b4c2a40c95

Change-Id: I442c904a1f5919e0a2962e31df8010234b653605
2019-03-14 20:09:42 -07:00
Yi Kong
1e7a150339 Reduce reserved size for DlExtTest.ReservedRecursiveTooSmall test
When built with clang-r353983, the ReservedRecursiveTooSmall test fail
due to the reserved memory is now large enough for android_dlopen_ext.
Reduce the reserved memory size to agree with ReservedTooSmall test.

Test: bionic-unit-tests
Bug: 126457671
Change-Id: I3e311a3f35b0de5d028fa1b9b3681d5ec32faee8
2019-03-14 16:25:45 -07:00
Elliott Hughes
5270017ab3 Remove __INTRODUCED_IN_FUTURE.
This hasn't been particularly useful, we haven't used it consistently,
and it has caused trouble.

Test: builds
Change-Id: Ic5b5b5124af98aa8301e602fd75b0eb72a5fc7f6
2019-03-14 13:34:21 -07:00
Elliott Hughes
bcaa454d32 bionic tests: use GTEST_SKIP.
Also be a bit more to the point in our messages, focusing on "why" not
"what".

Test: ran tests
Change-Id: I297806c7a102bd52602dcd2fcf7a2cd34aba3a11
2019-03-12 10:26:39 -07:00
Peter Collingbourne
72cf0b4311 Merge "linker: Handle libraries with disjoint mappings correctly." am: 432db6cfaf am: d7fc90e601
am: b3c32cd7b6

Change-Id: Icd7a4c71d2209ae822d2b7511ea159350be48b0a
2019-03-09 06:20:39 -08:00
Treehugger Robot
432db6cfaf Merge "linker: Handle libraries with disjoint mappings correctly." 2019-03-09 05:40:03 +00:00
Peter Collingbourne
b39cb3c31d linker: Handle libraries with disjoint mappings correctly.
It's possible and sometimes beneficial for a library to have disjoint mappings
and for other libraries to be mapped into the gap between the mappings using
ANDROID_DLEXT_RESERVED_ADDRESS. See for example the proposal for partitioning
in lld [1].

Because the find_containing_library and do_dl_unwind_find_exidx functions use
a simple bounds check to figure out whether a pointer belongs to a library
they will, given a pointer into a library mapped into the gap of a library
with disjoint mappings, return a pointer to the soinfo for the outer library
instead of the inner one, because the outer library will appear before the
inner one in the solist.

From a user perspective this means that we won't be able to unwind the inner
library's frames on 32-bit ARM with libgcc, dladdr() will return information
for the outer library given a pointer to the inner one and dlopen() et al will
use the linker namespace of the outer library when called from the inner one
(although they will usually be the same).

To make this work correctly, make it so that once find_containing_library
sees a match for the bounds check, it examines the library's PT_LOADs to
make sure that there is a mapping for the given address. This is similar
to how libgcc and libunwind_llvm already handle finding the PT_GNU_EH_FRAME
on non-ARM32 platforms [2,3]. do_dl_unwind_find_exidx is reimplemented in
terms of find_containing_library.

[1] http://lists.llvm.org/pipermail/llvm-dev/2019-February/130583.html
[2] e739ac0e25/libunwind/src/AddressSpace.hpp (L523)
[3] https://android.googlesource.com/toolchain/gcc/+/master/gcc-4.9/libgcc/unwind-dw2-fde-dip.c#294

Test: /data/nativetest{,64}/bionic-unit-tests/bionic-unit-tests on walleye-userdebug
Change-Id: I368fe6ad3c470b3dff80f7d9b04253566d63a7d2
2019-03-08 18:34:34 -08:00
Christopher Ferris
6c619a0da3 Refactor the malloc_info code.
malloc_info needs to be per native allocator, but the code treated it
like a global function that doesn't depend on the native memory allocator.

Update malloc debug to dump the actual pointers that it has been tracking.

Test: bionic-unit-tests pass.
Test: malloc debug tests pass.
Test: malloc hook tests pass.
Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e
Merged-In: I3b0d4d748489dd84c16d16933479dc8b8d79013e
(cherry picked from commit a3656a98b1)
2019-03-07 08:39:55 -08:00
Christopher Ferris
f6ea33916e Merge "Refactor the malloc_info code." 2019-03-07 16:28:22 +00:00
vichang
5f9634b004 Merge "bionic-unit-tests should depend on libandroidicu instead" am: 4e167f35d6 am: df9e4e5ae2
am: bbe4a4dd48

Change-Id: I4fa8b79c14b4a7e4faa9dc28bd990b71805bc577
2019-03-06 15:46:26 -08:00
vichang
4e167f35d6 Merge "bionic-unit-tests should depend on libandroidicu instead" 2019-03-06 23:05:24 +00:00
Victor Chang
ddcf488ef6 bionic-unit-tests should depend on libandroidicu instead
bionic has been moved to use libandroidicu instead of libicuuc.
This CL updates the unit test

Bug: 120659668
Test: m bionic-unit-tests && adb push out/target/product/walleye/data/nativetest/* /data/nativetest && adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Change-Id: I59a0589d18bfd6753215dc07874f3c472bd64cca
2019-03-06 18:29:55 +00:00
Christopher Ferris
a3656a98b1 Refactor the malloc_info code.
malloc_info needs to be per native allocator, but the code treated it
like a global function that doesn't depend on the native memory allocator.

Update malloc debug to dump the actual pointers that it has been tracking.

Test: bionic-unit-tests pass.
Test: malloc debug tests pass.
Test: malloc hook tests pass.
Change-Id: I3b0d4d748489dd84c16d16933479dc8b8d79013e
2019-03-05 12:52:55 -08:00
Christopher Ferris
c32e6747b7 Merge "Make aligned_alloc match the standard." am: b8ef55a4f8 am: 4917f6f575
am: 5cbbc36698

Change-Id: I396705b8822e1fca827e214d5a622f0c2651c979
2019-03-02 11:31:38 -08:00
Christopher Ferris
a22f5d5175 Make aligned_alloc match the standard.
Jemalloc does not verify that the size parameter is a multiple of
alignment. Fix this since it only went into P.

Fix the unit tests, and fix malloc debug/malloc hooks to handle this
new restrictive behavior.

Bug: 126944692

Test: Ran bionic unit tests.
Test: Ran bionic unit tests with malloc hooks enabled (no new tests fail).
Test: Ran bionic unit tests with malloc debug enabled (no new tests fail).
Test: Ran malloc debug unit tests.
Change-Id: I4d50785928815679c781ca729f998454d76b9192
2019-03-01 23:56:23 -08:00
Torne (Richard Coles)
d4184e7349 Merge "linker: allow using reserved space for multiple libraries." am: 7cdbd0d477 am: ac0e655b40
am: db850fa4b3

Change-Id: If60a4bccb7b8ca3cc9a9c41e818ab18cc6c8800e
2019-02-25 08:50:17 -08:00
Treehugger Robot
7cdbd0d477 Merge "linker: allow using reserved space for multiple libraries." 2019-02-21 16:06:17 +00:00
Torne (Richard Coles)
efbe9a5eef linker: allow using reserved space for multiple libraries.
Introduce a new flag ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE which
instructs the linker to use the reserved address space to load all of
the newly-loaded libraries required by a dlopen() call instead of only
the main library. They will be loaded consecutively into that region if
they fit. The RELRO sections of all the loaded libraries will also be
considered for reading/writing shared RELRO data.

This will allow the WebView implementation to potentially consist of
more than one .so file while still benefiting from the RELRO sharing
optimisation, which would otherwise only apply to the "root" .so file.

Test: bionic-unit-tests (existing and newly added)
Bug: 110790153
Change-Id: I61da775c29fd5017d9a1e2b6b3757c3d20a355b3
2019-02-20 17:29:36 -05:00
Tom Cherry
35e3d2ba85 Merge "Waive AID Range check for devices through Q" am: c46cc7d83d am: f75bca93cc
am: 0559ddb5ce

Change-Id: I8e5fd639daaf432368dcf89d179d50976bce17fb
2019-02-20 03:03:51 -08:00
Tom Cherry
9da8ff1270 Waive AID Range check for devices through Q
We still don't have a good way to create vendor AIDs in the system or
other non-vendor partitions, therefore we keep this check disabled.

Bug: 73062966
Test: treehugger
Change-Id: I7aed425899d6ec11a22702ccec82476eacdbc790
2019-02-19 13:24:59 -08:00
Sandeep Patil
63619b5816 Merge "bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile" am: cf6cec8489 am: 761b215dc7
am: bee2dda45c

Change-Id: I383c9e7e91755f387a19ecb1329e3cb391654a62
2019-02-15 15:25:17 -08:00
Treehugger Robot
cf6cec8489 Merge "bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile" 2019-02-15 23:03:00 +00:00
Christopher Ferris
5b2d135288 Merge "Refactor malloc common into distinct pieces." am: c2136b51aa am: 578f95aeb3
am: 13b4fcbb78

Change-Id: I0ca4a7293fc0fe24caf749960e78b797d3bf72b5
2019-02-13 11:20:47 -08:00
Christopher Ferris
c2136b51aa Merge "Refactor malloc common into distinct pieces." 2019-02-13 18:38:22 +00:00
Ryan Prichard
4df5b75a78 Merge "Only test tprel_missing_weak in dynamic binaries" am: 40f18976db am: 61d56a7a75
am: b233479974

Change-Id: Idf407c79b6caa6b6e68f217aa2c751b73b54c7fb
2019-02-12 16:47:34 -08:00
Christopher Ferris
e4cdbc4754 Refactor malloc common into distinct pieces.
The pieces:
- The malloc common shared by static and dynamic code (malloc_common.cpp).
- The code for shared libraries that includes any dlopen'ing
  (malloc_common_dynamic.cpp).
- The implementation of perfetto's heapprofd (malloc_heapprofd.cpp).

This makes it easier to see what's going on in the many different areas.
It should also make it easier to add the allocation capping option.

Other related changes:
- Update the unit tests for android_mallopt. All of the current options
  don't work on static binaries, so make sure that is reflected in the test.
- A few names changes to make sure that all code is consistent.

Test: Ran tests (malloc hooks/malloc debug/perfetto/bionic unit tests).
Change-Id: I0893bfbc0f83d82506fac5d1f37cf92fbdef6f59
2019-02-12 14:19:07 -08:00
Ryan Prichard
7fda2c9495 Only test tprel_missing_weak in dynamic binaries
Rename a test to be less confusing when this file tests unresolved weaks
with both TPREL and TLSDESC relocations.

Bug: http://b/123635978
Test: bionic unit tests
Change-Id: Id17d76a41159d134d16e84a699cc284662eb99bb
2019-02-11 18:37:17 -08:00
Sandeep Patil
7d2aea09dd bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile
Bug: 123532375
Test: Builds

Change-Id: I8e782d9050b4d6a0726e8c880d4064df99c763e5
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-02-10 17:27:39 -08:00
Christopher Ferris
c40c32935b Merge "Fix flakiness of mallinfo test." am: 2eb1fc9df0 am: ecd1c9e235
am: 078f208d3f

Change-Id: Iddd42fd6fef7ba60ba53b643142508ae5d74ee77
2019-02-07 16:58:33 -08:00
Christopher Ferris
4e56228637 Fix flakiness of mallinfo test.
The test was really only supposed to verify that mallinfo eventually
increase after allocations of certain sizes. Sometimes the mallinfo
returned decreases due to some compaction event, so don't fail in that
case.

Bug: 124060188

Test: Ran the test 2000 times (32 bit and 64 bit). It would fail within about
Test: 200 test iterations before.
Change-Id: Ie019107be163dcf275cedf4d1bc5759278def483
2019-02-07 14:20:03 -08:00
vichang
7680c41f21 Merge "Revert "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""" am: 1d3c56bc30 am: 598e2f22e8
am: c64f899f48

Change-Id: Ib90bed1d157c30531712dd64adc2b63408260b92
2019-02-07 04:45:23 -08:00
vichang
1d3c56bc30 Merge "Revert "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""" 2019-02-07 12:28:00 +00:00
Victor Chang
6cb719f0ed Revert "Revert "Allow dlopen("/system/lib/<soname>") for pre-Q""
This reverts commit 1906e77665
and fixes dlopen(nullptr)

It's enabled for the following .so libraries
libicuuc.so
libicui18n.so

This CL does not move the .so files into a APEX.
Thus, no visible effect before moving .so files.

Bug: 121248172
Test: dlfcn#dlopen_from_nullptr
Test: Perform the following test after moving libicuuc to /apex
      dlopen("/system/lib64/libicuuc.so") for targetSdkVersion < Q
Change-Id: Ia310ea566485fe00ca28e2203f4bffbd92243638
2019-02-07 01:17:37 +00:00
Evgenii Stepanov
39d86b1bd2 Merge "Cleanup bionic tests with hwasan." am: f827d82cdd am: d1e1a5e3d5
am: c2bc9b4ce3

Change-Id: I292a729985e514fb672963a50dc94d25e639f5f6
2019-02-06 14:48:46 -08:00
Evgenii Stepanov
f827d82cdd Merge "Cleanup bionic tests with hwasan." 2019-02-06 22:04:09 +00:00
Evgenii Stepanov
7cc6706370 Cleanup bionic tests with hwasan.
The tests were patched earlier to run with tagging heap allocator.
This change enables hwasan code instrumentation in the tests themselves,
and fixes the issues that arise, mainly in the code that:
* compares addresses of unrelated stack variables
* compares address of a stack variable with stack limits as found in
  /proc/self/maps
* writes address of a stack variable to a hardware watchpoint register
etc.

Note that static tests are broken at the moment, like all static
binaries. Dynamic tests pass 100% with this change.

Bug: 114279110, 124007027
Test: SANITIZE_TARGET=hwaddress; run dynamic bionic tests

Change-Id: I68b8df9dd3e30b47734ddc083811a75a7f27deaa
2019-02-06 13:59:16 -08:00
Evgenii Stepanov
97ef4571bd Merge "Fix use-after-pthread_exit in a test." am: 3f8bdb216c am: 7bf8ee1d51
am: 4f00c980e5

Change-Id: Ib2704b2ffea98d65f77a10d7e217efd58038d59c
2019-02-06 09:20:00 -08:00
Elliott Hughes
cc33c4cf11 Merge "Avoid writing to a zero-capacity buffer." am: 166dfd6f49 am: 00fe14f20a
am: 57755188be

Change-Id: I7699655eba18069e710ba887a5a2205e538e0035
2019-02-06 08:54:47 -08:00
Treehugger Robot
3f8bdb216c Merge "Fix use-after-pthread_exit in a test." 2019-02-06 16:42:47 +00:00
Elliott Hughes
166dfd6f49 Merge "Avoid writing to a zero-capacity buffer." 2019-02-06 16:39:33 +00:00
Evgenii Stepanov
352853a535 Fix use-after-pthread_exit in a test.
HWASan reports access to a local variable after the owning thread has
called pthread_exit.

Bug: 114279110
Test: enable hwasan in tests/Android.bp; run pthread_DeathTest.pthread_bug_37410
Change-Id: Ic04a2b3dce092d7ab3cbefab1da64731e0c7afb9
2019-02-05 17:37:37 -08:00
Elliott Hughes
d85cd5e1dd Merge "Move NetBSD string routines to OpenBSD." am: e7c5954b31 am: 754cb9644f
am: 5481a6a344

Change-Id: I88b858e93c372b08a7e8ee7bc16cc0977cb8b6c0
2019-02-05 17:07:29 -08:00
Elliott Hughes
288465d6e9 Avoid writing to a zero-capacity buffer.
Bug: http://b/120752721
Test: ran tests
Change-Id: I3f03ae204ab5de40fd4402a5562c50ffe51ef998
2019-02-05 15:00:13 -08:00
Elliott Hughes
fbac97a54c Move NetBSD string routines to OpenBSD.
NetBSD seems to be the least well maintained of our three BSD upstreams,
and it's already the one we use the least. Let's push a little further
in that direction...

Test: new smoke tests
Change-Id: Idfebd11794445fe14cbfa07177a7392a7b36a5e4
2019-02-05 12:15:27 -08:00
Elliott Hughes
3086b7a924 Merge "Pass caller names to __pthread_internal_find for better errors." am: 3912efa503 am: e6cf682ef5
am: c82a57e823

Change-Id: I99f950692ce45207d668750354b493f94916072c
2019-02-04 08:59:30 -08:00
Elliott Hughes
3912efa503 Merge "Pass caller names to __pthread_internal_find for better errors." 2019-02-04 16:42:27 +00:00
Peter Collingbourne
1f805c6c67 Merge "Implement ifunc support for static executables." am: c1d579798e am: e70872c1fc
am: 559f6a6d8e

Change-Id: I30f45bbc86e49ce5632fc349f41058360f4c8486
2019-02-02 16:23:19 -08:00
Treehugger Robot
c1d579798e Merge "Implement ifunc support for static executables." 2019-02-03 00:04:46 +00:00
Elliott Hughes
5bb113cba2 Pass caller names to __pthread_internal_find for better errors.
On http://b/122082295 we had this abort:

  12-27 15:29:31.237 10222 10814 10848 F libc    : invalid pthread_t 0xb1907960 passed to libc

This wasn't super helpful. We can do better. Now you get something like
this instead:

  03-27 02:34:58.754 25329 25329 W libc    : invalid pthread_t (0) passed to pthread_join

Test: adb shell crasher
Bug: http://b/123255692
Change-Id: I1d545665a233308480cc3747ec3120e2b6de0453
2019-02-01 16:31:10 -08:00
Treehugger Robot
c378180cb8 Merge "dlfcn.dt_runpath* tests are amended to handle LIB" 2019-02-01 16:15:44 +00:00
Elliott Hughes
f5a8f9fb71 Merge "Updates for glibc 2.17." am: 58dd1cbd7f am: 32319f7717
am: a7d3302b25

Change-Id: I58839e1fee366ca3b69db38d19ab91033f55917a
2019-01-30 21:37:21 -08:00
Elliott Hughes
18181e6a0a Updates for glibc 2.17.
Bug: http://b/111358231
Test: builds
Change-Id: I542b2a9acc74261ad12b78e4add0f3ae77c3656c
2019-01-30 13:52:36 -08:00
Jiyong Park
fa4dcb418d dlfcn.dt_runpath* tests are amended to handle LIB
LIB is now expanded to either lib or lib64. Add a new lib
libtest_dt_runpath_y which is under lib or lib64 directory to the tests.

Test: run bionic-unit-tests

Merged-In: Ib051d8cae4d50b452759d594c87126b45bc9e959
Change-Id: Ib051d8cae4d50b452759d594c87126b45bc9e959
2019-01-30 21:05:03 +09:00
TreeHugger Robot
0a354166fc Merge "dlfcn.dt_runpath* tests are amended to handle LIB" 2019-01-30 12:02:07 +00:00
Jiyong Park
d7ca67859f dlfcn.dt_runpath* tests are amended to handle LIB
LIB is now expanded to either lib or lib64. Add a new lib
libtest_dt_runpath_y which is under lib or lib64 directory to the tests.

Test: run bionic-unit-tests

Change-Id: Ib051d8cae4d50b452759d594c87126b45bc9e959
2019-01-30 17:44:36 +09:00
Ryan Prichard
aa3dd3d520 Merge "Add tests for dynamic ELF TLS" 2019-01-30 04:46:54 +00:00
George Burgess IV
dd19ddc191 Merge "bionic: update for glibc 2.17" am: d7873cf94e am: 5edb60efa9
am: 7f167e2544

Change-Id: Ibaf2501f146db93aff298e3b084626cffe4b2ac6
2019-01-29 15:11:07 -08:00
George Burgess IV
d7873cf94e Merge "bionic: update for glibc 2.17" 2019-01-29 22:24:58 +00:00
Ryan Prichard
06d2d790ad Add tests for dynamic ELF TLS
Bug: http://b/78026329
Test: bionic unit tests
Merged-In: I508fa38b331eeec7dae53039b4b1ec6cedea3034
Change-Id: I508fa38b331eeec7dae53039b4b1ec6cedea3034
2019-01-29 08:35:10 +00:00
Ryan Prichard
e84ebbb46f Add tests for dynamic ELF TLS
Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I508fa38b331eeec7dae53039b4b1ec6cedea3034
2019-01-28 21:22:52 -08:00
Ryan Prichard
c77e201a3b Merge commit 'ecdc451ccf9e3f6fa4a89ec99f0f59b0a8080516' into stage-aosp-master am: 41be8e99b3
am: c872f7d661

Change-Id: Ie7c0f20869cc3652f926592c5de6cb75807b0657
2019-01-28 19:24:51 -08:00
Ryan Prichard
ecdc451ccf Merge changes I3c9b1292,I05c28d6a,I788c4a95,If8cd798f,I1c8d1cd7, ...
* changes:
  Implement dynamic TLS accesses and allocation
  Implement TLS_DTPMOD and TLS_DTPREL relocations
  Ignore DT_TLSDESC_GOT / DT_TLSDESC_PLT
  Disable the dlfcn.dlopen_library_with_ELF_TLS test
  Add BionicAllocator::memalign
  Move the linker allocator into libc
  Replace some of linker_allocator's header includes
2019-01-28 19:32:59 +00:00
Treehugger Robot
122ecb1ca8 Merge "bionic_unit_tests: Remove dependency on libpagemap" 2019-01-27 03:42:35 +00:00
TreeHugger Robot
e40d8f489c Merge "bionic_unit_tests: Remove dependency on libpagemap" 2019-01-27 00:39:46 +00:00
Ryan Prichard
5f5a1929e8 Disable the dlfcn.dlopen_library_with_ELF_TLS test
This test is verifying that an ELF TLS solib can't be loaded, but once
ELF TLS is implemented, it *can* be loaded. Removing the test requires
coordinated changes with internal test suites.

I could modify the test to verify that the solib was successfully loaded,
but support for dynamic ELF TLS appears across a few different CLs.

Bug: http://b/78026329
Test: bionic unit tests
Change-Id: If8cd798f456568a5c76310b754cea48ca8edaa82
2019-01-25 17:53:01 -08:00
Peter Collingbourne
7a0f04cb8d Implement ifunc support for static executables.
A static executable is almost entirely statically relocated by the
linker, with the exception of IRELATIVE relocations, which must be
resolved by libc by enumerating the relocations using the special
linker-defined symbols __rela?_iplt_{start,end}. This patch implements
ifunc support by enumerating the relocations in this way.

Bug: 112482891
Test: /data/nativetest{,64}/bionic-unit-tests-static/bionic-unit-tests-static on walleye_hwasan-userdebug
Change-Id: Ia5522a190da0b86e095b141d5d4e68dd7dd4b695
2019-01-25 16:25:27 -08:00
Ryan Prichard
96773a2daf Add BionicAllocator::memalign
Bionic needs this functionality to allocate a TLS segment with greater
than 16-byte alignment. For simplicity, this allocator only supports up
to one page of alignment.

The memory layout changes slightly when allocating an object of exactly
PAGE_SIZE alignment. Instead of allocating the page_info header at the
start of the page containing the pointer, it is allocated at the start
of the preceding page.

Bug: http://b/78026329
Test: linker-unit-tests{32,64}
Change-Id: I1c8d1cd7ca72d113bced5ee15ba8d831426b0081
2019-01-25 15:31:35 -08:00
Ryan Prichard
083d850b30 Move the linker allocator into libc
Rename LinkerMemoryAllocator -> BionicAllocator
Rename LinkerSmallObjectAllocator -> BionicSmallObjectAllocator

libc and the linker need to share an instance of the allocator for
allocating and freeing dynamic ELF TLS memory (DTVs and segments). The
linker also continues to use this allocator.

Bug: http://b/78026329
Test: /data/nativetest/bionic-unit-tests-static
Test: /data/nativetest64/bionic-unit-tests-static
Test: /data/nativetest/linker-unit-tests/linker-unit-tests32
Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64
Change-Id: I2da037006ddf8041a75f3eba2071a8fcdcc223ce
2019-01-25 15:31:35 -08:00
Josh Gao
5bc393b773 Merge "Don't filter reserved signals in sigaction." am: 65502ea8e0 am: 81f534e7c6
am: ae302f56f3

Change-Id: I6d2e4006a979f7bf9111deb182efb56d517fd618
2019-01-25 14:50:20 -08:00
Sandeep Patil
4e02cc1858 bionic_unit_tests: Remove dependency on libpagemap
Use libmeminfo instead.
Bug: 111694435
Test: bionic-unit-tests --gtest_filter=DlExtRelroSharingTest.*

Change-Id: Ice217a91a16ee0216354608b2776c0f1e5f65c09
Merged-In: Ice217a91a16ee0216354608b2776c0f1e5f65c09
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-25 13:07:02 -08:00
Sandeep Patil
e3f39a0efc bionic_unit_tests: Remove dependency on libpagemap
Use libmeminfo instead.
Bug: 111694435
Test: bionic-unit-tests --gtest_filter=DlExtRelroSharingTest.*

Change-Id: Ice217a91a16ee0216354608b2776c0f1e5f65c09
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-24 15:36:45 -08:00
Josh Gao
ba40ff657f Don't filter reserved signals in sigaction.
If a signal handler is blocking all of their signals, we should
probably respect that and not silently unblock bionic's reserved
signals for them. Otherwise, user code can deadlock, run out of stack,
etc. through no fault of their own, if one of the reserved signals
comes in while they've pivoted onto their signal stack.

Bug: http://b/122939726
Test: treehugger
Change-Id: I6425a3e7413edc16157b35dffe632e1ab1d76618
2019-01-24 13:21:18 -08:00
Ryan Savitski
ecc37e3877 conditional zygote child heap profiling + android_internal_mallopt
On user builds, heapprofd should only be allowed to profile apps that
are either debuggable, or profileable (according to the manifest). This
change exposes extra zygote-specific knowledge to bionic, and makes the
dedicated signal handler check for the special case of being in a zygote child.

With this & the corresponding framework change, we should now be
handling the 4 combinations of:
  {java, native} x {profile_at_runtime, profile_at_startup}.

See internal go/heapprofd-java-trigger for further context.

Test: on-device unit tests (shared & static) on blueline-userdebug.
Test: flashed blueline-userdebug, confirmed that java profiling activates from startup and at runtime.
Bug: 120409382
Change-Id: Ic251afeca4324dc650ac1d4f46976b526eae692a
(cherry picked from commit 998792e2b6)
Merged-In: Ic251afeca4324dc650ac1d4f46976b526eae692a
2019-01-23 18:30:54 +00:00
Ryan Savitski
998792e2b6 conditional zygote child heap profiling + android_internal_mallopt
On user builds, heapprofd should only be allowed to profile apps that
are either debuggable, or profileable (according to the manifest). This
change exposes extra zygote-specific knowledge to bionic, and makes the
dedicated signal handler check for the special case of being in a zygote child.

With this & the corresponding framework change, we should now be
handling the 4 combinations of:
  {java, native} x {profile_at_runtime, profile_at_startup}.

See internal go/heapprofd-java-trigger for further context.

Test: on-device unit tests (shared & static) on blueline-userdebug.
Test: flashed blueline-userdebug, confirmed that java profiling activates from startup and at runtime.
Bug: 120409382
Change-Id: Ic251afeca4324dc650ac1d4f46976b526eae692a
2019-01-23 00:05:54 +00:00
Ryan Prichard
e4ee12f813 Add tests for static ELF TLS
Bug: http://b/78026329
Test: bionic unit tests
Merged-In: I806f2bd193998dfe352372476104876edb27aebf
Change-Id: I806f2bd193998dfe352372476104876edb27aebf
2019-01-18 22:44:55 +00:00
Ryan Prichard
453ebb0131 Merge "Turn off XOM on libnstest_root.so" am: c85a8823ca am: 6fb9f4ceee
am: 455f313d51

Change-Id: I606ca38e11c29d2282fef2cdbff5ed2d77fa6c73
2019-01-18 14:17:23 -08:00
Ryan Prichard
f1180aee35 Merge "Add tests for static ELF TLS" 2019-01-18 22:15:01 +00:00
Ryan Prichard
c85a8823ca Merge "Turn off XOM on libnstest_root.so" 2019-01-18 21:44:27 +00:00
Elliott Hughes
cc395b4d99 Merge "Allow more leeway to fix sys_time.gettimeofday flakiness." am: 4ac3709f66 am: 81542e662c
am: f20ee7900d

Change-Id: I089cf9ba2def6a641af311b21190a4db9852dc75
2019-01-18 12:12:08 -08:00
Elliott Hughes
0159b64aa5 Allow more leeway to fix sys_time.gettimeofday flakiness.
Bug: http://b/121156651
Test: ran tests
Change-Id: Ieb8ee481ea3572533823e6cb0eab4ec089a38e44
2019-01-18 08:20:55 -08:00
Ryan Prichard
cd4e5ba559 Turn off XOM on libnstest_root.so
The dlext.ns_anonymous test copies the loaded segments of this shared
object into a new mapping, so every segment must be readable. Turn off
eXecute-Only-Memory.

Bug: http://b/123034666
Test: bionic-unit-tests --gtest_filter=dlext.ns_anonymous
Change-Id: I2d427feb81d353e0403c7ef251a55afb4d8729b4
2019-01-18 01:15:44 -08:00
Ryan Prichard
5cf02f6934 Add tests for static ELF TLS
Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I806f2bd193998dfe352372476104876edb27aebf
2019-01-17 20:40:32 -08:00
Ryan Prichard
8ad8abf233 Merge changes Ia08e1b5c,I60e589dd,Ib7edb665,Ibf1bf5ec,Ibd623857 am: 9a238653c1 am: b387a9270c
am: 582280600e

Change-Id: I7548beb2cc0b92561566044ad3e3d9c5f26c5c7b
2019-01-17 15:53:29 -08:00
Ryan Prichard
9a238653c1 Merge changes Ia08e1b5c,I60e589dd,Ib7edb665,Ibf1bf5ec,Ibd623857
* changes:
  Handle R_GENERIC_TLS_TPREL relocations
  Avoid a dlopen abort on an invalid TLS alignment
  Initialize static TLS memory using module list
  Record TLS modules and layout static TLS memory
  StaticTlsLayout: add exe/tcb and solib layout
2019-01-17 23:10:51 +00:00
Elliott Hughes
3923469cff Merge "Allow more leeway to fix time.clock_gettime flakiness." am: 1f6adf5863 am: 94e4167844
am: fd6608672f

Change-Id: I46ecd8f74a93424ca52f5df0220641a09ac910d3
2019-01-17 15:02:15 -08:00
Treehugger Robot
1f6adf5863 Merge "Allow more leeway to fix time.clock_gettime flakiness." 2019-01-17 22:15:33 +00:00
Martijn Coenen
aa09d2d15a Merge "Update getpwnam() tests to correctly handle new app zygote uids." am: de70b72b4f am: 83ec4fdd64
am: f2f8997661

Change-Id: I45fe9607f9a20a23779925d49fc207a2d733fe05
2019-01-17 13:06:27 -08:00
Martijn Coenen
de70b72b4f Merge "Update getpwnam() tests to correctly handle new app zygote uids." 2019-01-17 20:49:19 +00:00
Elliott Hughes
8dff0bb66b Allow more leeway to fix time.clock_gettime flakiness.
Bug: http://b/121156651
Test: ran tests
Change-Id: Ic949763e56c46f05ed2565ca4465a15c7ecf768c
2019-01-17 12:32:32 -08:00
Martijn Coenen
f9d2299ee2 Update getpwnam() tests to correctly handle new app zygote uids.
The UID range [90000..98999] is used for isolated processes that are
spawned from an application zygote. Otherwise they are identical to
regular isolated processes in the [99000..99999] range. Fix the tests to
match the new range.

Bug: 111434506
Test: atest bionic-unit-tests-static
Change-Id: Id0352f2cf0d21edb04d95f01ea2548e95b62317a
2019-01-17 13:36:47 +01:00
Ryan Prichard
fb8730d495 Handle R_GENERIC_TLS_TPREL relocations
This relocation is used for static TLS's initial-exec (IE) accesses.

A TLS symbol's value is its offset from the start of the ELF module's
TLS segment. It doesn't make sense to add the load_bias to this value,
so skip the call to soinfo::resolve_symbol_address.

Allow TLS relocations to refer to an unresolved weak symbol. In that case,
sym will be non-zero, but lsi will be nullptr. The dynamic linker resolves
the TPREL relocation to 0, making &missing_weak_symbol equal the thread
pointer.

Recognize Gold-style relocations to STB_LOCAL TLS symbols/sections and
issue an error.

Remove the "case R_AARCH64_TLS_TPREL64", because the R_GENERIC_TLS_TPREL
case handles it.

Remove the no-op R_AARCH64_TLSDESC handler. It's better to issue an error.
dlopen_library_with_ELF_TLS now fails with a consistent error about an
unimplemented dynamic TLS relocation.

Bug: http://b/78026329
Test: bionic unit tests (elftls tests are added in a later CL)
Change-Id: Ia08e1b5c8098117e12143d3b4ebb4dfaa5ca46ec
2019-01-17 00:45:55 -08:00
Ryan Prichard
f2a24a7e1f Merge changes I221b1342,I1d1276da,I89b128df,Icb348a11,Ifb3b2d8d am: aef4a49a3f am: 9282a56091
am: 540d9e3ddd

Change-Id: I0dc838ff7d1e5d94a9ae5e26517fa6c7247c4bd4
2019-01-16 16:06:04 -08:00
Ryan Prichard
073fffde09 Provide a stub aeabi.read_tp on other archs
Using "#if defined(...)" inside the test body seems to be the convention.

Bug: none
Test: bionic-unit-tests
Change-Id: Icb348a1184e630c5e199129bbe2090fd1e490fa5
2019-01-16 01:11:26 -08:00
George Burgess IV
08fd072525 bionic: update for glibc 2.17
Coming soon to a source tree near you.

Bug: 111358231
Test: `m checkbuild`. x86 emulator boots cleanly.
Change-Id: I9e3e2f7d3f8b7c36798fad27ca776f3490d834d2
2019-01-15 19:00:11 -08:00
Ryan Prichard
45d1349c63 Reorganize static TLS memory for ELF TLS
For ELF TLS "local-exec" accesses, the static linker assumes that an
executable's TLS segment is located at a statically-known offset from the
thread pointer (i.e. "variant 1" for ARM and "variant 2" for x86).
Because these layouts are incompatible, Bionic generally needs to allocate
its TLS slots differently between different architectures.

To allow per-architecture TLS slots:
 - Replace the TLS_SLOT_xxx enumerators with macros. New ARM slots are
   generally negative, while new x86 slots are generally positive.
 - Define a bionic_tcb struct that provides two things:
    - a void* raw_slots_storage[BIONIC_TLS_SLOTS] field
    - an inline accessor function: void*& tls_slot(size_t tpindex);

For ELF TLS, it's necessary to allocate a temporary TCB (i.e. TLS slots),
because the runtime linker doesn't know how large the static TLS area is
until after it has loaded all of the initial solibs.

To accommodate Golang, it's necessary to allocate the pthread keys at a
fixed, small, positive offset from the thread pointer.

This CL moves the pthread keys into bionic_tls, then allocates a single
mapping per thread that looks like so:
 - stack guard
 - stack [omitted for main thread and with pthread_attr_setstack]
 - static TLS:
    - bionic_tcb [exec TLS will either precede or succeed the TCB]
    - bionic_tls [prefixed by the pthread keys]
    - [solib TLS segments will be placed here]
 - guard page

As before, if the new mapping includes a stack, the pthread_internal_t
is allocated on it.

At startup, Bionic allocates a temporary bionic_tcb object on the stack,
then allocates a temporary bionic_tls object using mmap. This mmap is
delayed because the linker can't currently call async_safe_fatal() before
relocating itself.

Later, Bionic allocates a stack-less thread mapping for the main thread,
and copies slots from the temporary TCB to the new TCB.
(See *::copy_from_bootstrap methods.)

Bug: http://b/78026329
Test: bionic unit tests
Test: verify that a Golang app still works
Test: verify that a Golang app crashes if bionic_{tls,tcb} are swapped
Merged-In: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
Change-Id: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
(cherry picked from commit 1e660b70da)
2019-01-11 15:34:22 -08:00
Ryan Prichard
7135694a63 Merge changes from topic "elftls-perarch-tls"
* changes:
  Reorganize static TLS memory for ELF TLS
  pthread_key.cpp: factor out get_thread_key_data
2019-01-11 22:29:32 +00:00
Jiyong Park
4e114eb221 Add stubs variants for bionic libs am: c45fe9f7bd am: 0f89dc7dbb
am: 36810c5301

Change-Id: I8076e6a5d8e9f023d491d5202f01b66f5d5333e8
2019-01-11 09:47:03 -08:00
Jiyong Park
0f89dc7dbb Add stubs variants for bionic libs
am: c45fe9f7bd

Change-Id: Ifcf199076e169f0ddff866f4def99e8c62312d2a
2019-01-11 09:16:40 -08:00
Treehugger Robot
98564b8c74 Merge changes from topic "move_bionic_to_apex"
* changes:
  Expose more symbols temporarily
  Add stubs variants for bionic libs
2019-01-11 16:59:15 +00:00
Ryan Prichard
1e660b70da Reorganize static TLS memory for ELF TLS
For ELF TLS "local-exec" accesses, the static linker assumes that an
executable's TLS segment is located at a statically-known offset from the
thread pointer (i.e. "variant 1" for ARM and "variant 2" for x86).
Because these layouts are incompatible, Bionic generally needs to allocate
its TLS slots differently between different architectures.

To allow per-architecture TLS slots:
 - Replace the TLS_SLOT_xxx enumerators with macros. New ARM slots are
   generally negative, while new x86 slots are generally positive.
 - Define a bionic_tcb struct that provides two things:
    - a void* raw_slots_storage[BIONIC_TLS_SLOTS] field
    - an inline accessor function: void*& tls_slot(size_t tpindex);

For ELF TLS, it's necessary to allocate a temporary TCB (i.e. TLS slots),
because the runtime linker doesn't know how large the static TLS area is
until after it has loaded all of the initial solibs.

To accommodate Golang, it's necessary to allocate the pthread keys at a
fixed, small, positive offset from the thread pointer.

This CL moves the pthread keys into bionic_tls, then allocates a single
mapping per thread that looks like so:
 - stack guard
 - stack [omitted for main thread and with pthread_attr_setstack]
 - static TLS:
    - bionic_tcb [exec TLS will either precede or succeed the TCB]
    - bionic_tls [prefixed by the pthread keys]
    - [solib TLS segments will be placed here]
 - guard page

As before, if the new mapping includes a stack, the pthread_internal_t
is allocated on it.

At startup, Bionic allocates a temporary bionic_tcb object on the stack,
then allocates a temporary bionic_tls object using mmap. This mmap is
delayed because the linker can't currently call async_safe_fatal() before
relocating itself.

Later, Bionic allocates a stack-less thread mapping for the main thread,
and copies slots from the temporary TCB to the new TCB.
(See *::copy_from_bootstrap methods.)

Bug: http://b/78026329
Test: bionic unit tests
Test: verify that a Golang app still works
Test: verify that a Golang app crashes if bionic_{tls,tcb} are swapped
Change-Id: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
2019-01-11 02:00:02 -08:00
Ryan Prichard
86e5c8b3fd Merge "Add ARM EABI function __aeabi_read_tp" am: c14d46f086 am: e0bdcb05ef
am: 68ac862825

Change-Id: I7f08cb2d1c386a8a356277f9551ff70762cc7656
2019-01-08 13:48:41 -08:00
Ryan Prichard
45024fefe7 Add ARM EABI function __aeabi_read_tp
By default, Clang uses this arm32 function to read the thread pointer,
either for ELF TLS or via __builtin_thread_pointer(). It's probably better
to inline the cp15 access using -mtp=cp15, but that's not the default yet.

See https://reviews.llvm.org/D34878?id=114573.

Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I93b8926075f0b2cea8df9ef518d54f2820a8ff5b
2019-01-07 20:30:35 -08:00
Jiyong Park
c45fe9f7bd Add stubs variants for bionic libs
Bionic libs are part of the runtime APEX (com.android.runtime). In order
to be able to update the runtime APEX independetly from the platform, we
have to prevent things outside of the APEX from using bionic symbols
that are not guaranteed to be stable. Otherwise, platform could break
when a symbol is removed from the libs via the APEX update.

To achive this goal, this change adds stubs variant to the bionic libs.
With this, things outside of the runtime APEX (i.e. other APEXes and the
platform) are built with the stubs variants that provide only the
symbols that are guaranteed to be stable.

The set of symbols are basically the same as the symbols available to
NDK clients. However, there are a few additional symbols that are not
available for NDK but should be made available for platform components.
They are marked with "# apex" tag. Symbols with that tag are not exposed
to apps (via NDK stubs) or vendors (via LLNDK stubs).

Note that the stubs is a build-time only artifact. It is used just to
break the build when private symbols are used outside of the runtime
APEX. At runtime, the real library in the APEX is used.

Bug: 120266448
Test: m
Test: m bionic-unit-tests
Change-Id: I7b8d75830c81d7d7d54e2fca21a85b3417531b47
2019-01-04 22:29:36 +09:00
Chih-hung Hsieh
d7433adba4 Merge "Fix/suppress bionic google-explicit-constructor warnings" am: 07468a811e am: b64cee9aca
am: 824831deac

Change-Id: I33f9a61936ba3bf8d8fc31fa30eb9e057c36be3d
2019-01-02 14:59:45 -08:00
Ryan Prichard
62950fc600 Merge "Fix modify_stack_protector flake" am: 49c631a746 am: 58cd0d0ad4
am: a47cff0562

Change-Id: Id3c3812857391b3a715e357a1085a01831023b1d
2019-01-02 14:59:07 -08:00
Chih-hung Hsieh
07468a811e Merge "Fix/suppress bionic google-explicit-constructor warnings" 2019-01-02 22:29:13 +00:00
Chih-Hung Hsieh
770032ddfa Fix/suppress bionic google-explicit-constructor warnings
* Add explicit to conversion constructors/operators

Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: Id1ad0327c1b8c6f094bcbb3ae599bc1f716b3f2f
2019-01-02 11:04:05 -08:00
Ryan Prichard
76e7fd4e26 Fix modify_stack_protector flake
The previous test would fail to crash if the first byte of the canary was
already NUL (1 of 256 runs assuming uniform canary distribution).

Bug: http://b/121156651
Test: bionic unit tests
2019-01-01 19:46:41 -08:00
Elliott Hughes
88d7c090c9 Merge "Make stdlib.getloadavg more resiliant." am: 727a6ebcfb am: 95d016c583
am: 96518c7fe3

Change-Id: If0b0c8aaaa1605a1ad819a85f60852d3b2732d45
2018-12-18 18:10:05 -08:00
Elliott Hughes
bae1a98700 Merge "Fix sys_prctl.pr_cap_ambient." am: 3b3e09aad0 am: 0c5b3f4d96
am: 7ea0086a3b

Change-Id: I797573b42f6bf045be846468a66fcbd1affd3f0f
2018-12-18 18:00:28 -08:00
Elliott Hughes
727a6ebcfb Merge "Make stdlib.getloadavg more resiliant." 2018-12-19 01:33:36 +00:00
Elliott Hughes
910a2a83a4 Fix sys_prctl.pr_cap_ambient.
This test didn't clear errno before testing it, so was sensitive to
whatever code had run before. Since I'd already added the code to dump
the exact kernel version before realizing the actual bug, I've left that
in too.

Bug: http://b/121156651
Test: ran tests
Change-Id: I38482036cb6f035c0c98c27eb64d17829f29b09a
2018-12-18 15:19:40 -08:00
Elliott Hughes
72a54a41a7 Make stdlib.getloadavg more resiliant.
Using rint(3) gave us a step where if one side was 1.4 and the other
was 1.5, that would be 1 and 2 respectively. So instead use a simple
difference. Also log more detail in case this doesn't fix the flakiness.

Bug: http://b/121156651
Test: ran tests
Change-Id: Ib5b2eb05d2b1eb8c4a10b182a8703510a3ef0cea
2018-12-18 14:47:25 -08:00
Elliott Hughes
6924cc08ee Merge "Increase 2ms to 5ms to reduce flake." am: 22549b331c am: 55d2ed41bb
am: 85ac85997f

Change-Id: I7d09147c11fea84a4e1ab0bc9d715a91b654ea4f
2018-12-18 12:08:53 -08:00
Elliott Hughes
0dafa8a3a5 Increase 2ms to 5ms to reduce flake.
Bug: http://b/121156651
Test: ran tests
Change-Id: Ief699cacf920b144bf66821cf0ac73930fae9274
2018-12-17 16:04:45 -08:00
Chih-hung Hsieh
bc8bc84e6b Merge "Fix cert-dcl16-c clang-tidy warnings in tests." am: c49776bffc am: 5eac8ef60e
am: 13bc7f4855

Change-Id: I19c21e47c3c132049a7a09e9bc278a9824441e02
2018-12-11 19:19:26 -08:00
Chih-Hung Hsieh
c2edae3f86 Fix cert-dcl16-c clang-tidy warnings in tests.
Bug: 120614316
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,cert-dcl16-c
Change-Id: I2606dc4cdfff9c2691ed60d529971e16adb3a9ae
2018-12-11 15:16:24 -08:00
Ryan Prichard
5a66490e3b Use shared globals so getauxval works earlier
Make getauxval() work in .preinit_array. It still won't be usable for
ifuncs unless we can guarantee that the __loader_shared_globals relocation
is resolved before the ifunc calls [__bionic_]getauxval.

Define __bionic_getauxval for use in replacing calls to
KernelArgumentBlock::getauxval, which doesn't (and sometimes isn't allowed
to) access TLS variables like errno.

Bug: http://b/25751302
Test: bionic unit tests
Change-Id: I461feeaed7f43cfa2a2b6c34147194f0df82b516
Merged-In: I461feeaed7f43cfa2a2b6c34147194f0df82b516
(cherry picked from commit bdab4a2b97)
2018-12-04 13:51:46 -08:00
Ryan Prichard
fd3771c396 Merge changes from topic "getauxval-early"
* changes:
  Replace TLS_SLOT_BIONIC_PREINIT w/ shared globals
  Use shared globals so getauxval works earlier
  Split main thread init into early+late functions
2018-12-04 21:40:25 +00:00
Ryan Prichard
bdab4a2b97 Use shared globals so getauxval works earlier
Make getauxval() work in .preinit_array. It still won't be usable for
ifuncs unless we can guarantee that the __loader_shared_globals relocation
is resolved before the ifunc calls [__bionic_]getauxval.

Define __bionic_getauxval for use in replacing calls to
KernelArgumentBlock::getauxval, which doesn't (and sometimes isn't allowed
to) access TLS variables like errno.

Bug: http://b/25751302
Test: bionic unit tests
Change-Id: I461feeaed7f43cfa2a2b6c34147194f0df82b516
2018-12-03 17:14:44 -08:00
Elliott Hughes
32772badd1 Merge "Reduce strerror(3)'s impact on .data.rel.ro." am: d264aaf95d am: 6b16fcc713
am: 2194f7edb2

Change-Id: Ie24b3142b4a2046037d3da228971c42abd5c464e
2018-12-03 16:33:06 -08:00
Elliott Hughes
eebf5fddf3 Reduce strerror(3)'s impact on .data.rel.ro.
Test: tests pass
Change-Id: I60b15dfac6ca7dce45f4858ad10b8255e2f1b66d
2018-12-03 08:46:21 -08:00
Ryan Prichard
05be2a8ee4 Merge changes I376d7695,Ied443375,I614d25e7 am: 6b70fda682 am: 1c2a15bd46
am: 36a0fa80b9

Change-Id: I1d895bf1d97adc4c59134dc45c583a486e3fd630
2018-11-30 00:23:55 -08:00
Ryan Prichard
48b1159bb8 Use shared globals to init __progname + environ
Initialize the __progname and environ global variables using
libc_shared_globals rather than KernelArgumentBlock.

Also: suppose the linker is invoked on an executable:

    linker prog [args...]

The first argument passed to main() and constructor functions is "prog"
rather than "linker". For consistency, this CL changes the BSD
__progname global from "linker" to "prog".

Bug: none
Test: bionic unit tests
Change-Id: I376d76953c9436706dbc53911ef6585c1acc1c31
2018-11-28 14:26:14 -08:00
Christopher Ferris
1fbef35b85 Merge "Add test for mallinfo." am: 7f92fbe064 am: e4838639b8
am: c3cf0d56e3

Change-Id: I6c81d87224e597f6c816ee0d400d19186f7e7421
2018-11-26 19:06:14 -08:00
Christopher Ferris
7f92fbe064 Merge "Add test for mallinfo." 2018-11-27 02:33:15 +00:00
Peter Collingbourne
3bcdb4034b Merge "Allocate a small guard region around the shadow call stack." am: 8d849ffbad am: ff18faa2b0
am: f634c7f521

Change-Id: Iffe91224477326d0d0b86260fb717c61744c21fe
2018-11-19 13:53:49 -08:00
Peter Collingbourne
8d849ffbad Merge "Allocate a small guard region around the shadow call stack." 2018-11-19 20:44:03 +00:00
Peter Collingbourne
734beec3d4 Allocate a small guard region around the shadow call stack.
This lets us do two things:

1) Make setjmp and longjmp compatible with shadow call stack.
   To avoid leaking the shadow call stack address into memory, only the
   lower log2(SCS_SIZE) bits of x18 are stored to jmp_buf. This requires
   allocating an additional guard page so that we're guaranteed to be
   able to allocate a sufficiently aligned SCS.

2) SCS overflow detection. Overflows now result in a SIGSEGV instead
   of corrupting the allocation that comes after it.

Change-Id: I04d6634f96162bf625684672a87fba8b402b7fd1
Test: bionic-unit-tests
2018-11-16 14:37:08 -08:00
Christopher Ferris
09a19aa0e7 Add test for mallinfo.
Bug: 119580449

Test: Test passes.
Change-Id: Ib605e550b7d6d8fd2336ad61b678a7e63f8ecffb
2018-11-16 13:34:36 -08:00
Elliott Hughes
1bfcf77fd2 Merge "Make android_get_application_target_sdk_version available to the NDK." am: ae471db4a9 am: c8146406c7
am: d3a29ee052

Change-Id: Iaeec37483c49036e0928c92a93c41b7c605bebb1
2018-11-15 15:39:19 -08:00
Elliott Hughes
ae471db4a9 Merge "Make android_get_application_target_sdk_version available to the NDK." 2018-11-15 23:04:41 +00:00
Elliott Hughes
c0f4656452 Make android_get_application_target_sdk_version available to the NDK.
Also move this and android_get_device_api_level into <android/api-level.h>
so that they're always available.

This involves cleaning up <sys/cdefs.h> slightly.

Bug: N/A
Test: builds
Change-Id: I25435c55f3549cd0d827a7581bee75ea8228028b
2018-11-15 11:07:30 -08:00
Mark Salyzyn
0467625cac Merge "switch to using android-base/file.h instead of android-base/test_utils.h" am: cfd628009c am: 6aefa0ac64
am: d92e3098d8

Change-Id: Ia67702b8c704d6ad0b49299d6351a52b74eb588b
2018-11-15 08:29:54 -08:00
Mark Salyzyn
ba1a723ad1 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14 15:46:49 -08:00
Elliott Hughes
8359068064 Merge "Move API levels from uint32_t to int." 2018-11-14 19:50:59 +00:00
Mark Salyzyn
c686824956 Merge "bionic tests: switch to using android-base/file.h for TemporaryFile" am: 48630a9191 am: c9ec58c441
am: 91efcb49f3

Change-Id: I7f5fc2f81ebf3b60ce82af1aada43fa007b26ff6
2018-11-14 07:41:41 -08:00
Elliott Hughes
ff1428a48e Move API levels from uint32_t to int.
(cherrypick of a6c71a09670ca636cca5cfea9d74b03a951e2b5e.)

Bug: N/A
Test: builds
Change-Id: I9c414e30e3c4fe2a4e16a2fe4ce18eae85fe4844
2018-11-13 21:25:07 -08:00
Elliott Hughes
0ce52fd8a8 Merge "Move API levels from uint32_t to int." 2018-11-14 05:24:04 +00:00
Peter Collingbourne
7b70e27ab1 Make the bionic tests implicitly test bionic's shadow call stack support.
For the moment this is an internal-only change until the AOSP kernels
can be fixed to not clobber x18.

Bug: 112907825
Change-Id: I4442ad424539e5054a3489451d1b8ab522af0a3e
2018-11-13 11:40:23 -08:00
Mark Salyzyn
68a3bcc249 bionic tests: switch to using android-base/file.h for TemporaryFile
A matching definition of TemporaryFile exists in libbase now.

Test: compile
Bug: 119313545
Change-Id: I6f84dbf3af9a9c4b270a2532a36c9cb4c0f6bb8f
2018-11-13 10:57:28 -08:00
Elliott Hughes
a6c71a0967 Move API levels from uint32_t to int.
Bug: N/A
Test: builds
Change-Id: I9c414e30e3c4fe2a4e16a2fe4ce18eae85fe4844
2018-11-12 16:01:37 -08:00
Yi Kong
d495e0b777 Merge "Don't build bionic-unit-tests-static with libcrt_builtins" 2018-11-08 18:23:56 +00:00
Yi Kong
b011d59a7f Don't build bionic-unit-tests-static with libcrt_builtins
libcrt_builtins does not work with libm, which is statically linked in
bionic-unit-tests-static. Opt it out of libcrt_builtins for now.

Bug: 119207651
Bug: 117167374
Test: run bionic-unit-test-static
Change-Id: I20067c9841beb9de2b73342847aaa945dbadbff8
2018-11-08 05:33:15 +00:00
Elliott Hughes
52d7749335 Merge "ART isn't using the ART-specific linker features any more." 2018-11-08 03:09:53 +00:00
Christopher Ferris
6689b4f258 Merge "Add a force fail for non-bionic xfail test." 2018-11-08 03:01:34 +00:00
Christopher Ferris
af1b8ddaa9 Add smoke tests for mallopt options.
Test: Unit tests pass.
Change-Id: If213f4338078011ff12996c1b2a6f6858b51d824
2018-11-07 17:11:42 -08:00
Christopher Ferris
01db9bde05 Add a force fail for non-bionic xfail test.
Test: xfail test passes on host.
Change-Id: I6c4ddd3f3dc5541b126d9dd31b1fcff9d34819e6
2018-11-07 14:39:43 -08:00
Treehugger Robot
5e099173da Merge "Revert "Do not use clang lld with -z,global"" 2018-11-07 21:43:24 +00:00
Evgenii Stepanov
acd6f4f9f5 Disable a few bionic tests under HWASan.
* HWASan report invalid use of the allocator api (like alignment not
being power of two, or allocation size too large) in a way tests do not
expect.
* Code in .preinit_array runs before HWASan shadow is initialized and
needs to be excluded from instrumentation.
* It looks that mm system calls (mmap/mprotect/etc) will not allow
tagged pointers. In fact, the use of mprotect on malloc()ed memory is
doubtful - one can imagine some kind of speculative load from such
memory, as compiler knows that it is addressable.

Bug: 114279110
Test: bionic-unit-tests with hwasan

Change-Id: I6ba4b46a0d554de77c923ad134cf156ce4ddba1b
2018-11-06 16:59:25 -08:00
Evgenii Stepanov
96bd339c51 Remove timer_delete_multiple test.
According to posix, this test invokes undefined behavior by deleting
a timer twice.

According to hwasan, the second call to timer_delete loads
kernel_timer_id from previously deallocated PosixTimer (i.e.
heap-use-after-free).

Bug: 114279110
Test: bionic-unit-tests with hwasan

Change-Id: Ic54579e3bb41d3f38282b8822dafaba51efd003a
2018-11-06 16:59:21 -08:00
Chih-hung Hsieh
08a0cd082f Revert "Do not use clang lld with -z,global"
This reverts commit 8e462d411a.

Reason for revert: this lld bug has been fixed upstream and in AOSP prebuilts

Bug: 80109858
Change-Id: Ied600324201e1a014a1d4e6742767e2ddd94999a
2018-11-07 00:12:56 +00:00
Elliott Hughes
8178c417f6 ART isn't using the ART-specific linker features any more.
Bug: N/A
Test: ran tests
Change-Id: Ide3c295035687019608a2c4716a4a21cb889d121
2018-11-06 11:15:17 -08:00
Christopher Ferris
9ffd39cdea Merge "Add test for malloc_iterate." 2018-11-02 15:20:54 +00:00
Josh Gao
6f3a56bb18 Merge "Revert "bionic: Allocate a shadow call stack for each thread."" 2018-11-01 01:32:00 +00:00
Christopher Ferris
bfd3dc497c Add test for malloc_iterate.
Bug: 62621531

Test: New unit tests pass.
Change-Id: Icc50f5b19642225c8f812844d42c904babde8acf
2018-10-30 18:38:39 -07:00
Christopher Ferris
9ce28844db Update to v4.19 kernel headers.
Test: Builds and boots.
Change-Id: I99a9ed79666e143b47f02ca4e59eed94f69b7e4a
(cherry picked from commit a981e2e52e)
2018-10-30 09:21:16 -07:00
Peter Collingbourne
7b13dd918e Revert "bionic: Allocate a shadow call stack for each thread."
This reverts commit da1bc79f93.

Reason for revert: Caused OOM in media process

Bug: 112907825
Bug: 118593766
Change-Id: I545663871d75889b209b9fd2131cdaa97166478f
2018-10-29 21:48:59 +00:00
Peter Collingbourne
f284a47544 Merge "bionic: Allocate a shadow call stack for each thread." 2018-10-29 21:05:25 +00:00
Peter Collingbourne
da1bc79f93 bionic: Allocate a shadow call stack for each thread.
Bug: 112907825
Change-Id: I7c1479a0cd68696739bf6aa5e0700ba4f2a137ec
Merged-In: I7c1479a0cd68696739bf6aa5e0700ba4f2a137ec
2018-10-29 19:55:18 +00:00
Elliott Hughes
5e62b34c0d Clean up bionic_macros.h a bit.
Use <android-base/macros.h> instead where possible, and move the bionic
macros out of the way of the libbase ones. Yes, there are folks who manage
to end up with both included at once (thanks OpenGL!), and cleaning that
up doesn't seem nearly as practical as just making this change.

Bug: N/A
Test: builds
Change-Id: I23fc544f39d5addf81dc61471771a5438778895b
2018-10-25 11:00:00 -07:00
Elliott Hughes
6032c38fb3 Merge "Add getloadavg(3)." 2018-10-24 16:31:21 +00:00
Elliott Hughes
2d0b28bc0d Add getloadavg(3).
Lets us build ninja with bionic.

Bug: N/A
Test: ran tests
Change-Id: I97eef1247d794b58a2b9aee4851551632e5a4e48
2018-10-23 11:23:00 -07:00
Chuwei Xu
5d9312bb13 CTS: allow continue to use the old AIDs on devices launch with P
Some vendors may have been using the AIDs outside the oem ranges
for long that those aids need continue to be maitained for the
existing devices. We allow them countinue to use the old AID names
and values on device launch with P and before, to give them the
period of time to adopt the new AID scheme.

Bug: 116405200
Change-Id: I0453ed14df4c0855575ef1404c596ddc6ded681b
2018-10-23 13:50:04 +08:00
Josh Gao
7ff7d03286 Merge "Properly fail with ESRCH when pthread_killing an exited thread." 2018-10-18 17:47:17 +00:00
Josh Gao
ddf757e35e Properly fail with ESRCH when pthread_killing an exited thread.
Previously, we were callign tgkill(pid, 0, signal) instead, which would
fail with EINVAL instead.

Test: bionic-unit-tests
Change-Id: I25b127dcf347e0223274502b0516a950b6c2093e
2018-10-17 17:35:56 -07:00
Tom Cherry
4e29cdec23 Merge "Waive AID Range check for upgrading devices launched before P" 2018-10-15 17:59:59 +00:00
Tom Cherry
5c941435ac Waive AID Range check for upgrading devices launched before P
We added a check in P that ensures all vendor provided AIDs only
appear in the carved out ranges for vendors to use.  However,
upgrading devices may be using AIDs outside of this range and it is
very difficult to change these AIDs, so we waive this test for them.

Bug: 116830906
Test: test succeeds on upgrading devices
Change-Id: Iddcacb1dce77a150d5138e7b3115abf25bf60a6e
2018-10-11 11:57:13 -07:00
Treehugger Robot
391af2cefe Merge "Allow invoking the linker on an executable." 2018-10-11 01:04:57 +00:00
Ryan Prichard
8f639a4096 Allow invoking the linker on an executable.
The executable can be inside a zip file using the same syntax used for
shared objects: path.zip!/libentry.so.

The linker currently requires an absolute path. This restriction could be
loosened, but it didn't seem important? If it allowed non-absolute paths,
we'd need to decide how to handle:
 - foo/bar      (relative to CWD?)
 - foo          (search PATH / LD_LIBRARY_PATH, or also relative to CWD?)
 - foo.zip!/bar (normalize_path() requires an absolute path)

The linker adjusts the argc/argv passed to main() and to constructor
functions to hide the initial linker argument, but doesn't adjust the auxv
vector or files like /proc/self/{exe,cmdline,auxv,stat}. Those files will
report that the kernel loaded the linker as an executable.

I think the linker_logger.cpp change guarding against (g_argv == NULL)
isn't actually necessary, but it seemed like a good idea given that I'm
delaying initialization of g_argv until after C++ constructors have run.

Bug: http://b/112050209
Test: bionic unit tests
Change-Id: I846faf98b16fd34218946f6167e8b451897debe5
2018-10-10 14:31:06 -07:00
Josh Gao
069d5aef90 Merge "Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...)." 2018-10-10 20:38:46 +00:00
Josh Gao
baf20fc912 Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...).
Previously, we were zeroing out the reserved signals, when we actually
wanted to have TIMER_SIGNAL always be blocked, and the other signals
always be unblocked. This resulted in process termination when a
SIGEV_THREAD timer callback calls sigprocmask(SIG_SETMASK, ...) with
any signal mask value, and then subsequently fails to complete its
callback and reach the sigtimedwait in bionic before the next timer
iteration triggers.

Add a how argument to filter_reserved_signals to appropriately
block/unblock our reserved signals.

Bug: http://b/116783733
Test: bionic-unit-tests32/64
Change-Id: Ie5339682cdeb914711cd4089cd26ee395704d0df
2018-10-09 16:27:22 -07:00
Elliott Hughes
82ab481123 Add _SC_UIO_MAXIOV as a synonym for _SC_IOV_MAX.
glibc and musl both have these as synonyms for one another, so we may
as well do the same and get backwards compatibility on old OS releases.

Bug: N/A
Test: ran tests
Change-Id: I6bf38ea446560e1b11022ff539f07eb67c157049
2018-10-09 13:56:06 -07:00
Christopher Ferris
928ce8eb64 Merge "Move isolated test runner out of bionic." 2018-10-01 23:07:31 +00:00
Stephen Hines
05ba56d6c0 Merge "Fix up a few bionic tests for the clang-r339409 update." 2018-10-01 15:57:35 +00:00
Christopher Ferris
6d2c0bdf6e Move isolated test runner out of bionic.
Use a global gtest isolation runner rather than the custom one in
bionic.

Test: Ran all unit tests and verified same behavior before and after.

Change-Id: I24a7cf17cf8e018d0f51969c64b53ce9059cc779
2018-09-27 22:22:17 -07:00
Christopher Ferris
f3ff8dc6f4 Merge "Ignore output to stderr while enumerating tests" 2018-09-27 23:23:36 +00:00
Treehugger Robot
ddf92a1ba5 Merge "Always return /vendor/bin/sh as shell for OEM ids in getpwnam() etc." 2018-09-27 23:23:34 +00:00
Tom Cherry
fa5f61c8d9 Always return /vendor/bin/sh as shell for OEM ids in getpwnam() etc.
During the review of the script that generates /vendor/etc/passwd, it
was suggested that the shell be /vendor/bin/sh instead of the typical
/system/bin/sh.  This has subsequently caused bionic unit tests to
fail, since they always check that the shell is set to /system/bin/sh.

In the spirit of that review, libc is modified to return
/vendor/bin/sh for the OEM AID ranges and the test is updated to
expect this.

Test: bionic unit tests
Change-Id: Ie7c1c48fde8a71b3df1aa0ef112d42ab7bd3baec
2018-09-27 20:29:49 +00:00
Elliott Hughes
b177085ce7 Add reallocarray(3).
Originally a BSD extension, now in glibc too. We've used it internally
for a while.

(cherry-pick of e4b13f7e3ca68edfcc5faedc5e7d4e13c4e8edb9.)

Bug: http://b/112163459
Test: ran tests
Change-Id: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
Merged-In: I813c3a62b13ddb91ba41e32a5a853d09207ea6bc
2018-09-26 14:24:18 -07:00
dimitry
21557cdd2e Ignore output to stderr while enumerating tests
Bug: http://b/114304197
Test: adb unroot && run CtsBionicTestCases
Change-Id: I75880934fa1c25be6c76e866f97efc14d5ccd0a1
2018-09-25 12:23:33 +02:00
Stephen Hines
cd659d410a Fix up a few bionic tests for the clang-r339409 update.
Disable -Wmemset-transposed-args to ensure that FORTIFY still works
without it. Also, we can finally enable checking for
FLT_HAS_SUBNORM/DBL_HAS_SUBNORM/LDBL_HAS_SUBNORM now that those are
available in Clang.

Bug: http://b/110779387
Test: build and run bionic unit tests
Change-Id: I4bf19b870c44d981ecbd1089d0ae6a2496be5441
2018-09-24 16:59:08 -07:00