Commit graph

9871 commits

Author SHA1 Message Date
Evgenii Stepanov
b92d1c3a26 Block signals in pthread_create.
HWASan-instrumented code needs TLS_SLOT_SANITIZER set up to run, and
that is not done until the new thread calls __hwasan_thread_enter. Block
all signals until that time to prevent hwasan-instrumented signal
handlers running (and crashing) on the new thread.

Bug: 141893397
Test: seq 0 10000000 | xargs -n 1 -P 200 adb shell am instrument \
      -w -r -e command grant-all \
      com.android.permissionutils/.PermissionInstrumentation

(cherry picked from commit d181585dd5)

Change-Id: Id65fae836edcacdf057327ccf16cf0b5e0f9474a
2019-10-07 15:37:26 -07:00
Jiyong Park
f302cfb26b libc_malloc_[debug|hooks] are not available for platform
The libs are not available for platform. Thus removing
'//apex_available:platform' from the apex_available property. However,
since there are test modules that statically links the libs, we
exceptionally make the static variant of the libs available to the
platform.

Test: m
Test: mm under bionic does not create
out/target/product/<name>/system/lib[64]/libc_malloc_[debug|hooks].so

Change-Id: Ia6d473658c4231b04b5db511f9dacbbdf0f207b0
2019-10-07 15:52:21 +09:00
Jiyong Park
e87e0dcbae Restrict the availability of the bionic libs
The bionic libs are now restricted to be in the runtime APEX and the
platform (for bootstrapping). It can still be referenced from other
APEXes but can't be included there.

Bug: 139870423
Test: m
Change-Id: I7f99eef27ccf75844ca5c9a7ea866496841b738f
2019-10-07 13:52:32 +09:00
Treehugger Robot
3e565bd7ee Merge "fortify(unistd): emit diagnostics regardless of API level" 2019-10-04 06:36:54 +00:00
Elliott Hughes
0e14c5a869 <unistd.h> __INTRODUCED_IN cleaup.
The NDK doesn't support anything older than API level 16, so remove some
more clutter.

Test: builds
Change-Id: If257a27841396af001b089b7ae0fbd8c3e0128e4
2019-10-03 20:35:38 -07:00
George Burgess IV
da8d30f357 fortify(unistd): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I17ad1283cbedaec2ab070134320e1c5401d3e6a4
2019-10-03 20:30:02 -07:00
Treehugger Robot
3398552aa6 Merge "Remove __INTRODUCED_IN for obsolete API levels." 2019-10-04 01:47:03 +00:00
Elliott Hughes
f106a391d3 Remove __INTRODUCED_IN for obsolete API levels.
The NDK only supports >= 16, so remove anything older than that to avoid
giving the misleading impression that such old targets are still
supported.

(This change doesn't touch <unistd.h>. I'll follow up with that once the
outstanding FORTIFY changes to that file are in.)

Test: builds
Change-Id: I6cc6ecdb99fe228a4afa71f78e5fd45309ba9786
2019-10-03 16:09:04 -07:00
Christopher Ferris
b8a95e2186 Update to kernel headers v5.3.2.
Test: Builds and run unit tests on taimen/cuttlefish.
Change-Id: I6ebd8f179d159ac974555e8edca588083e8081b3
2019-10-03 10:59:32 -07:00
Elliott Hughes
3d6cf766be Merge "<sys/select.h>: add docs, and a warning against using select()." 2019-10-03 00:47:25 +00:00
Treehugger Robot
40ef00f039 Merge "fortify(stdio): emit diagnostics regardless of API level" 2019-10-03 00:36:22 +00:00
Elliott Hughes
cfac8d0074 <sys/select.h>: add docs, and a warning against using select().
Test: N/A
Change-Id: I596d63f2c8039434e2b8023eefb944da5c4bbb40
2019-10-02 14:13:54 -07:00
Christopher Ferris
e55e5eef8a Make it easy to switch between scudo and jemalloc.
Refactor some of the definitions to separate out all of the native
allocator pieces into one place that can be changed easily. This
should fix a few static libraries that appear to have accidentally
included jemalloc wrapper functions. For example, I verified that
libc_nomalloc.a no longer has references to any je_XXX functions.

Modify the bionic_libc_platform_headers to not include any libraries.
If this isn't updated, soong thinks there are cycles when used by
libscudo.

To enable scudo, change the libc_native_allocator_defaults defaults
from libc_jemalloc5_defaults to libc_scudo_defaults and comment out
the defaults: ["libc_scudo_wrapper_defaults"], line for the shared
library libc_scudo.

To do a final switch to scudo, it will be necessary to clean up
some code in other parts of the tree, but this allows a single cl
to enable or disable.

Bug: 137795072

Test: Builds with jemalloc or scudo with a small change.
Test: Ran bionic unit tests.
Change-Id: I07bb5432a0d2b2f405f92412e8d04fb9c9e51b31
Merged-In: I07bb5432a0d2b2f405f92412e8d04fb9c9e51b31
(cherry picked from commit ccff1b19ef)
2019-10-02 09:45:13 -07:00
George Burgess IV
113d6fa14e fortify(stdio): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I875a072c74f578d4404576c5bb42fd8ea30ff68d
2019-09-30 13:00:36 -07:00
George Burgess IV
db87607524 fortify(poll): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I5e147d28ec606c104b5905fd3d0c3fc197f0e4b8
2019-09-30 13:00:36 -07:00
George Burgess IV
bc37c5a8ce fortify(strings): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: Ief185320f93ec31f4d0a8035c450a7ab7b4e02b4
2019-09-30 13:00:35 -07:00
George Burgess IV
d0a0f72852 fortify(socket/stat): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I7fe29184290e19ec080b204aa98d513ce59bc66b
2019-09-30 13:00:35 -07:00
Elliott Hughes
82ee3a08e2 Merge "Optimize tolower(3)/toupper(3) from <ctype.h>." 2019-09-30 18:49:51 +00:00
Christopher Ferris
d24c14d817 Merge "Make tls related header files platform accessible." 2019-09-30 16:15:33 +00:00
Elliott Hughes
1c8a2a99a7 Optimize tolower(3)/toupper(3) from <ctype.h>.
The tables in the BSD tolower/toupper are slower for ASCII than just
doing the bit twiddling.

We can't actually remove the tables on LP32, so move them into the
"cruft" we keep around for backwards compatibility (but remove them for
LP64 where they were never exposed).

I noticed that the new bit-twiddling tolower(3) was performing better
on arm64 than toupper(3). The 0xdf constant was requiring an extra MOV,
and there isn't a BIC that takes an immediate value. Since we've already
done the comparison to check that we're in the right range (where the
bit is always set), though, we can EOR 0x20 to get the same result as
the missing BIC 0x20 in just one instruction.

I've applied that same optimization to towupper(3) too.

Before:

  BM_ctype_tolower_n                 3.30 ns         3.30 ns    212353035
  BM_ctype_tolower_y                 3.31 ns         3.30 ns    211234204
  BM_ctype_toupper_n                 3.30 ns         3.29 ns    214161246
  BM_ctype_toupper_y                 3.29 ns         3.28 ns    207643473

  BM_wctype_towupper_ascii_n         3.53 ns         3.53 ns    195944444
  BM_wctype_towupper_ascii_y         3.48 ns         3.48 ns    199233248

After:

  BM_ctype_tolower_n                 2.93 ns         2.92 ns    242373703
  BM_ctype_tolower_y                 2.88 ns         2.87 ns    245365309
  BM_ctype_toupper_n                 2.93 ns         2.93 ns    243049353
  BM_ctype_toupper_y                 2.89 ns         2.89 ns    245072521

  BM_wctype_towupper_ascii_n         3.34 ns         3.33 ns    212951912
  BM_wctype_towupper_ascii_y         3.29 ns         3.29 ns    214651254

(Why do both the "y" and "n" variants speed up with the EOR
change? Because the compiler transforms the code so that we
unconditionally do the bit twiddling and then use CSEL to decide whether
or not to actually use the result.)

We also save 1028 bytes of data in the LP64 libc.so.

Test: ran the bionic benchmarks and tests
Change-Id: I7829339f8cb89a58efe539c2a01c51807413aa2d
2019-09-27 14:42:39 -07:00
Peter Collingbourne
4096cba7f8 Merge "Disable sanitization of crt objects." 2019-09-27 19:31:13 +00: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
Balaram Makam
0e670e26a2 ASCII fastpath for towupper and towlower.
This change elides unnecessary calls to __find_icu_symbol
for ASCII chars and improves PUBG mobile game loading time by 7% on
hikey620(Cortex-A53):

name                old time/op  new time/op  delta
PUBG_0.13.0_Launch   41.5s ± 2%   37.7s ± 3%  -9.24%  (p=0.008 n=5+5)

Below are the bionic benchmark results on a Pixel 2 XL for 64-bit,
showing a large speedup for ASCII and only a small slowdown for non-ASCII.

Before:

  BM_wctype_towlower_ascii_n         10.5 ns         10.4 ns     61973065
  BM_wctype_towlower_ascii_y         10.2 ns         10.2 ns     70158659
  BM_wctype_towlower_unicode_n       10.3 ns         10.3 ns     67719478
  BM_wctype_towlower_unicode_y       10.6 ns         10.5 ns     67841545
  BM_wctype_towupper_ascii_n         10.8 ns         10.8 ns     63456778
  BM_wctype_towupper_ascii_y         10.9 ns         10.9 ns     65116910
  BM_wctype_towupper_unicode_n       10.7 ns         10.7 ns     67463276
  BM_wctype_towupper_unicode_y       10.4 ns         10.4 ns     66467890

After:

  BM_wctype_towlower_ascii_n         3.35 ns         3.34 ns    205567652
  BM_wctype_towlower_ascii_y         3.30 ns         3.29 ns    214108746
  BM_wctype_towlower_unicode_n       10.9 ns         10.8 ns     65007743
  BM_wctype_towlower_unicode_y       10.6 ns         10.6 ns     63819060
  BM_wctype_towupper_ascii_n         3.53 ns         3.53 ns    195944444
  BM_wctype_towupper_ascii_y         3.48 ns         3.48 ns    199233248
  BM_wctype_towupper_unicode_n       11.1 ns         11.1 ns     62760216
  BM_wctype_towupper_unicode_y       11.0 ns         11.0 ns     61608872

Test: bionic unit tests on device
Test: bionic benchmarks on device
Signed-off-by: Balaram Makam <b.makam@samsung.com>
Change-Id: I77ab7efb66d7bcb35d00467663607535e5c1992f
2019-09-27 16:41:03 +00:00
Peter Collingbourne
7eb851c7da Disable sanitization of crt objects.
The accompanying soong change causes sanitize attributes to be allowed on
cc_object targets and propagates sanitize attributes into dependencies. This
is problematic for the crt objects in sanitizer builds because everything
depends on them including the sanitizer runtime, so a circular dependency
would otherwise be created. Furthermore, some of the code in these objects
runs before sanitizer initialization so it is unlikely that sanitizing them
would work anyway. Therefore, disable sanitization on these objects.

Change-Id: I25380dfc8eed5db34b034ba127a9d6b5674032fa
2019-09-26 12:16:06 -07:00
John Cater
e86e505b85 Fix gensyscalls.py to actually use the input argument provided in
bionic/libc/Android.bp.

Test: Built and tested bionic.
Change-Id: Ibb25990b2b1b5c18edfdaaab4f1593fa8d95f338
2019-09-26 15:02:04 -04:00
Evgeny Eltsin
8a18af52d9 Make more pthread functions weak for native bridge
These are using __pthread_internal_*.

Test: run bionic-unit-tests on cuttlefish
Change-Id: Idbb2503f03bd9f1f2a20fced34b734f573c1c0ad
2019-09-25 16:55:47 +02:00
Elliott Hughes
1db8fdb76e Merge "Remove global seccomp list." 2019-09-18 18:10:13 +00:00
Elliott Hughes
fa43309a59 Merge "ifuncs: start sharing." 2019-09-18 18:01:54 +00:00
Elliott Hughes
ae03b12925 Remove global seccomp list.
Never used, and incompatible with having bionic in a mainline module.

Test: builds
Change-Id: If377f66cc105fd3a1ec4d9c92330fa6a2d2c145c
2019-09-17 16:37:05 -07:00
Treehugger Robot
e6c3f0628c Merge "fortify: account for new clang diagnostics" 2019-09-17 20:11:51 +00:00
Elliott Hughes
a4c7876c01 ifuncs: start sharing.
We're going to have to add ifuncs to libm, and there will be some SVE
ones for arm64 soon too, so let's start sharing the absolute minimum...

Test: builds
Change-Id: Idbb9dd9477291ed3c15dc3902f65e593b766dfb9
2019-09-17 12:44:41 -07: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
Ryan Prichard
85be9725c7 crtbegin: replace TPREL with R_*_NONE relocs
Bug: https://bugs.llvm.org/show_bug.cgi?id=41527
Test: bionic unit tests
Change-Id: Ia66c969b209c0f72d1e37573949f3fb59817ca71
2019-09-04 20:31:06 +00:00
Christopher Ferris
e2c10d8de0 Merge "Update to kernel headers v5.2.11." 2019-09-04 19:44:24 +00:00
Treehugger Robot
d0494b368e Merge "Test for ns_parserr() and got a heap-buffer-overflow" 2019-09-04 02:21:43 +00:00
Logan Chien
2fb9a03b9c Merge "versioner: Fix bzero/bcopy fortify" 2019-09-03 23:12:43 +00:00
Christopher Ferris
e892fd6b17 Update to kernel headers v5.2.11.
Test: Build and boots on taimen.
Test: Bionic unit tests all pass on taimen.
Change-Id: I80abb6f9abbff9ca20ce6c7c912a259b5ca86fa2
2019-09-03 15:56:49 -07:00
Elliott Hughes
37ff081e88 Merge "Support statvfs on API levels before 19." 2019-09-03 22:28:36 +00:00
Christopher Ferris
add3a4ae70 Merge "Add EFD_SEMAPHORE flag for eventfd." 2019-09-03 19:16:55 +00: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
Logan Chien
8292d04da5 Merge "versioner: Fix C11 threads.h" 2019-09-03 16:22:02 +00:00
Logan Chien
b33952c777 versioner: Fix bzero/bcopy fortify
This commit replaces `bzero` with `__bionic_bzero` and `bcopy` with
`__bionic_bcopy` because `bzero` and `bcopy` are partially defined in
`libc.map.txt`.  Bionic versioner raises errors because versioner treats
static inline functions as exported function definitions then it
compares the availability with the information specified in
`libc.map.txt`.

This commit fixes the problem by replacing static inline functions into
`__bionic_{bzero,bcopy}` and defining aliases for source-level
compatibility.

Test: PATH=$(pwd)/prebuilts/clang-tools/linux-x86/bin:$PATH \
      bionic/tools/versioner/run_tests.py
Bug: 140110040

Change-Id: I97f2f0dc0abccd0a9fcfe5bb02f4e918362d35cc
2019-08-30 10:17:36 -07:00
Elliott Hughes
261bd745ee Support statvfs on API levels before 19.
Split statfs and statvfs. The former has been available forever, and the
latter is implemented in terms of the former. The implementation has
been moved into headers so that it can be used at low API levels.

There's no reason for any Android or Linux code to use statvfs rather
than statfs, but code that needs to build on Darwin too will want to use
statvfs because Darwin's statfs is very spartan.

Bug: https://github.com/android-ndk/ndk/issues/609
Test: treehugger
Change-Id: Icf3d5723a260099fddb2d9f902e3047b0f041647
2019-08-29 21:57:58 -07:00
Logan Chien
235aad1981 versioner: Fix C11 threads.h
This commit annotates C11 Thread APIs so that bionic versioner won't
report errors.

This commit also adds a guard before `mtx_timedlock` because
`pthread_mutex_timedlock` was introduced in Android L.

Test: PATH=$(pwd)/prebuilts/clang-tools/linux-x86/bin:$PATH \
      bionic/tools/versioner/run_tests.py
Bug: 140110040

Change-Id: I3c6ce0831f613ffd3a7bf1c1972fd3548195cc56
2019-08-29 16:40:34 -07:00
Martin Stjernholm
6d5277dbaa Update references to the new com.android.art APEX.
Test: Flash & boot
Test: atest CtsJniTestCases CtsBionicTestCases
Bug: 135753770
Exempt-From-Owner-Approval: Approved internally
Change-Id: I1c16a798edc494e75b9d703990de08e60686a3ea
Merged-In: I1c16a798edc494e75b9d703990de08e60686a3ea
2019-08-29 18:07:50 +01:00
chenbruce
2cc76462e5 Test for ns_parserr() and got a heap-buffer-overflow
In ns_name_skip of ns_name.c, there is a possible out of bounds read due to
a missing bounds check. This could lead to remote denial of service with no
additional execution privileges needed. User interaction is not needed for
exploitation.

Bug: 137346580
Test: built, flashed, booted
Test: ns_parserr_fuzzer test
Change-Id: Ib023bd9b2ae97795d64195de9922a6a32d7b2f37
2019-08-29 22:18:37 +08:00
Ryan Savitski
9db3486a12 Add arm32 case to BIONIC_STOP_UNWIND to correctly stop unwinders
The arm32 case was omitted when the macro was originally added due to
clang issues (b/15469122#comment5).

Testing at ToT master, ".cfi_undefined r14" appears to compile & work as
expected. This is the same directive as used by the linker's begin.S.

Test: ran a 32 bit binary on crosshatch-userdebug, verified that
"debuggerd -b" (which uses libunwindstack) stops at __libc_init as in
the arm64 case (before it would unwind past _start_main, with an
erroneous frame at the bottom).

Test: ran unwind_reg_info tool on /system/lib/libc.so with an address
within __libc_init, confirmed that the "debug_frame" section includes
"r14 = undefine" (arm exidx still contains "r14 = [cfa - 4]", but that
looked correct to cferris@).

Bug: 140008396
Change-Id: I6eb0bc6cf516fddee2df40492350678a0547fee3
2019-08-27 22:50:21 +01:00
Vic Yang
f1fde773e1 Move __dso_handle to RELRO
Most DSOs have a RELRO segment, but some of them have nothing except
__dso_handle in their .data section.  This means __dso_handle is taking
up a page as well as a vm_area_struct in kernel slabs for those DSOs.

Let's move it to the RELRO segment to save memory.

On a 32-bit device I tested on, I saw ~400 KB less slab usage on
vm_area_struct.  To control for difference in number of cached
processes, I also measured with Android stopped, and I saw ~100 KB less
slab usage.  Summing up all dirty pages attributed to shared libraries,
I saw 5.6 MB less dirty pages.

Test: Build and boot.
Change-Id: Ib88e49f1c72352e610affc19623895d954110d4e
2019-08-26 20:35:00 -07:00
Ryan Prichard
665e98edf7 Merge "Add additional dl_phdr_info fields" 2019-08-23 20:45:54 +00: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
Treehugger Robot
74e56438bb Merge "Link libc++demangle." 2019-08-21 23:54:48 +00:00
Treehugger Robot
28cf07f93d Merge "Reland "fdsan: make fatal by default."" 2019-08-21 07:57:28 +00:00
Josh Gao
6a51013728 Reland "fdsan: make fatal by default."
The two tests known to be failing (installd_dexopt_test and BpfMapTest)
have been fixed, so let's try this again.

This reverts commit 76351e3e3f.

Bug: http://b/137788030
Bug: http://b/139092341
Bug: http://b/139175951
Test: treehugger
2019-08-20 17:59:14 -07:00
Elliott Hughes
f69d852f27 Automatically include <android/ndk-version.h> from every header.
(Via <sys/cdefs.h>, which is where we get <android/api-level.h> from.)

Not super helpful today, but when NDK r21 is the oldest NDK anyone cares
about, they'll be able to stop worrying about this specific header as
long as they've included _something_.

Test: builds
Change-Id: Ia5bc42f89b7025d8e3963e4fd590f0e3723157be
2019-08-20 13:18:57 -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
Treehugger Robot
2fbbc253f6 Merge "Fix OOB read in fortify str[np]cpy implementations found by hwasan." 2019-08-15 05:26:43 +00:00
Tom Cherry
a960142fe3 Fix timespec.h documentation
There are 1,000,000,000 nanoseconds in a second.

Test: n/a
Change-Id: I8ce622ce3c60d7d5b06a056cfd0e6bea976b5aab
2019-08-12 13:34:03 -07:00
Pete Gillin
c6c17ac1e8 Merge "Revert "fdsan: make fatal by default."" 2019-08-09 11:29:36 +00:00
Pete Gillin
76351e3e3f Revert "fdsan: make fatal by default."
This reverts commit 66b5e3ca19.

Reason for revert: Causes installd_dexopt_test to fail. Presumably there is an existing issue which this change is turning into a hard fail, so that needs to be fixed before this can be rolled forwards. See b/139092341.

Bug: 139092341
Bug: 137788030
Change-Id: I1beccddff64c86541bc003b9b009f4046ec9cbf1
2019-08-09 11:18:39 +00:00
Peter Collingbourne
a51bded572 Fix OOB read in fortify str[np]cpy implementations found by hwasan.
The fortify implementations of stpncpy and strncpy read out of bounds and
only then check that they did so. This causes newer versions of hwasan
to complain during the fortify tests as a result of the new support for
byte-precise error checks. Move the bounds check into the loop so that it
is detected before the load.

Test: bionic-unit-tests
Change-Id: Id990a4a0217f6c4b39bba60ff41776875615fcb4
2019-08-08 18:54:31 -07:00
Tom Cherry
5dea560e4c Merge "Remove now unneeded #undef in __cxa_guard.cpp" 2019-08-07 23:04:50 +00:00
Josh Gao
592b5f52fd Merge "fdsan: make fatal by default." 2019-08-07 19:53:40 +00:00
Josh Gao
66b5e3ca19 fdsan: make fatal by default.
Make fdsan fatal by default on native processes, and Java processes that
target R or later.

Bug: http://b/137788030
Test: manual
Change-Id: I5900efc606fc0d47b69223574ad7dca89afe4eda
2019-08-07 19:53:14 +00:00
Tom Cherry
08baac348c Remove now unneeded #undef in __cxa_guard.cpp
Before aosp/1086558, this was needed, since we would have
_USING_LIBCXX defined, yet <atomic> was not available, so we'd run
into compiler issues.  After that change, we're using
__has_include(<atomic>) so this is no longer an issue.

Test: build
Change-Id: Ia81d343000e7d90f07422120fc1e1eb5becb01aa
2019-08-07 11:10:22 -07:00
Elliott Hughes
da32ff104b Merge "Add memfd_create(2) and mlock2(2)." 2019-08-06 17:08:13 +00:00
Christopher Ferris
5d3ba4ed9d Merge "Update to kernel headers v5.2.6." 2019-08-06 04:30:52 +00:00
Peter Collingbourne
6533208aaa linker: Add library load and unload hooks for HWASan.
These hooks notify the HWASan runtime library whenever a library is loaded
or unloaded so that it can update its shadow memory.

Bug: 138159093
Test: walleye_hwasan-userdebug boots with+without https://reviews.llvm.org/D65770
Change-Id: I6caf2a6540ed2c0d94db444e806a3c7ba504cabb
2019-08-05 16:51:01 -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
Christopher Ferris
fa59a10bcd Update to kernel headers v5.2.6.
Also, fix a bug in update_all.py when the syscalls file does not change.

Test: Builds and boots on a taimen.
Change-Id: If85b00daef2c176f804a0861894f5bbca9c6d5df
2019-08-05 12:59:58 -07:00
Elliott Hughes
9a5bdd6d45 Update seccomp whitelist.
renameat2 is now exposed, my comment about timerfd was nonsense, and
it's worth documenting when and where the various syscalls appeared.

Bug: http://b/127675384
Test: treehugger
Change-Id: I84662398d39678df3ee7ce39add670337ff8abea
2019-08-05 08:56:40 -07:00
Elliott Hughes
fd56f55419 Merge "Add renameat2." 2019-08-02 21:53:18 +00:00
Elliott Hughes
05b675e8bf Add renameat2.
Bug: http://b/127675384
Test: new tests
Change-Id: Ia2e3d5679180391ca98e62fa429fa11cbf167507
2019-08-02 09:09:59 -07:00
Elliott Hughes
ee7bc3002d seccomp: add the "64-bit time for 32-bit processes" system calls.
The cuttlefish folks are hitting this because the VDSO clock_gettime
falls back to the clock_gettime64 system call when given an invalid
clock.

Bug: http://b/138781460
Test: examined the generated .cpp files.
Change-Id: I98b311cd8652716eb6d45fb99308fdf952e79ba3
2019-08-01 15:16:58 +00:00
Ryan Prichard
c2a722f5d7 Merge changes I99d2faae,Ie98b7624
* changes:
  Enable traditional TLS accesses on arm64
  Renumber arm64 TLS to match GNU values
2019-07-31 20:50:58 +00:00
Ryan Prichard
30feb645f9 Enable traditional TLS accesses on arm64
Handle generic DTPMOD/DTPREL relocations on arm64. Expose __tls_get_addr.

Bug: http://b/123385182
Test: manual -- compile code using arm64 gcc -mtls-dialect=trad
Change-Id: I99d2faae35d1ebffc1be8de50b4a1f5e21b14348
2019-07-30 20:55:54 -07:00
Ryan Prichard
6d601458de Renumber arm64 TLS to match GNU values
The AArch64 ELF specification originally specified these relocations:

  R_AARCH64_TLS_DTPREL64          1028
  R_AARCH64_TLS_DTPMOD64          1029

However, the GNU toolchain implemented them as:

  R_AARCH64_TLS_DTPMOD64          1028
  R_AARCH64_TLS_DTPREL64          1029

The AArch64 ELF specification has been updated to replace the relocations
with R_AARCH64_TLS_IMPDEF1 and with R_AARCH64_TLS_IMPDEF2, where each
implementation can choose which interpretation it implements, but with a
suggestion to follow the GNU behavior.

Also: remove the 64 suffixes from the TLS relocations. The newest version
of the AArch64 ELF specification (version f) also omits the suffixes, as
do the glibc headers.

Bug: http://b/123385182
Bug: https://bugs.llvm.org/show_bug.cgi?id=40507
Test: build device, it boots
Change-Id: Ie98b7624752982973f0ac969d646454a86784cab
2019-07-30 16:30:46 -07:00
Pirama Arumuga Nainar
876c6f03f9 Merge "Fix clang header dependency for versioner" 2019-07-30 05:08:18 +00:00
Pirama Arumuga Nainar
49c733cc49 Fix clang header dependency for versioner
Versioner is now a prebuilt in prebuilts/clang-tools and that project
has the Clang headers packaged with it.  Use that dependency instead of
external/clang/lib/Headers.  Use the linux-x86 path for both Linux and
Darwin since they are both the same.

Test: presubmit
Change-Id: I01ad4c05fe3301a2fdad3662377f78694af6cd81
2019-07-29 15:44:46 -07:00
Vic Yang
03ff4365ec Use the new sort_bss_symbols_by_size option for libc
Instead of maintaining a symbol ordering file, using the new
sort_bss_symbols_by_size property allows for symbol sorting at build
time.

Bug: 135754984
Test: Build and check the resulting libc.so has its bss symbols sorted.
Change-Id: I4a1cd6774dfe61b73f454bdf95b535db1f9fb1ac
2019-07-29 13:26:33 -07:00
Ryan Prichard
d5c0a508bc Merge "Name stack+tls VMAs with PR_SET_VMA_ANON_NAME" 2019-07-24 20:46:32 +00:00
Dan Albert
4ea19214a4 Link libc++demangle.
The demangler is moving out of libc++abi to save on bloat.

Test: make checkbuild
Bug: http://b/138245375
Change-Id: I7402894bb326f524388c9efdf86509dad50f2018
2019-07-24 12:16:41 -07:00
Treehugger Robot
4f40d47a02 Merge "Add missing nothrow attribute" 2019-07-24 01:10:58 +00:00
Yi Kong
7b50f7d51e Add missing nothrow attribute
The upcoming compiler update emits warning about the missing nothrow
attribute:

  bionic/libc/bionic/jemalloc.h:33:5: error: 'je_mallctl' is missing exception specification '__attribute__((nothrow))' [-Werror,-Wmissing-exception-spec]
  int je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
      ^
                                                                                           __attribute__((nothrow))
  external/jemalloc_new/include/jemalloc/jemalloc.h:230:38: note: previous declaration is here
  JEMALLOC_EXPORT int JEMALLOC_NOTHROW    je_mallctl(const char *name,
                                          ^
  external/jemalloc_new/include/jemalloc/jemalloc_rename.h:12:22: note: expanded from macro 'je_mallctl'
  #  define je_mallctl je_mallctl

Test: build with clang r365631
Bug: 131328001
Change-Id: Ia8b6f47d38e5a003b6282f10724b65b1f971ba84
2019-07-23 15:03:16 -07:00
Florian Mayer
6883b0807b Reserve signal for java heap dumps.
We will put instrumentation in ART to write out Java heap memory
information on receipt of this signal.

Bug: 136210868
Test: Flash blueline-userdebug and boot

Change-Id: I63173a4051c46b8569faaf3064e1db1dbd0ea3fe
2019-07-23 16:38:00 +01:00
Ryan Prichard
03cef383ba Name stack+tls VMAs with PR_SET_VMA_ANON_NAME
Bionic creates a single thread mapping to hold a thread's stack and static
TLS memory. Use PR_SET_VMA_ANON_NAME to name this region
"stack_and_tls:tid". dumpsys meminfo can report this region as "Stack"
memory.

The main thread's memory is instead named stack_and_tls:main, and the VMA
is renamed to stack_and_tls:main in a post-fork child.

For the main thread, and threads using pthread_attr_setstack, Bionic still
creates the stack_and_tls mapping, but it only has TLS memory in it.

Bug: http://b/134795155
Test: run "dumpsys meminfo" and verify that this CL increases the reported
  stack memory usage from about 4MB to 21MB.
Change-Id: Id1f39ff083329e83426130b4ef94222ffacb90ae
Merged-In: Id1f39ff083329e83426130b4ef94222ffacb90ae
2019-07-23 02:06:51 +00: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
Paul Duffin
91b0430a08 Merge "Add bionic_libc_private_headers for use by art" 2019-07-19 09:18:47 +00:00
Christopher Ferris
9782b87074 Move to the libc++ demangler.
Bug: 136138882

Test: Ran malloc debug tests.
Test: Ran an app with backtrace_full and verified demangling working in
Test: log file.
Test: Enabled leak checking and verified that the logs include properly
Test: demangled.
Change-Id: Ic4fd9f1522451e867048ac1bea59d8c5ed0d3577
2019-07-18 21:11:22 +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
Paul Duffin
6b5cb034e3 Add bionic_libc_private_headers for use by art
This avoids art having a direct reference to bionic directories which
would prevent the bionic module from being unbundled from the runtime
module.

Bug: 134379140
Test: m droid
Change-Id: I9545767b76341fd01166b675bdd156f620d4f262
2019-07-18 14:48:44 +01:00
Tom Cherry
9cf76012aa Merge "Update notice" 2019-07-17 21:11:15 +00:00
Tom Cherry
40f69aefb2 Update notice
4ed2f475d8 added new items for NOTICE,
but didn't update the NOTICE file.

Test: none
Change-Id: I558271dc4520d9685dd164ba9f0b6db13d125014
2019-07-17 10:56:16 -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
Treehugger Robot
59cc0b3142 Merge "Clear pointer tags as required for HWASAN for globals." 2019-07-17 01:03:48 +00:00
Elliott Hughes
3975431aba Merge "Add avx2 version of wmemset in binoic" 2019-07-16 23:00:24 +00:00
Peter Collingbourne
45f0a3b642 Clear pointer tags as required for HWASAN for globals.
A future version of HWASAN will set pointer tags when taking the address of
a global. This means that we need to untag pointers in a couple of cases
where potential global pointers are passed to an interface that expects
untagged pointers:

- The WriteProtected class, whose only instances are globals, passes its
  own address to mprotect. However, our device kernels do not currently
  untag pointers passed to mprotect (the proposed upstream kernel patches
  do, however, untag these pointers), so once HWASAN starts tagging global
  pointers, this will start failing.
- The shadow_load function loads from a shadow that corresponds to the
  address space bounds of loaded binaries. Since these address space
  bounds are untagged, the pointer needs to be untagged to match.

Test: boots
Change-Id: I3f11ce6eb7261752e5ff6d039d04dd45516b236f
2019-07-16 13:38:38 -07:00
Shalini Salomi Bodapati
4ed2f475d8 Add avx2 version of wmemset in binoic
Test: ./tests/run-on-host.sh 64
Change-Id: Id2f696cc60a10c01846ca3fe0d3a5d513020afe3
Signed-off-by: Shalini Salomi Bodapati <shalini.salomi.bodapati@intel.com>
2019-07-16 18:06:57 +05:30
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
Elliott Hughes
c80af7f146 Merge "Explicitly add open/stat64 to the seccomp common whitelist." 2019-07-12 16:25:17 +00:00
Treehugger Robot
34d11e52af Merge "Avoid calling snprintf in bionic_trace_begin." 2019-07-11 23:39:38 +00:00
Elliott Hughes
33e079900d Explicitly add open/stat64 to the seccomp common whitelist.
They're used by 32-bit sanitizers. We used to get these for free (as the
comment says), but the place we got them from changed. Just be explicit.

Longer-term we should fix how we build the sanitizers to only use the
canonical system calls, like they already do for arm64.

Bug: https://issuetracker.google.com/136777266
Test: builds
Change-Id: If80a8d47aa345aaaa8bed32b44f020e06e504d49
2019-07-11 14:59:12 -07:00
Josh Gao
e1d121bef6 Avoid calling snprintf in bionic_trace_begin.
snprintf always calls free (on a null pointer) in its epilogue, which
results in infinite recursion if free calls a function that calls
bionic_trace_begin (e.g. when perfetto attempts to lock a mutex in
RecordFree).

Bug: http://b/137284735
Test: treehugger
Change-Id: I51c5b32e8f4e394be4602e06c7b94797df73c37b
2019-07-11 13:00:26 -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
Christopher Ferris
78977053a7 Merge "Update to kernel headers v5.2." 2019-07-09 17:16:53 +00:00
Christopher Ferris
3d0bafb945 Do not check tcache clear when doing a purge.
On systems where the tcache is disabled, the tcache clear option will
fail, and not really do a purge.

Bug: 137037462
Bug: 136236080

Test: Built taimen as malloc svelte and verified the M_PURGE mallopt
Test: call failed before this fix and passes afterwards.
Change-Id: Ib30e5f3e083a9c6d046adff30f2aa7eacaf6df10
2019-07-08 15:15:01 -07:00
Christopher Ferris
aeddbcfb2c Update to kernel headers v5.2.
Test: Booted a taimen, ran unit bionic unit tests.
Change-Id: I3522c59793bbcef98ea515996a481d92f14b8816
2019-07-08 13:54:11 -07:00
Elliott Hughes
b2bd7c575e Merge "libnetd_client: support hooking sendto/sendmsg/sendmmsg too." 2019-06-24 15:04:25 +00:00
George Burgess IV
36bc922772 Merge changes I33957ad4,I02f8f87d,Iba04e486
* changes:
  fortify: replace bzero/bcmp defines
  fortify: add __mempcpy_chk
  fortify: fix overflow checks in unistd
2019-06-21 00:18:44 +00:00
George Burgess IV
261b7f4867 fortify: replace bzero/bcmp defines
__builtin_*_chk will emit warnings when things are trivially broken.
Emitting errors instead is probably better (and we can be a bit smarter
about how we emit code for trivially safe cases.)

Bug: 131861088
Test: checkbuild + bionic-unit-tests on blueline
Change-Id: I33957ad419922d0760304758ecb9bc8ad33e0b64
2019-06-20 13:05:23 -07:00
George Burgess IV
3bdeae781f Merge changes I557309b3,If5f47e0e
* changes:
  fortify: add even more warnings
  fortify: fix up a few diagnostics; add __wur to realpath
2019-06-20 17:20:52 +00:00
Elliott Hughes
5c6a3f9fbc libnetd_client: support hooking sendto/sendmsg/sendmmsg too.
Samsung has asked for this for KNOX.

Test: treehugger
Change-Id: Iffaace9f8cb265ce8c911472989c9829cbf91a42
2019-06-20 08:32:24 -07:00
Elliott Hughes
50080a29f7 Remove the ___ hack.
Plain __ for generated syscalls didn't mean it was a hidden symbol, it
just meant "please don't use this". We added ___ to signify that a
hidden symbol should be generated, but then we added the map files
anyway so you now have to explicitly export symbols. Given that, this
convention serves no particular purpose so we may as well just use the
nicer names have everything look the same.

Test: treehugger
Change-Id: If424e17a49c36f4be545f5d283c4561a6ea9c7ea
2019-06-19 15:38:42 -07:00
Marco Nelissen
745137c827 Merge "Fix overflow check in malloc_limit" 2019-06-18 20:10:01 +00:00
Marco Nelissen
323431bc27 Fix overflow check in malloc_limit
Bug: 135201859

Change-Id: I78dcc497cb100ab1d5f4144e2774437891719ca3
2019-06-18 10:15:28 -07:00
George Burgess IV
849c0b9f51 fortify: add __mempcpy_chk
Bug: 131861088
Test: mma + bionic-unit-tests on blueline
Change-Id: I02f8f87d5db0ba5fecec410da32f6ffa2c98ef57
2019-06-13 23:29:37 -07:00
George Burgess IV
26d25a22e2 fortify: add even more warnings
Bug: 131861088
Test: mma
Change-Id: I557309b3e25b54321ee1fe0207f18b6e840bf76e
2019-06-13 23:26:02 -07:00
George Burgess IV
2356c93d39 fortify: add bit checking for open(at)?64 functions
This also adds _2-variants for these functions, for extra glorious
checking

Bug: 131861088
Test: mma
Change-Id: I80475ff4bb220c0c47894e9532426f53412f176f
2019-06-13 23:26:02 -07:00
George Burgess IV
74519e7aa5 fortify: fix overflow checks in unistd
We should only be calling _real versions of the functions that use this
if the input size is verifiably <= SSIZE_MAX. Otherwise, just fall
through to _chk and let that handle it.

Bug: 131861088
Test: mma && bionic-unit-tests
Change-Id: Iba04e486ef91ea1b3539ab6df6260429264e66b4
2019-06-13 23:26:02 -07:00
George Burgess IV
8c0ec114c5 fortify: fix up a few diagnostics; add __wur to realpath
As it says on the box.

Since realpath isn't a function definition, any attributes it provides
here just add to the "regular" realpath.

__wur is being added to realpath because it returns NULL on failure, and
the contents of the input buffer are undefined in that case. A blueline
checkbuild showed 0 complaints about this new __wur, so it seems
harmless to add.

Bug: 131861088
Test: mma
Change-Id: If5f47e0e290d86df69c0888711e29775c390fca4
2019-06-13 23:26:02 -07:00
George Burgess IV
77f99aaf58 fortify: add diagnostics for str* functions
This CL allows us to diagnose string functions that get an explicit size
passed into them, and string functions that are trivially misused.

Bug: 131861088
Test: mma
Change-Id: I894aec99420a75c6474cfd7d5010f0cf2f10ab21
2019-06-13 23:26:02 -07:00
Neil Fuller
41636ca1ac Remove bionic refs to runtime module tz files
The tzdata file is being removed from the runtime mainline module
in an upcoming commit. This commit removes the bionic references
to it.

This commit also contains general comment tidy-ups.

Bug: 132168458
Test: build only
Change-Id: I83cd9ff756b36e1d1222b7830f97c8bde2885ce4
2019-06-10 15:09:15 +01:00
Elliott Hughes
738a6c92e5 <arpa/nameser.h>: fix INTRODUCED_IN API level.
Historical research (see bug) suggests that these functions were all in
22. The map file believed this with one (presumably typoed) exception,
but the header file didn't match the map file. It looks like the map was
correct (modulo the one typo), so fix up all the disagreement.

Bug: http://b/113618851
Test: treehugger
Change-Id: Ia579f4e6163206abfac79aa54dc98c792f00ee86
2019-06-06 09:57:54 -07:00
Yi Kong
6cfd9a1071 Merge "Clean up no_libgcc" 2019-06-05 00:58:35 +00:00
Elliott Hughes
1b61d78fc1 Build 32-bit ARM assembler with -mno-restrict-it.
We're not going to change this code, ARM's not going to break it.
Silence the warnings.

Bug: http://b/114120867
Test: treehugger
Change-Id: Ie25ef44706c952efc5d54012391bee19af095818
2019-06-04 10:38:34 -07:00
Yi Kong
cd3155dd17 Clean up no_libgcc
This property is getting removed.

Test: build
Change-Id: Ib7b8cb189b21b55da6305f6644b0b029b41e8e4b
2019-06-03 16:04:01 -07:00
Mitch Phillips
44c29535cc Merge "Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'." 2019-05-30 22:24:06 +00:00
Mitch Phillips
dfde0eeee1 Change SANITIZE_TARGET refs from 'coverage' to 'fuzzer'.
Cleanup of references to 'coverage' in build files. Part of a larger
cleanup to make fuzzing work again in the Android build tree.

Also fixed a test issue with emulated TLS with the new changes, and
removed libc.so fuzzer support until a linked bug is fixed
(b/132640749).

Bug: 121042685
Test: With all patches in the bug merged: mmma bionic
Change-Id: I592352fe9210ff811a2660a88cbbfe48d70a1e57
Merged-In: I592352fe9210ff811a2660a88cbbfe48d70a1e57
2019-05-30 16:49:13 +00:00
Tom Cherry
6b116d1bbf Make 'app' users/groups more accurate
In an attempt to make bionic's reporting of users and groups more
accurate, this change makes the user / group functions do the
following:

1) Fail to query a uid/gid for a secondary user when the uid/gid
   doesn't exist.  Currently bionic would return successfully but with
   a empty string for the name.
2) Fail to query a platform uid/gid, except a limited pre-allocated
   set for a secondary user, as these are not used by second users.
3) Fail to query uids for all users for the GID-only app ranges:
   CACHE_GID, EXT_GID, EXT_CACHE_GID, SHARED_GID.
4) Fail to query gids in SHARED_GID range for secondary users, as
   these GIDs are only allocated for the first user.
5) Use "u#_a#_ext" and u#_a#_ext_cache" for EXT_GID and EXT_CACHE_GID
   ranges.  This both allows querying based on these names and
   returning these names for the appropriate uids/gids.

This also consolidates the tests for better readability.

Test: these unit tests, boot

Change-Id: I59a1af0792e7806d423439582e56ce7f9f801c94
2019-05-29 15:54:50 -07:00
Florian Mayer
9fc9509b52 Log when trying to profile non profilable app.
Change-Id: I91b489d3ff78ab7153ae1a7854ae448e87a6e8da
2019-05-29 10:31:17 +01:00
Ryan Prichard
fc5535074d Merge "Overalign the TLS segment using crtbegin" 2019-05-28 23:34:11 +00:00
Treehugger Robot
cfede4fdd1 Merge changes Ic2d48c93,I981ac9bd
* changes:
  fortify: s/([gl])eq/\1e/g
  fortify: more use of __builtin_constant_p
2019-05-24 06:48:27 +00:00
Christopher Ferris
497d7169d4 Merge "Disable malloc debug when asan enabled." 2019-05-24 05:44:56 +00:00
Treehugger Robot
30d4c6fb06 Merge "fortify: use __builtin_constant_p for more short-circuits" 2019-05-24 02:29:06 +00:00
George Burgess IV
a743f31981 Merge "fortify: Migrate trivial cases to dynamic check macros" 2019-05-24 00:43:26 +00:00
George Burgess IV
c03d5964d0 fortify: s/([gl])eq/\1e/g
Follow-up from review comments in
https://android-review.googlesource.com/c/platform/bionic/+/961600

Bug: 131861088
Test: mma
Change-Id: Ic2d48c935ced3c7e875923810f4e9970e7439e51
2019-05-23 15:22:01 -07:00
George Burgess IV
d9865e7734 fortify: more use of __builtin_constant_p
This converts all of stdio to short-circuit _chk functions in trivially
safe cases.

Bug: 131861088
Test: checkbuild on internal master. blueline bionic tests pass + it
      boots.
Change-Id: I981ac9bd19112492d5a47dc5277526426b9af710
2019-05-23 15:01:55 -07:00
George Burgess IV
a1a09b211e fortify: use __builtin_constant_p for more short-circuits
This also lets us retire our |__enable_if| version of |strlen|, which
should catch strictly fewer cases where we can fold the string's length
to a constant than |__builtin_constant_p| inside of |strlen|.

Bug: 131861088
Test: checkbuild on internal master. blueline bionic tests pass + it
      boots.
Change-Id: I21b750a24f7d1825591a88d12a385be03a0a7ca3
2019-05-23 15:01:54 -07:00
Ryan Prichard
cc9b100e97 Overalign the TLS segment using crtbegin
Android's current lld build has a hack that overaligns TLS segments, but
it broke glibc when it produced TLS segments where (p_vaddr % p_align) was
non-zero. Move the hack into Bionic's crtbegin instead. It will emit a
0-sized, 64-byte alignment TLS segment into executables that don't use
TLS, but that should be harmless.

This variant of the hack is compatible with the gold and lld linkers. The
ld.bfd linker will optimize the .tdata output section out if its size is
zero, preventing the overalignment in an executable that only has .tbss
sections. This problem could be fixed by adding a ". = .;" statement
inside .tdata in ld.bfd's linker script.

See discussion on https://reviews.llvm.org/D61824.

Bug: https://bugs.llvm.org/show_bug.cgi?id=41527
Test: bionic unit tests, boot a device
Change-Id: I34df8b5594b6518d4590e4861e3d0b74d6fa754e
2019-05-23 14:21:55 -07:00
Treehugger Robot
32e8d4fa71 Merge "fortify: inline #defined strings" 2019-05-23 21:17:31 +00:00
Treehugger Robot
b07c1973d1 Merge "fortify: use a macro in diagnose_if" 2019-05-23 21:17:22 +00:00
George Burgess IV
5da5dd5215 fortify: Migrate trivial cases to dynamic check macros
|__builtin_constant_p| has become more flexible in clang. In particular,
it's no longer forcibly lowered before inlining, so we can actually use
it on function parameters (or |__bos(param)|).

This CL tweaks things so that trivially safe calls to FORTIFY'ed
functions compile into direct calls to those functions, rather than to
their _chk counterparts. This will be the most impactful with things
like |memset|, |memcpy|, etc., since clang has way more flexibility
about how to lower those than it does with |__memset_chk|,
|__memcpy_chk|, ...

As noted in the comments, the spelling of the new macros is meant to
match closely with the spelling of our |__bos_static| macros used in
|diagnose_if|.

This isn't a full cleanup of all of the cases in which we can do this.
Just a start on the super simple cases.

Bug: 131861088
Test: m checkbuild; blueline boots.

Change-Id: I696f42ce4a65231e0c4a78a4c5133a6be1cb7708
2019-05-23 13:39:04 -07:00
George Burgess IV
ff7179350a fortify: inline #defined strings
These were originally #defined so we could share them between our
GCC and clang FORTIFY implementations. Since we no longer have a GCC
FORTIFY, #defining them is sort of pointless.

Bug: 131861088
Test: mma
Change-Id: I2ae4e0bdebbed16c946f5df7cc38c471881b481e
2019-05-23 13:38:09 -07:00
George Burgess IV
5273dc588a fortify: use a macro in diagnose_if
Our diagnose_if conditions are repetitive. It's potentially convenient
to hide that behind a macro. There's an upcoming refactor to our
run-time checks; having static checks look super similar is convenient,
and makes correctness (hopefully) slightly more obvious.

Bug: 131861088
Test: checkbuild on internal master.
Change-Id: Ic39a3b6bf020734c1bef6be144f61ef81466aafe
2019-05-23 13:38:09 -07:00
Pirama Arumuga Nainar
17e7c75265 Disable native_coverage for scudo-related libraries
Bug: http://b/133379274
Bug: http://b/133322197

Test: coverage-enabled mediaextractor, which uses scudo, no longer
crashes during llvm_gcov_init.

Change-Id: I85a0cc91a2fbd8433823769c3032ec2591424e55
2019-05-22 22:18:37 -07:00
Christopher Ferris
705de3c639 Disable malloc debug when asan enabled.
Bug: 123312263

Test: Verified with asan enabled, malloc debug does not initialize.
Test: Ran tests on non-asan build and verify they pass.
Change-Id: I3c37c170bf6c1de42740972f2113ae991351d931
2019-05-22 17:16:37 -07:00
Christopher Ferris
933bd3ae66 Merge "Update to kernel headers to v5.1.3." 2019-05-22 19:09:12 +00:00
Treehugger Robot
d277334059 Merge "Export some symbols for vendor libmemunreachable" 2019-05-21 22:51:26 +00:00
Treehugger Robot
e1276ba538 Merge "pwd/grp: fix pwd _r reentrancy, new tests, clean up" 2019-05-21 18:29:33 +00:00
Christopher Ferris
24f97eb27b Update to kernel headers to v5.1.3.
Test: Builds and boots taimen.
Test: Ran bionic unit tests.
Change-Id: Ieaca8709d568f075df8cac60c9da2c0ed1916963
2019-05-20 12:58:13 -07:00
Christopher Ferris
0c0f6fb293 Keep .debug_frame on arm 32.
The arm exidx unwind information can be sparse and clang is producing
functions that cannot be properly represented. The .debug_frame includes
extra unwind information that covers the cases that are not complete, so
do not remove it. For example, the __strchr_chk function has a push
in the middle of the function, so any crash before that instruction will
not unwind properly.

This does increase the size of libc.so, but only by about 80,000 bytes.

Bug: 132992102

Test: Verified the .debug_frame exists in libc.so only for arm32.
Test: Used the unwind_reg_info to verify that __str_chk gets proper
Test: unwind info. Also use unwind_reg_info on some assembler functions
Test: to make sure that there is no overlapping information.
Change-Id: If9a6de15b3adf08a93c4563da8c89846e4dd059b
2019-05-17 17:52:51 -07:00
Colin Cross
b9667b51a8 Export some symbols for vendor libmemunreachable
Add the malloc symbols used by libmemunreachable to the VNDK, and
make libc_malloc_debug_backtrace vendor_available.

Bug: 132302484
Test: m checkbuild
Change-Id: Ide555195afa084c13eaeaf0eab6ff90787b5f2d0
2019-05-17 14:26:31 -07:00
Jake Weinstein
bff53b2617 libc: import ARM strcmp from newlib
* Current version is also based on newlib, but an older revision

* The Krait and A9 specific changes no longer seem relevant, so
  let's use A15 directly.

Tested on OnePlus 3 (MSM8996):

Before (Krait strcmp):
                                       iterations      ns/op
BM_string_strcmp/8                          1000k         24    0.322 GiB/s
BM_string_strcmp/64                           20M        123    0.519 GiB/s
BM_string_strcmp/512                           2M        920    0.556 GiB/s
BM_string_strcmp/1024                       1000k       1818    0.563 GiB/s
BM_string_strcmp/8Ki                         200k      14405    0.569 GiB/s
BM_string_strcmp/16Ki                        100k      28762    0.570 GiB/s
BM_string_strcmp/32Ki                         50k      57526    0.570 GiB/s
BM_string_strcmp/64Ki                         10k     114959    0.570 GiB/s

After:
                                       iterations      ns/op
BM_string_strcmp/8                          1000k         28    0.284 GiB/s
BM_string_strcmp/64                           20M        107    0.596 GiB/s
BM_string_strcmp/512                           2M        800    0.639 GiB/s
BM_string_strcmp/1024                       1000k       1579    0.649 GiB/s
BM_string_strcmp/8Ki                         200k      12469    0.657 GiB/s
BM_string_strcmp/16Ki                        100k      24931    0.657 GiB/s
BM_string_strcmp/32Ki                         50k      49843    0.657 GiB/s
BM_string_strcmp/64Ki                         20k      99635    0.658 GiB/s

Test: bionic-benchmarks BM_string_memcmp
Change-Id: Icb3bfb0a381bcc1e10885ca5e9547842c3f620d7
2019-05-16 04:37:26 +00:00
Tom Cherry
c57c5bdb7f pwd/grp: fix pwd _r reentrancy, new tests, clean up
getpwnam_r() and getpwuid_r() clobber the storage used by getpwnam()
and getpwuid().  This isn't likely to be a big issue, but since we do
this right for the group functions, fix this as well as add a test.
Both use more space in buf than is actually required, but well below
their sysconf() suggested values, so we accept that to keep the code
concise.

Add tests for dealing with unaligned input buffers, particularly for
getgrnam_r() and getgrgid_r(), as they require alignment but this
wasn't being tested.

Refactor common initialization code for both passwd and group state
structs.

Remove extraneous null pointer checks; the values they were testing
were offsets of a previous pointer, so guaranteed to never actually be
null.  If the underlying pointer is actually null, we're beyond repair
anyway, so accept that we'll crash.

Test: pwd/grp unit tests

Change-Id: I60c4d00e9ab3cf55daf8314c5029fd914025b696
2019-05-15 15:49:34 -07:00
Josh Gao
93f79a1a5b Merge "Annotate no_return and returns_twice functions." 2019-05-15 20:26:46 +00:00
Josh Gao
3403315521 Annotate no_return and returns_twice functions.
When building the bionic tests, we use -fno-builtins, which turns off
clang's recognition of vfork as a magical function that can return
twice. Explicitly annotate our returns_twice functions to ensure that
we generate correct code even in -fno-builtins (and while we're at it,
annotate the no_return functions as well, so we generate faster code).

Bug: http://b/131856005
Test: treehugger
Change-Id: I465f8042a965f0c7c03caa5f17af67deea8f5d9d
2019-05-13 13:17:51 -07:00
Christopher Ferris
23c056dbcb Add removed platform functions used by apps.
Added get_malloc_leak_info and free_malloc_leak_info for arm 32 bit
only so that the kindle app will continue to run.

Bug: 132175052

Test: Ran kindle app, read pdf file. Verified libKindleReaderJNI.so
Test: is loaded in memory properly.
Change-Id: Ib1ea3a37b3729f9bcc2739c5f3a584ea8f66d200
Merged-In: Ib1ea3a37b3729f9bcc2739c5f3a584ea8f66d200
(cherry picked from commit 235f35a266)
2019-05-08 15:43:25 -07:00
Christopher Ferris
f15a00b1ec Merge "Avoid using malloc debug code after exit." 2019-05-07 22:28:50 +00:00
Christopher Ferris
d269fcc935 Avoid using malloc debug code after exit.
I wrote a new unit test that would fail on the old version of the
code.

On a walleye big cpu, this costs about 40ns-50ns (going from ~430ns to ~480ns).
I think this is an acceptable performance degradation.

Bug: 131867816

Test: New unit tests pass.
Change-Id: I4c0f4373fb0694bf29c3824dbb1224a8a17e211e
2019-05-07 13:16:58 -07:00
Elliott Hughes
31c7309dc6 Add SEEK_DATA and SEEK_HOLE constants.
Without pulling in <linux/fs.h>, the UAPI source of these constants,
because it's full of pollution, in particular a macro called BLOCK_SIZE
that breaks a lot of stuff.

Test: treehugger
Change-Id: I7258ec57e91c67645c2b4d0ce44850d757c4bb12
2019-05-07 10:03:02 -07:00
Dimitry Ivanov
78e42d81ec Merge "Enable native_bridge_support" 2019-05-07 11:30:58 +00:00
Florian Mayer
0633e569bc Merge "Match maximum command line size for startup tracing." 2019-05-07 10:34:05 +00:00
Ryan Prichard
f61ca22248 Merge "Revert fwalk/sfp locking to fix concurrent reads" 2019-05-06 23:38:49 +00:00
dimitry
7f04880820 Enable native_bridge_support
Enable native bridge support for bionic libraries.
Makes it possible to use them in binaries for translated
architectures.

Bug: http://b/77159578
Test: make
Change-Id: Iccd4ad7aecfa5260cc15f09ca975d2e18987278a
2019-05-06 17:13:51 +02: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
Florian Mayer
f6d221eeed Match maximum command line size for startup tracing.
Fix too small buffer for the startup property not accounting for the
prefix.

Bug: 131893397

Change-Id: Iad2398bc09c61b1144430bcbef58e5a832b85b0a
2019-05-03 17:37:47 +01: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
1eb6d36ba8 Merge "Make purging clear the current thread cache too." 2019-05-01 22:22:46 +00:00
Christopher Ferris
0f710fd593 Make purging clear the current thread cache too.
Bug: 131362671

Test: Ran bionic unit tests.
Test: Wrote a test that did a purge and verified that the tcache->ncached
Test: number went from 3 to 0. Also verified that mallinfo reflects the
Test: cached entries being flushed.
Change-Id: I64e35618fa3b523cf29bdaceedef676abe440dd3
2019-05-01 13:26:46 -07:00
Elliott Hughes
4fa9b8cd2e malloc.h: explicitly suggest malloc_info() instead of mallinfo().
I've also sent a patch to the man7.org man page.

Change-Id: I715eacf129abe61562c6d79c4eda03bab31f9c77
2019-04-30 12:44:03 -07:00
Tom Cherry
0cd818a377 Merge "Allow device launched before Q to use legacy OEM AID value" 2019-04-29 15:25:25 +00:00
Neil Fuller
f5eaea32b6 Merge "Move /system dependency on tz_version to bionic" 2019-04-29 12:59:32 +00:00
Ryan Prichard
34bf6107b6 Merge "__cxa_finalize: skip fflush call on dlclose" 2019-04-26 21:51:05 +00:00
Nick Kralevich
560de5f5c7 Don't honor LIBC_HOOKS_ENABLE across a security boundary
Similar to the way we handle LIBC_DEBUG_MALLOC_OPTIONS
(bug 68003719), filter LIBC_HOOKS_ENABLE when we cross a
security boundary. This prevents modifying the allocation
behavior of a privileged program.

Introduced in
db478a6274%5E%21/#F0
(bug 30561479)

Test: compiles and boots
Change-Id: I59a7c224734b0991fd62efb45ab599dab8570723
2019-04-26 12:58:00 -07:00
Nick Kralevich
99cec1892d Don't honor LD_CONFIG_FILE across security transitions
For security reasons, when a binary is executed which causes a security
transition (eg, a setuid binary, setgid binary, filesystem capabilities,
or SELinux domain transition), the AT_SECURE flag is set. This causes
certain blacklisted environment variables to be stripped before the
process is executed. The list of blacklisted environment variables is
stored in UNSAFE_VARIABLE_NAMES. Generally speaking, most environment
variables used internally by libc show up in this list.

Commit 02586a2a34 ("linker: the
global group is added to all built-in namespaces", Aug 2017) added
support for the environment variable LD_CONFIG_FILE. This debug build
only feature allows the caller to specify the path to the loader
configuration file. Like other linker environment variables, setting
this variable allows the calling process to control executed code of the
called process, which has security implications (on debuggable builds
only).

Add LD_CONFIG_FILE to UNSAFE_VARIABLE_NAMES. This has the effect of
stripping, on all build types, the LD_CONFIG_FILE environment variable.
This has three advantages:

1) Prevents security bugs should LD_CONFIG_FILE ever be inadvertantly
exposed on a production build.
2) Makes the behavior of userdebug and user builds more similar, helping
prevent build-type dependent bugs where someone may come to rely on this
debug-only feature.
3) Protect droidfood users against malicious applications which can
trigger a security transition, eg, the execution of crash_dump or the
renderscript compiler.

Alternative considered but rejected:

If we treated LD_CONFIG_FILE like LD_PRELOAD, we could expose this on
all build types, and remove the build-type dependent behavior. But this
is contrary to enh's Aug 02 2017 guidance at
https://android-review.googlesource.com/c/platform/bionic/+/449956

  i'm still uncomfortable about LD_CONFIG_FILE because i'd like
  to be reducing the number of environment variables that affect
  the linker in P rather than increasing them.

Test: atest CtsBionicTestCases
Test: atest linker-unit-tests
Change-Id: I82d286546ee079b5cde04428dc89941c253c2d20
2019-04-26 12:08:54 -07:00
Ryan Prichard
c5d8c6c6e4 __cxa_finalize: skip fflush call on dlclose
In __cxa_finalize, only call fflush(NULL) when the program is exiting, not
when a library is unloaded with dlclose. This change restores behavior
from 2015.

Flushing output is needed when the program exits, but flushing everything
is hazardous at other times because it can block -- fflush(NULL) locks
every file, so it also blocks on read operations.

Bug: http://b/130655235
Test: manual
Change-Id: I2f5ecffa6724bfd98a93d145ab5313c793c01ae6
2019-04-25 16:38:31 -07:00
Tom Cherry
b368a0b2e4 Allow device launched before Q to use legacy OEM AID value
Devices launched before Q may be using OEM defined AID that are not in
the OEM_RESERVED ranges. Those devices should be allowed to keep using
legacy oem AID values given it may not be possible to upgrade the
userdata and persist files through OTA.

Bug: 131095318
Test: bionic-unit-tests

Change-Id: I73fc0c452420be5287adcacb36a1e772acc9bb3e
2019-04-25 09:26:48 -07:00
dimitry
c7b81108b4 Make pthread_get/setschedparam weak for native bridge
Bug: http://b/130825973
Test: run affected app on cuttlefish
Change-Id: I776f26f5eaebdfdb1256ff621bd05ef5a90b852a
2019-04-25 16:43:24 +02:00
Neil Fuller
a7db90f32d Move /system dependency on tz_version to bionic
Move /system dependency on tz_version to bionic from core-libart.

The file is not used by code but is useful on device to identify
the format / version / origin of the tzdata file. The
tz_version file identifies the Android release (e.g. 3.1 == Q), which
implies the version of zic used to generate tzdata, and any Android
revision of the tzdata (e.g. 2019a v2) that may have taken place. The
file was previously used by by the tzdatacheck binary but it has since
switched to using the copy in the runtime module.

The bionic README.md is also updated here to reflect latest locations of
scripts.

Bug: 131239046
Test: make installclean / make droid / inspect /system
Change-Id: Ib142f98aa30c8c9d5eda33df55d4191478570ced
2019-04-25 09:35:58 +01:00
Tom Cherry
731ed0fb52 Merge "Refactor some pieces of grp_pwd.cpp" 2019-04-24 23:02:06 +00:00
Tom Cherry
5fb07634c3 Refactor some pieces of grp_pwd.cpp
We loop through android_ids in many functions, but this can be
consolidated into find functions.

Test: bionic-unit-tests
Change-Id: I70c423affe49090a93e999c72bb4c84a068de5d8
2019-04-24 13:37:11 -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
Christopher Ferris
31fe3c637e Merge "Move all leak info functions to android_mallopt." 2019-04-23 17:45:01 +00:00
Yi Kong
7f3527fb5c Merge "Implement __gnu_[u]ldivmod_helper methods in libc" 2019-04-23 05:54:33 +00:00
Yi Kong
b410d0e69e Implement __gnu_[u]ldivmod_helper methods in libc
These symbols were previously provided by Android's out-dated libgcc,
but they're removed/deprecated in upstream libgcc, and also won't be
available in libclang_rt.builtins. We need to provide these methods in
libc itself for compatiblity.

Test: build with these symbols stripped in libgcc
Bug: 29275768
Change-Id: I04a05258c6c06b5a22ead41e148b02792ffbc941
2019-04-22 18:12:55 -07:00
Elliott Hughes
1311545bb2 Merge "Reland ifuncs for strcmp and strlen." 2019-04-22 23:32:33 +00:00
Ryan Prichard
b250766282 Merge "PIMutexUnlock: load owner_tid in non-common case" 2019-04-22 21:09:52 +00:00
Ryan Prichard
f32e1a1f50 Merge "Comment about lock destruction and unlocking" 2019-04-22 21:09:44 +00:00
Elliott Hughes
927fe99692 Reland ifuncs for strcmp and strlen.
This reverts commit e4788d4c7e,
which undid this change during the Q betas.

Bug: http://b/120989619
Change-Id: Iea589fd0e56426971adf9f7c19c2aedf0d7a7a60
2019-04-22 18:57:21 +00:00
Elliott Hughes
493322baf1 Merge "Move libdl and linker to static NOTICE files." 2019-04-22 15:33:05 +00:00
Elliott Hughes
390be50067 Workaround ASan not knowing about reallocarray.
Ensure we call realloc@plt rather than (as was previously happening)
inlining realloc into reallocarray, which makes the allocation invisible
to ASan.

Bug: http://b/129989984
Test: objdump
Change-Id: If8a43cba11aa5a2f2f62bacd02ef6ef4032e0dbb
2019-04-20 22:18:49 -07:00
Ryan Prichard
aca110173f Comment about lock destruction and unlocking
Add a couple of comments explaining that a mutex can be freed during
the unlock call, immediately after the unlock's atomic exchange call but
before its futex wakeup call.

Bug: http://b/129744706
Test: bionic unit tests
Change-Id: I2d290ebde880f46866098d022720896039e7022e
2019-04-19 17:16:25 -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
Elliott Hughes
584bc626b6 Move libdl and linker to static NOTICE files.
The libstdc++ directory has no copyright headers, so it was a no-op
anyway.

The interesting part will be switching libc and libm over to genrules...

Test: N/A
Change-Id: Iec92562af40c451fdcb4a7468984878ec5dba2ce
2019-04-19 14:18:07 -07:00
Christopher Ferris
30659fd243 Move all leak info functions to android_mallopt.
Bug: 130028357

Test: malloc_hooks unit tests.
Test: Enable backtrace for mediaserver, run dumpsys media.player -m
Test: Enable backtrace for calendar, run am dumpheap -n <PID> <FILE>
Change-Id: I6774e28ccd9b3f2310127a5b39ccd15fe696a787
Merged-In: I6774e28ccd9b3f2310127a5b39ccd15fe696a787
(cherry picked from commit 3aadc5e80a)
2019-04-19 11:27:02 -07:00
Tom Cherry
75f7b06454 Merge "paths.h: /sbin and /system/sbin no longer exist." 2019-04-17 23:26:13 +00:00
Christopher Ferris
30bcaae2b6 Merge "Remove gMallocLeakZygoteChild." 2019-04-17 17:31:04 +00:00