Commit graph

27663 commits

Author SHA1 Message Date
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
b8ef55a4f8 Merge "Make aligned_alloc match the standard." 2019-03-02 19:11:22 +00: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
Treehugger Robot
0771b752f1 Merge "Workaround string-plus-int warning" 2019-03-01 02:21:16 +00:00
Nick Kralevich
36501ba189 Merge "Ensure STDIN/STDOUT/STDERR always exist" 2019-03-01 00:46:47 +00:00
Yi Kong
4ca9a6b576 Workaround string-plus-int warning
The upcoming compiler warns against adding string and int:
In file included from bionic/libc/bionic/strsignal.cpp:41:
  bionic/libc/private/bionic_sigdefs.h:58:1: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int]
  __BIONIC_SIGDEF(SIGWINCH,  "Window size changed")
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  bionic/libc/bionic/strsignal.cpp:40:83: note: expanded from macro '__BIONIC_SIGDEF'
  #define __BIONIC_SIGDEF(signal_number, unused) [ signal_number ] = #signal_number + 3,
                                                                     ~~~~~~~~~~~~~~~^~~

Use array indexing index to avoid this warning.

Test: m checkbuild
Change-Id: Ib5e20edbf5bac76352df0484dd233d0621beb4e9
2019-02-28 15:54:58 -08:00
Nick Kralevich
7fa3b47813 Ensure STDIN/STDOUT/STDERR always exist
File descriptor confusion can result if a process is exec()d and
STDIN/STDOUT/STDERR do not exist. In those situations, the first,
second, and third files opened by the exec()d application will have FD
0, 1, and 2 respectively. Code which reads / writes to these STD* file
descriptors may end up reading / writing to unintended files.

To prevent this, guarantee that FDs 0, 1, and 2 always exist. Bionic
only currently guarantees this for AT_SECURE programs (eg, a setuid
binary, setgid binary, filesystem capabilities, or SELinux domain
transition).

Extending this to all exec()s adds robustness against this class of
bugs. Additionally, it allows a caller to do:

  close(STDIN_FILENO);
  close(STDOUT_FILENO);
  close(STDERR_FILENO);

and know that the exec()d process will reopen these file descriptors on
its own. This has the potential to simplify other parts of Android, eg
https://android-review.googlesource.com/c/platform/system/apex/+/915694

Steps to reproduce:

  sleep 100 <&- >&- 2>&- & BGPID=$! && ls -la /proc/$BGPID/fd && kill $BGPID

Expected:

  $ sleep 100 <&- >&- 2>&- & BGPID=$! && ls -la /proc/$BGPID/fd && kill $BGPID
  [1] 3154
  total 0
  dr-x------ 2 shell shell  0 1970-04-17 12:15 .
  dr-xr-xr-x 9 shell shell  0 1970-04-17 12:15 ..
  lrwx------ 1 shell shell 64 1970-04-17 12:15 0 -> /dev/null
  lrwx------ 1 shell shell 64 1970-04-17 12:15 1 -> /dev/null
  lrwx------ 1 shell shell 64 1970-04-17 12:15 2 -> /dev/null
  $
  [1] + Terminated           \sleep 100 <&- >&- 2>&-

Actual:

  $ sleep 100 <&- >&- 2>&- & BGPID=$! && ls -la /proc/$BGPID/fd && kill $BGPID
  [1] 16345
  total 0
  dr-x------ 2 shell shell 0 2019-02-28 20:22 .
  dr-xr-xr-x 9 shell shell 0 2019-02-28 20:22 ..
  $
  [1] + Terminated           \sleep 100 <&- >&- 2>&-

Test: manual (see above)
Change-Id: I3e05700a1e8ebc7fc9d192211dd9fc030cc40139
2019-02-28 13:06:07 -08:00
Elliott Hughes
6b65e07809 Merge "Log when malloc functions fail." 2019-02-27 01:37:35 +00:00
Elliott Hughes
a21f6cca06 Log when malloc functions fail.
This shouldn't happen often, and resulting failures can be hard to debug.

From the bionic unit tests now:

  W libc    : malloc(18446744073709551615) failed: returning null pointer
  W libc    : calloc(18446744073709551615, 100) failed: returning null pointer
  W libc    : calloc(1, 18446744073709551615) failed: returning null pointer
  W libc    : calloc(18446744073709551615, 18446744073709551615) failed: returning null pointer
  W libc    : calloc(2, 18446744073709551615) failed: returning null pointer
  W libc    : calloc(18446744073709551615, 2) failed: returning null pointer
  W libc    : memalign(4096, 18446744073709551615) failed: returning null pointer
  W libc    : realloc(0x0, 18446744073709551615) failed: returning null pointer
  W libc    : realloc(0x75d7526070, 18446744073709551615) failed: returning null pointer
  W libc    : reallocaray(0x0, 9223372036854775812, 2) failed: returning null pointer
  W libc    : reallocaray(0x0, 2, 9223372036854775812) failed: returning null pointer

Bug: http://b/12821450
Test: ran tests
Change-Id: Ib176814404f4ba1297416dd3e1edd721bf59aeed
2019-02-26 12:22:38 -08:00
Yi Kong
e65558a0a4 Merge changes I070d3a26,Ie9176587
* changes:
  Turn on XOM for libm
  Switch libm to libcrt.builtins
2019-02-23 02:16:08 +00:00
Christopher Ferris
68e4f49c06 Merge "Fix wrong variable reference." 2019-02-23 01:38:27 +00:00
Yi Kong
1ac113dc6b Turn on XOM for libm
Test: bionic-unit-tests
Bug: 122993571
Bug: 123241361
Change-Id: I070d3a2627ee64124ff415a646ddfbcc767b54d1
2019-02-22 14:03:15 -08:00
Yi Kong
e3d90de50b Switch libm to libcrt.builtins
After switching libm from libgcc to libcrt.builtins, some of the symbols
are no longer getting included in libm, causing the compiler to complain
about missing symbols from the version script. Explicitly export them in
libc (since libm depends on libc).

Bug: 122993571
Test: m checkbuild
Test: bionic-unit-tests
Change-Id: Ie91765874d20df605f557b1a8c4236619553c549
2019-02-22 13:33:15 -08:00
Christopher Ferris
503c17bae7 Fix wrong variable reference.
Bug: 125891203

Test: Verify that setting the program property to "" doesn't trigger
Test: heapprofd.
Change-Id: Id27cbb92c7a120d02151e29be993f369230c2de8
2019-02-22 12:47:23 -08:00
Treehugger Robot
58239d0020 Merge "Revert "Revert "Turn on XOM for libc""" 2019-02-22 20:46:27 +00:00
Jeffrey Vander Stoep
dced8138d8 Revert "Revert "Turn on XOM for libc""
This reverts commit d119269c1c.

Reason for revert: b/124792601 fixed

Change-Id: I8603231042b0e70772fc174f5493db4ef0587323
Test: bionic-unit-tests
Bug: 122993569
Bug: 123241361
2019-02-21 23:13:52 +00:00
Dan Albert
5e15f34c50 Merge "Make static ifunc resolvers optional." 2019-02-21 21:14:09 +00: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
Dan Albert
a535d3ca65 Make static ifunc resolvers optional.
Gold isn't emitting these symbols, so we don't necessarily have the
support for them (gold is still the default for most architectures in
the NDK).

Test: bionic static unit tests
Bug: None
Change-Id: Ifc360cb6c26571fb3f0309adb0faf0af7ee5b36f
2019-02-20 12:44:19 -08:00
Treehugger Robot
b656d4a1da Merge "Revert "Turn on XOM for libc"" 2019-02-20 17:02:39 +00:00
Treehugger Robot
c46cc7d83d Merge "Waive AID Range check for devices through Q" 2019-02-20 10:42:56 +00:00
Yi Kong
d119269c1c Revert "Turn on XOM for libc"
This reverts commit 51b8255cf5.

Breaks app compat.

Bug: 124792601
Change-Id: I99690d0092066fdfd76dc68aa3ed0fe0df873892
2019-02-20 10:27:38 +00:00
Treehugger Robot
4284fe96f6 Merge "Mark lib_async_safe_headers as supporting linux_bionic" 2019-02-20 06:17:01 +00: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
Elliott Hughes
11dff3e91c Merge "Add TEST_MAPPING." 2019-02-19 18:00:37 +00:00
Alex Light
7448f3e5dd Mark lib_async_safe_headers as supporting linux_bionic
This target is needed by linux_bionic targets and so should support
it.

Test: ./art/tools/build_linux_bionic.sh com.android.runtime.host
Change-Id: Ib12f1cf1d70e606b0921f507b3e460f5d543017e
2019-02-19 09:47:40 -08:00
vichang
54c864052b Merge "Redirect /system/lib/libicuuc.so regardless of duplication in /system" 2019-02-19 10:14:31 +00:00
Elliott Hughes
f05dd837cb Add TEST_MAPPING.
Test: treehugger
Change-Id: I28eced257260028553bb0dc02a9d99bcbf266378
2019-02-16 09:06:57 -08:00
Treehugger Robot
a60488109c Merge "Fix: symbols/bionic/lib64/libc.so is the wrong variant" 2019-02-16 01:51:11 +00:00
Elliott Hughes
d102cf62d1 Merge "Switch linker tests to Android.bp." 2019-02-16 01:11:56 +00:00
Elliott Hughes
f84d0a95bd Merge "libasync_safe: stop clobbering other folks' identifiers." 2019-02-16 00:12:51 +00:00
Yi Kong
f60449c21c Merge changes Ibce7bd9d,Ieab5af35
* changes:
  Turn on XOM for libc
  Switch libc to libcrt.builtins
2019-02-15 23:58:10 +00:00
Treehugger Robot
f4533e6956 Merge "Remove unused .mk file." 2019-02-15 23:42:46 +00:00
Treehugger Robot
cf6cec8489 Merge "bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile" 2019-02-15 23:03:00 +00:00
Elliott Hughes
15a2b7b17b Switch linker tests to Android.bp.
Life is easier if we just keep test code in the same directory as the
stuff it's testing...

Test: tests still build and pass
Change-Id: I9b35d689098bdc28a71d69645b0ca9fdd6ea0108
2019-02-15 14:40:08 -08:00
Elliott Hughes
2ae246d0d1 Remove unused .mk file.
Test: treehugger
Change-Id: I5e560247e466dd2fe0038e787756f5a47461f240
2019-02-15 13:24:09 -08:00
Yi Kong
51b8255cf5 Turn on XOM for libc
Test: bionic-unit-tests
Bug: 122993569
Bug: 123241361
Change-Id: Ibce7bd9dc45c39a27fee33fd0566483dd8427cce
2019-02-15 12:48:26 -08:00
Yi Kong
165b1cf57b Switch libc to libcrt.builtins
With the switch to libcrt.builtins, some symbols no longer becomes
exported. Add dummy references to them to force them to be exported.
This is to maintain backwards binary compatibility with ancient Android
versions.

x86 and x86_64 crashes with libcrt, keep using libgcc for now.

Test: bionic-unit-tests
Bug: 29275768
Bug: 122993569
Change-Id: Ieab5af354e3924af4a03d888b28c6e75090cb613
2019-02-15 12:46:19 -08:00
Pirama Arumuga Nainar
a192c50e5a Merge "Clarify reason for native_coverage being off for libdl" 2019-02-15 19:52:26 +00:00
Pirama Arumuga Nainar
eeb2ee65f7 Clarify reason for native_coverage being off for libdl
Bug: http://b/124067925

It's off because it doesn't link with any system_shared_libs.

Test: N/A
Change-Id: I293fb9ba8df213f8f6bbec85135a974e5966f0cc
2019-02-15 11:40:40 -08:00
Treehugger Robot
be9b7240c2 Merge "Remove removed functions from symbol_ordering." 2019-02-15 08:11:50 +00:00
Christopher Ferris
7ae03335fc Merge "malloc debug: fix LogFreeError error log" 2019-02-15 06:52:07 +00:00
Jiyong Park
88d03200d4 Fix: symbols/bionic/lib64/libc.so is the wrong variant
The new module type bionic_mountpoint wasn't mutated by the sanitizer.
As a result, it has been taking non-sanitized symbol libraries even for
sanitized builds. Fixing the issue by making the module type to
implement the cc.Sanitizeable interface so that it can be mutated by the
sanitizer.

Bug: 124469750
Test: SANITIZE_TARGET=hwaddress m
Inspect Android-<target>.mk and check that LOCAL_SOONG_UNSTRIPPED_BINARY
for libc.mountpoint module is pointing to a hwasan variant of libc.so

Change-Id: I10c863c0dbd361463648a4b7d897a4f88a9c85cb
2019-02-15 12:15:27 +09:00
Treehugger Robot
4788931135 Merge "Disable native_coverage for ld-android and linker" 2019-02-15 02:17:45 +00:00
Christopher Ferris
6cf828c310 Merge "Avoid heapprofd init when other hooks enabled." 2019-02-15 01:43:19 +00:00
Iris Chang
b34415046c malloc debug: fix LogFreeError error log
When free_track option is enabled and malloc debug detects error in
VerifyFreedPointer flow, if freed pointer's usable_size is more than
g_debug->config().fill_on_free_bytes(), the error log is not correct.

The max. bytes printed to error message should be the max bytes to
cmp, not usable size.

Bug: 124420174
Test: build pass and test pass
Change-Id: I41f35ab3330e49e0a6ad276d405bf4f6c3f0ea92
2019-02-14 17:15:03 -08:00
Dan Albert
30a0bf0aec Remove removed functions from symbol_ordering.
Test: treehugger
Bug: None
Change-Id: Id398f8d5b3d8a6f9acc25cf222ba8c963e4a6341
2019-02-14 14:52:41 -08:00
Elliott Hughes
3019d78d4a libasync_safe: stop clobbering other folks' identifiers.
The log priorities and ids are in an NDK header, available to everyone.

Move CHECK into its own header for now. This would be better if it was
more like the <android-base/logging.h> CHECK family, but I don't have an
easy way to do that without lots of copy & paste, so punting for now.

Bug: https://issuetracker.google.com/issues/119713191
Test: boots
Change-Id: I4566be8a0a024fede0e2d257c98b908ec67af2a8
2019-02-14 14:23:13 -08:00