Commit graph

2681 commits

Author SHA1 Message Date
Christopher Ferris
88b2f0d8f0 Add support for scudo.
Bug: 137795072

Test: Unit tests pass on jemalloc and scudo.
Change-Id: I764cdad2507d322ff36dd5d28bd8ff9719601e6a
2019-10-02 12:48:23 -07:00
Christopher Ferris
c5d3a4348a Make tls related header files platform accessible.
There are places in frameworks and art code that directly included
private bionic header files. Move these files to the new platform
include files.

This change also moves the __get_tls.h header file to tls.h and includes
the tls defines header so that there is a single header that platform
code can use to get __get_tls and the defines.

Also, simplify the visibility rules for platform includes.

Bug: 141560639

Test: Builds and bionic unit tests pass.
Change-Id: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
Merged-In: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
(cherry picked from commit 44631c919a)
2019-09-27 12:14:24 -07:00
Christopher Ferris
f97dcc15e8 Merge "Revert "Temporarily disable some clock_getres tests."" 2019-09-24 19:19:28 +00:00
Christopher Ferris
a9dfe1c352 Revert "Temporarily disable some clock_getres tests."
This reverts commit 8eba2a59ac.

Reason for revert: The kernel update has been reverted.

Change-Id: I21d9ac3c319b8c6e8546a0b40c5646c5610cc8c5
2019-09-24 16:20:17 +00:00
Christopher Ferris
849f0db7ca Merge "Temporarily disable some clock_getres tests." 2019-09-24 14:12:13 +00:00
Christopher Ferris
8eba2a59ac Temporarily disable some clock_getres tests.
A kernel update broke three clock_getres tests, so disable
them while the kernel is fixed.

Bug: 141515847

Test: All tests pass on cuttlefish.
Change-Id: I7db789b2b8ba0bc5f8b13bb06e85711031735925
2019-09-23 18:44:22 -07:00
Christopher Ferris
103b998a52 Stop executing if skip occurs.
Bug: 141358530

Test: Forced a skip and verified it registers as a skip.
Change-Id: I9915c67ebae4389a26f28e16375ad4a41f3e4837
2019-09-23 09:41:13 -07:00
George Burgess IV
8a4414ef9c fortify: remove pragma diagnostic error from tests
This was necessary because we weren't doing -Werror=fortify-source
everywhere. As of I2715ea411ef067f801534dab4d306fef5431f290, we should
be doing this.

Bug: 131861088
Test: mma
Change-Id: I00d499938ae24c3870760470576d6be603fbecd1
2019-09-19 15:23:45 -07:00
Treehugger Robot
e6c3f0628c Merge "fortify: account for new clang diagnostics" 2019-09-17 20:11:51 +00:00
George Burgess IV
36926f4ca8 fortify: account for new clang diagnostics
Clang recently grew its own diagnostics for memcpy and such. These are
generally higher-quality than what we can do with diagnose_if, since
clang is happy to include e.g., sizes of things per-callsite. Move to
those instead where applicable.

Bug: 131861088, 123644155
Test: blueline internal-master checkbuild; treehugger
Change-Id: I701f5a8b247ba2948ca47fdc60ff5198b564c03e
2019-09-16 12:48:04 -07:00
Christopher Ferris
2b0638ef29 Make bionic_malloc.h a platform header.
Instead of having platform directories directly include the
private header, create a platform header directory and export it.

Bug: 130763340

Test: Builds.
Change-Id: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
Merged-In: Ie0f092b3fe077a3de8b90266c0b28bfbc20d0dfa
(cherry picked from commit 8f582ef2f8)
2019-09-16 12:27:33 -07:00
Christopher Ferris
f0e70113d5 Merge "Add EFD_SEMAPHORE flag for eventfd."
am: add3a4ae70

Change-Id: I5508cec132fa1c8b79d41f39231e26fde17bba2f
2019-09-03 12:45:26 -07:00
Christopher Ferris
2c4cb0d760 Add EFD_SEMAPHORE flag for eventfd.
Add a test for the new flag and add a test for the EFD_CLOEXEC flag.

Test: New unit tests pass on glibc and target.
Change-Id: Ib7a6ea4aadbd67ba8a523b6114a49fb8d6a43f12
2019-09-03 09:35:51 -07:00
Christopher Ferris
5b8d0757f1 Merge "Use ReadMapFileAsyncSafe in malloc_iterate tests."
am: 8bccbb01e7

Change-Id: I6eab952fb46f1f3e0a9661c1e25f4ef98dea0d09
2019-08-24 01:22:13 -07:00
Ryan Prichard
f62547a4ee Merge "Add additional dl_phdr_info fields"
am: 665e98edf7

Change-Id: I3c1ed6c9f53ef2a348de69481498299577437780
2019-08-24 01:18:27 -07:00
Christopher Ferris
8bccbb01e7 Merge "Use ReadMapFileAsyncSafe in malloc_iterate tests." 2019-08-24 04:12:42 +00:00
Ryan Prichard
665e98edf7 Merge "Add additional dl_phdr_info fields" 2019-08-23 20:45:54 +00:00
Christopher Ferris
8ea85afde5 Use ReadMapFileAsyncSafe in malloc_iterate tests.
This avoids issues where an allocation could create a map while trying
to check data from the maps and running malloc_iterate.

Bug: 137795072

Test: Runs in unit tests.
Change-Id: If8509845d86dd9d002aeac3aa9278fbcf026af17
2019-08-23 10:07:31 -07:00
Ryan Prichard
a2e83ab348 Add additional dl_phdr_info fields
Previously, Bionic's dl_phdr_info only included the first four
dl_iterate_phdr fields. Several other libc's have these additional fields:

    unsigned long long dlpi_adds -- incremented when a library is loaded
    unsigned long long dlpi_subs -- incremented when a library is unloaded
    size_t dlpi_tls_modid -- TLS module ID
    void* dlpi_tls_data -- pointer to current thread's TLS block or NULL

These extra fields are also exposed by glibc, musl, and FreeBSD. The
unwinder in libgcc.a, linked into shipping Android DSOs, has a
PC->eh_frame cache that activates if dl_phdr_info has the dlpi_adds and
dlpi_subs fields (indicated at run-time by a sufficiently-large size
argument to the callback).

Bug: https://github.com/android-ndk/ndk/issues/1062
Test: bionic unit tests
Change-Id: I6f0bab548cf8c828af2ddab9eb01c5c6d70cd81f
2019-08-22 12:43:17 -07:00
Yi Kong
d5da35bc84 Merge changes from topic "clang-r365631-switch-over"
am: 436af3d55b

Change-Id: I116f6b040d47ec6f4fca540322651f7d59305cc9
2019-08-22 11:57:14 -07:00
Tom Cherry
0dc903ee6a stdatomic_test: always use bits/stdatomic.h
am: 32b5f4e16b

Change-Id: I8978d456b4e513913f999552908c342a5f98b4d1
2019-08-22 11:56:59 -07:00
Yi Kong
2da8962f77 Adapt tests due to the new Clang fortify-source warning
am: bf67ea5426

Change-Id: I997e180413e9f647ca6671ce23ef6e6618cd806e
2019-08-22 11:56:24 -07:00
Yi Kong
436af3d55b Merge changes from topic "clang-r365631-switch-over"
* changes:
  Fix segment gap test
  stdatomic_test: always use bits/stdatomic.h
  Adapt tests due to the new Clang fortify-source warning
2019-08-22 18:35:54 +00:00
Yi Kong
e39a51bfd4 Fix segment gap test
The test starts failing in the upcoming lld update. The root cause is
that no relro section is specified by the linker script, and the orphan
placement algorithm decides to place them after .text which is a
misaligned place.

Test: bionic-unit-tests
Bug: 139089152
Bug: 131328001
Change-Id: I2140d8a9fd7c712f1d31a541a3b4a10788385e98
2019-08-17 22:41:25 +00:00
Peter Collingbourne
752b619240 Merge "Fix a few bionic test failures caused by hwasan global instrumentation."
am: 3952113d90

Change-Id: I17d6e9c5448b081c6833af6fc1ec247c997bfc59
2019-08-16 10:56:35 -07:00
Peter Collingbourne
3952113d90 Merge "Fix a few bionic test failures caused by hwasan global instrumentation." 2019-08-16 17:26:05 +00:00
Peter Collingbourne
191ecdc49b Fix a few bionic test failures caused by hwasan global instrumentation.
The call to the load hook needs to be moved before the call to link_image()
because the latter calls ifunc resolvers which might access global
variables. This fixes a bunch of ifunc tests.

The dlfcn.segment_gap test is currently failing. One problem is that the name
of the .bss.end_of_gap section changes as a result of global instrumentation.
Add some wildcards in so that we match both names. The other problem seems
to be the same as b/139089152.

It turns out that we need to untag pointers in a few more places. Since we have
quite a few of these now it seems worth creating a function for it.

Test: bionic-unit-tests
Change-Id: I44e2b0904faacdda7cc0c5e844ffc09de01dea2d
2019-08-15 09:21:34 -07:00
Tom Cherry
32b5f4e16b stdatomic_test: always use bits/stdatomic.h
Host includes are updated now, so we always must include
bits/stdatomic.h

Bug: 137876753
Bug: 138701943
Test: not yet
Change-Id: Ib2ce34ae5dace8f9a114fa8c04f864cd7f41a5d9
2019-08-14 07:08:28 +00:00
Josh Gao
6f844f936f Merge "leak_test: use tgkill to check if threads are alive."
am: 80d85f72dd

Change-Id: I2cb534827a3afa286305d093d498a497c688a3c0
2019-08-13 18:48:23 -07:00
Josh Gao
253ef12f50 leak_test: use tgkill to check if threads are alive.
If one of our threads exits and a new process shows up with the same
tid, we would previously loop until that process exits, leading to
flakiness in tests.

Also fix use of uninitialized memory that happens when threads_count !=
kThreadCount.

Bug: http://b/139315254
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter="pthread_leak.detach" on cuttlefish
Change-Id: I2aad7f3f105aeba87c3929bfce53ef08e1484b2d
2019-08-13 16:13:39 -07:00
Elliott Hughes
15ae87b2fb Merge "Add memfd_create(2) and mlock2(2)."
am: da32ff104b

Change-Id: I2609877a7984e137a785614b6eff01d728472b76
2019-08-06 10:40:22 -07:00
Elliott Hughes
3d24d2b088 Add memfd_create(2) and mlock2(2).
These are old enough now that the latest devices will have kernels that
support them.

Also add basic doc comments to <sys/mman.h>.

Test: treehugger
Change-Id: I1b5ff5db0b6270f5c374287cac1d6a751a0259f5
2019-08-05 16:31:08 -07:00
Yi Kong
bf67ea5426 Adapt tests due to the new Clang fortify-source warning
https://reviews.llvm.org/D58797 added several new compile time
_FORTIFY_SOURCE diagnostics. This broke clang_fortify_tests:

FAILED: out/target/product/walleye/obj/STATIC_LIBRARIES/bionic-compile-time-tests2-clang++_intermediates/clang_fortify_tests.o
error: 'warning' diagnostics seen but not expected:
  Line 159: 'memcpy' will always overflow; destination buffer has size 8, but size argument is 9
  Line 161: 'memmove' will always overflow; destination buffer has size 8, but size argument is 9
  Line 165: 'memset' will always overflow; destination buffer has size 8, but size argument is 9
  Line 183: 'strncpy' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 185: 'stpncpy' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 189: 'strncat' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 227: 'strncpy' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 232: 'stpncpy' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 242: 'strncat' size argument is too large; destination buffer has size 4, but size argument is 5
  Line 490: 'snprintf' size argument is too large; destination buffer has size 8, but size argument is 9
  Line 495: 'vsnprintf' size argument is too large; destination buffer has size 8, but size argument is 9
error: 'note' diagnostics seen but not expected:
  File bionic/libc/include/bits/fortify/fcntl.h Line 50: 'open' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 102: 'open64' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 75: 'openat' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/fcntl.h Line 121: 'openat64' has been explicitly marked unavailable here
  File bionic/libc/include/bits/fortify/stdio.h Line 68: 'sprintf' has been explicitly marked unavailable here
16 errors generated.

Bug: 131328001
Bug: 138701853
Test: Build with r365631 toolchain
Change-Id: I103ecb7b3abcf4b5cfc4f36ccab69e03d0976275
2019-08-05 11:48:47 -07:00
Elliott Hughes
0dc203a547 Merge "Add renameat2."
am: fd56f55419

Change-Id: I6843edd14527e6029271718b076ad5cbc94fee45
2019-08-02 15:19:42 -07:00
Elliott Hughes
05b675e8bf Add renameat2.
Bug: http://b/127675384
Test: new tests
Change-Id: Ia2e3d5679180391ca98e62fa429fa11cbf167507
2019-08-02 09:09:59 -07:00
Tom Cherry
52de5d1a70 Merge "Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)"
am: 6b2532e19a

Change-Id: I78c3d5fb79a63edb71553cd1ebe554511361e6c5
2019-07-19 11:36:49 -07:00
Tom Cherry
d9be229581 Merge "Load /etc/{passwd,group} from all partitions"
am: 5a8482ef8f

Change-Id: I86b764124ba8d926d97f42387af2f28889f5b1be
2019-07-19 11:33:50 -07:00
Tom Cherry
6b2532e19a Merge "Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)" 2019-07-19 18:01:06 +00:00
Tom Cherry
5a8482ef8f Merge "Load /etc/{passwd,group} from all partitions" 2019-07-19 18:00:41 +00:00
Tom Cherry
76e2b15ad4 Change stdatomic.h check from defined(_USING_LIBCXX) to __has_include(<atomic>)
The previous check was causing some problems with platform builds
using the NDK.  The new check is more accurate.

Move the C definitions from stdatomic.h to bits/stdatomic.h since
with the new check, we no longer can use the #undef trick to test
them.

Test: build platform NDK with stdatomic.h in pthread.h header
Test: stdatomic bionic-unit-tests
Change-Id: Ia0bc3cc8344f2ba4e6e55a52248fb6efee799d1d
2019-07-18 13:57:39 -07:00
Tom Cherry
50940c55d2 Merge "Fix pthread_cond_clockwait() when cond is initialized with CLOCK_MONOTONIC"
am: 09ecb00b86

Change-Id: I100818d326b59f335b7f3c78024f29821db35bf7
2019-07-17 14:30:26 -07:00
Tom Cherry
800c1a9707 Fix pthread_cond_clockwait() when cond is initialized with CLOCK_MONOTONIC
A bit of over-reliance on implementing pthread_cond_clockwait() in
terms of existing functions ended up with a bug that if the condition
variable was initialized to use CLOCK_MONOTONIC, then
pthread_cond_clockwait() would do the wrong thing.

This change corrects that and adds a test for this case.

Test: new and existing tests pthread_cond unit tests
Change-Id: I708d5dfbef95a67678db56dceda011f2f8fd1c5c
2019-07-17 10:46:47 -07:00
Tom Cherry
32531b709a Merge "Implement new clock wait functions"
am: 7e958d0ce0

Change-Id: I05e1801d8355aa941102bfc9e382afdea77cbea5
2019-07-15 16:49:22 -07:00
Tom Cherry
69010802d0 Implement new clock wait functions
pthread_cond_clockwait
pthread_mutex_clocklock
pthread_rwlock_clockrdlock
pthread_rwlock_clockwrlock
sem_clockwait

Bug: 35756266
Test: new unit tests
Change-Id: I71bd25eeec6476134b368d5bdf2f729d0bba595e
2019-07-15 09:06:19 -07:00
Tom Cherry
777b34dcc3 Load /etc/{passwd,group} from all partitions
Note that unlike the oem_ range that is used for the vendor
partitions, we do not create oem_<n> entries for these new reserved
ranges; they will only appear in getpwent()/getgrent() if there is an
entry in the corresponding passwd/group file.

Bug: 73062966
Test: can load AIDs from partitions other than vendor
Test: bionic-unit-tests
Change-Id: Ifcbbf202894adff948eaaba2a59e25c993611140
2019-07-11 10:31:02 -07:00
dimitry
63b261096b Merge "Remove unused dependency to libandoridicu"
am: 7d961a16e9

Change-Id: I415fd796093c80fd8964546ebdccca52ff7764e2
2019-07-10 10:23:53 -07:00
dimitry
29fbf6fdd2 Remove unused dependency to libandoridicu
Test: mmma -j42 bionic/
Change-Id: I6049dbea5a55523758649370396a6a5bfb09462f
2019-07-10 15:50:29 +02:00
Elliott Hughes
ae4c2f06e6 Merge "Stop using grep -P."
am: 7d10422499

Change-Id: Ie773bb9a364e9c1a38dd43181e1e1232bb671fcd
2019-07-09 09:10:06 -07:00
Elliott Hughes
165a8c6653 Stop using grep -P.
This might let us get to using toybox grep for the build faster than if
we have to implement PCRE support.

Test: builds
Change-Id: Idaf24cfefbf18fdc442871f24fe4fe9b2152359a
2019-07-08 15:03:19 -07:00
Elliott Hughes
6684b7e877 Merge "The time#clock test has been a bit flaky." am: 05407d81f8
am: 81c16d9770

Change-Id: I5b3af7337a3a49394d3e36a8212189eeeeec09b2
2019-06-21 08:25:43 -07:00