Commit graph

27643 commits

Author SHA1 Message Date
Adrian-CJ Hung
8c1a14d4f3 Workaround potential access to unmapped stack
Issue:
Process is crashed near the end (startup_handshake_lock.unlock()) in
pthread_create().

The newly created child thread passes this handshake_lock unexpectedly
=> its stack is unmapped & its associated pthread_internal_t data
structure can’t be accessed.

Analysis:
The created child thread should be blocked by startup_handshake_lock.lock()
and enter __futex_wait_ex()

But if the parent thread is in the middle of startup_handshake_lock.unlock():

  void unlock() {
    if (atomic_exchange_explicit(&state, Unlocked, memory_order_seq_cst) == LockedWithWaiter) {  // => the state is modified to Unlocked

    // (a) if the child thread is back to running and pass the while() check in Lock::lock()
    // (b) the child thread executes its start_routine and then pthread_exit
    // (c) the stack of the child thread (where its pthread_internal_t (so the startup_handshake_lock) is located) will be unmapped

     __futex_wake_ex(&state, process_shared, 1);   // => when the parent thread is back to running
                                                   // the “state” & “process_shared” of startup_handshake_lock can’t be accessed (unmapped)
                                                   // so the process will be crashed
    }
  }

Bug: 129744706
Test: Monkey
Change-Id: I55175e8c7ebc2b3b52de8a5602def0667076b974
2019-04-03 11:50:33 +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
Pirama Arumuga Nainar
fcd35380dd Disable native_coverage for ld-android and linker
Bug: http://b/116873221

The coverage library, which depends on libc, cannot link with libraries
since they opt of libc.

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=bionic
Change-Id: Iaaca8bc30c8ba59e5d4f7092b1a0fce8e8c14c72
2019-02-14 13:50:55 -08:00
Christopher Ferris
2822856e98 Avoid heapprofd init when other hooks enabled.
All of the heapprofd code assumes that it's the only hook that
has been enabled. Enforce that by disallowing heapprofd from
enabling if malloc debug or malloc hooks have been enabled.

Test: Ran all unit tests (bionic/malloc hooks/malloc debug/perfetto).
Test: Enabled malloc debug ran perfetto integration tests and verified
Test: that an error message goes to the log.
Change-Id: I506fbf1c5b8e4052855531fa0d161f5de06e6c1a
2019-02-14 10:23:58 -08:00
Treehugger Robot
1b82812635 Merge "Fix hwasan build." 2019-02-14 08:04:46 +00:00
Christopher Ferris
883144719a Fix hwasan build.
Test: hwasan builds properly.
Change-Id: I3c911da08d1925b797423671e3beb72770a934b0
2019-02-13 22:15:28 -08:00
Treehugger Robot
1462d267e2 Merge "Symbols files under $(OUT)/symbols/bionic/" 2019-02-14 05:27:44 +00:00
Pirama Arumuga Nainar
bd912d2868 Merge "Disable native_coverage for libdl" 2019-02-14 00:05:57 +00:00
Treehugger Robot
b5c1b12389 Merge "Sync with upstream NetBSD." 2019-02-14 00:04:20 +00:00
Elliott Hughes
4fc93ffa62 Sync with upstream NetBSD.
Bug: http://b/123359356
Test: treehugger
Change-Id: Ide95d7eeb24cc0e22914162be423f8bacfdd3548
2019-02-13 14:17:18 -08:00
Treehugger Robot
0197b0a92f Merge "Use no_libcrt property instead of hard coding projects to exclude" 2019-02-13 21:53:26 +00:00
Christopher Ferris
c2136b51aa Merge "Refactor malloc common into distinct pieces." 2019-02-13 18:38:22 +00:00
Victor Chang
af12c94e79 Redirect /system/lib/libicuuc.so regardless of duplication in /system
The change is a workaround of app compat issue until the app fixes the
issue.

Likely, the app does not only dlopen(), but open() the libicuuc.so
with the absolute path.

Note that platform uses the stub libandroidicu.so, not libicuuc directly.
This CL topic moves (not duplicates) libandroidicu from /system to
/apex. Even though /system/lib/libicuuc.so is kept in the default
namespace, but no one should be using it.

Some debug info after this CL:
$ adb shell cat /proc/<zygote pid>/maps | grep libicuuc
$ adb shell cat /proc/<app pid>/maps | grep libicuuc
Only /apex/com.android.runtime/lib64/libicuuc.so is found, not the
/system.

Bug: 124218500
Test: The app can be launched successfully
Test: CtsJniTestCases
Change-Id: I67a50f0ad934be567a63d4038215546c9b4e5f7e
2019-02-13 15:31:06 +00:00
Ryan Prichard
40f18976db Merge "Only test tprel_missing_weak in dynamic binaries" 2019-02-13 00:26:51 +00:00
Christopher Ferris
e4cdbc4754 Refactor malloc common into distinct pieces.
The pieces:
- The malloc common shared by static and dynamic code (malloc_common.cpp).
- The code for shared libraries that includes any dlopen'ing
  (malloc_common_dynamic.cpp).
- The implementation of perfetto's heapprofd (malloc_heapprofd.cpp).

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

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

Test: Ran tests (malloc hooks/malloc debug/perfetto/bionic unit tests).
Change-Id: I0893bfbc0f83d82506fac5d1f37cf92fbdef6f59
2019-02-12 14:19:07 -08:00
Yi Kong
16f947281f Use no_libcrt property instead of hard coding projects to exclude
Test: m checkbuild
Change-Id: If34c72d37dc4077ca3e83135391256bc53d295b5
2019-02-12 09:49:23 -08:00
Elliott Hughes
c682e3b6e5 Merge "Greylist libraries are attempted to be loaded in the default ns" 2019-02-12 16:48:13 +00:00
Jiyong Park
efc503d677 Greylist libraries are attempted to be loaded in the default ns
Some of the greylist libraries can be in directories other than
/system/lib. For example, libnativehelper.so is moved from the directory
to /apex/com.android.runtime/lib.

Previous behavior for greylist libraries is to find the lib under
/system/lib while "within" the current namespace which is usually the
classloader-namespace. Since the libs no longer exist there, linker
fails to load it and no further attempt is made.

This change fixes the problem by loading the greylist libs "from" the
default namespace. Since there is a link from the default namespace to
the namespace where the moved libraries are intended to be loaded (e.g.,
the 'runtime' namespace for libnativehelper.so), the call is successful.

Bug: 124201397
Test: bionic-unit-tests

Change-Id: I11d15993d18896bdf663c408f9e40d8a607c9b80
2019-02-12 23:07:08 +09:00
Ryan Prichard
7fda2c9495 Only test tprel_missing_weak in dynamic binaries
Rename a test to be less confusing when this file tests unresolved weaks
with both TPREL and TLSDESC relocations.

Bug: http://b/123635978
Test: bionic unit tests
Change-Id: Id17d76a41159d134d16e84a699cc284662eb99bb
2019-02-11 18:37:17 -08:00
Jiyong Park
acb4d21a2a Symbols files under $(OUT)/symbols/bionic/
We need symbol files for /bionic/* paths.

New property "mountsource" is added to specify the "real" module that
the bionic mountpoint module is a mountpoint for. The real module
provides path to the unstripped elf file, which is installed to the
symbols/bionic/* path.

Bug: 123985838
Test: m libc.mountpoint libm.mountpoint libdl.mountpoint
linker.mountpoint
$(OUT)/symbols/bionic/bin/linker, bionic/lib[64]/lib{c|dl|m}.so exist

Change-Id: I43f074f0076b576f214fe92a98689a413efd3daa
2019-02-11 16:05:48 +09:00
Sandeep Patil
7d2aea09dd bionic/malloc_iterate_test: Adjust callback for procinfo::ReadMapFile
Bug: 123532375
Test: Builds

Change-Id: I8e782d9050b4d6a0726e8c880d4064df99c763e5
Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-02-10 17:27:39 -08:00
Ryan Prichard
808d176e7e Merge "Fix linker self-exec detection" 2019-02-08 22:33:11 +00:00