Commit graph

26030 commits

Author SHA1 Message Date
Jeremy Compostella
592bf711fd Revert "Add 64-bit slm optimized strlcpy and srlcat."
This reverts commit 2e7145c048.

When src is at the end page, the sse2 strlcpy SSE2 optimized version
can issue a movdqu instruction that can cross the page boundary.  If
the next page is not allocated to that process, it leads to
segmentation fault.  This is a rare but has be caught multiple times
during robustness testing.

We isolated a way to reproduce that issue outside of an Android device
and we have been able to resolve this particular case.  However, we
ran some additional compliance and robustness tests and found several
other similar page crossing issues with this implementation.

In conclusion, this optimization needs to be re-written from scratch
because its design is at cause.  In the meantime, it is better to
remove it.

Bug: http://b/78355649
Change-Id:  If90450de430ba9b7cd9282a422783beabd701f3d
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>

(cherry picked from commit 611ad621c6)
2018-04-20 17:33:12 -07:00
Evgeny Eltsin
4c9504aa6c Add __libc_add_main_thread and mark it weak
This complements __libc_init_main_thread in setting up main thread
under native bridge.

Test: run_tests
Bug: 77877742
Change-Id: I53efab66f285a1b9f0ab36d44386fa1e2621e4ba
2018-04-19 18:39:48 +02:00
Andreas Gampe
9302cf2526 Bionic: Always use fortified versions of FD_X macros
When compiling on/for at least Lollipop, always use the fortified
versions of FD_X macros. This works around side-effect issues (which
are explicitly called out in the specification) and generally
increases robustness of code.

(cherry picked from commit 00a6d5fe0a)

Bug: 77986327
Test: mmma bionic
Test: m
Test: bionic_unit_tests
Merged-In: I9096c6872770e46ba5ab64e7375ff83fc0518e07
Change-Id: I9096c6872770e46ba5ab64e7375ff83fc0518e07
2018-04-16 11:06:27 -07:00
Ryan Prichard
5a0fe3e8bf spawn.signal_stress: reap spawned children on exit
Test: adb shell \
  /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static \
  --gtest_filter=spawn.signal_stress
Bug: b/77824306
Change-Id: I970d1a4d0f8ac9621e676f32f838fc2f638d9750
(cherry picked from commit 344969c849)
2018-04-10 14:42:46 -07:00
TreeHugger Robot
45cd095f9d Merge "Do not check user/group names in pwd/grp tests for OEM uid/gids" into pi-dev 2018-04-05 18:49:21 +00:00
Tom Cherry
4b30f14b33 Do not check user/group names in pwd/grp tests for OEM uid/gids
Vendors that use config.fs will have their own uniquely named
user/group names for uids/gids that fall in the OEM ranges.  We
continue to allow lookup via oem_## for these values, however the
returned structs will always include the name from config.fs, so we do
not check it for anything in the tests.

Bug: 77549259
Test: bionic unit tests with uid 5000 as AID_CRAS
Merged-In: I27fc1fdd0e22063fea82b4c9d2a6fb8b865c5d7b
Change-Id: I27fc1fdd0e22063fea82b4c9d2a6fb8b865c5d7b
(cherry picked from commit b4c25c882e)
2018-04-05 09:52:40 -07:00
Luis Hector Chavez
51b867612e Make sys_ptrace_test.cpp Yama LSM-aware
This change enables the tracer process to be able to call ptrace(2) on
the worker process, which is does not have a direct-ancestor dependency.

Bug: 77146512
Test: adb shell \
      /data/nativetest{,64}/bionic-unit-tests{,-static}/bionic-unit-tests-{,-static} \
      --gtest_filter='spawn*'  # aosp_sailfish and Chrome OS
Test: cts-tradefed run singleCommand cts --skip-preconditions \
      -m CtsBionicTestCases --test 'PtraceResumptionTest*'  # aosp_sailfish
                                                            # and Chrome OS
Change-Id: I9e41b3ddde64c0623ba9299cede9d5b2001c8e30
Merged-In: I9e41b3ddde64c0623ba9299cede9d5b2001c8e30
(cherry picked from commit 7300d83b2e)
2018-04-05 09:23:35 -07:00
TreeHugger Robot
ffaeac104a Merge changes Ib44cbea8,I9763caa0 into pi-dev
* changes:
  Fix race in spawn.signal_stress test
  Fix race in ld.config.txt tests
2018-04-05 02:35:31 +00:00
Ryan Prichard
ef53e759cc Fix race in spawn.signal_stress test
The default behavior for a real-time signal is to terminate the process.
If the child we fork sends a SIGRTMIN signal before we've set up the
ScopedSignalHandler for it, then the parent is terminated.

Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static --gtest_filter=spawn.signal_stress --gtest_repeat=1000
Bug: b/77554047
Change-Id: Ib44cbea8ccf506644405d8f426d9ad24e77cfa33
(cherry picked from commit a1bc826c37)
2018-04-04 16:10:57 -07:00
Ryan Prichard
0044cd188e Fix race in ld.config.txt tests
The tests can run in parallel, and if they do, one test can truncate
ld.config.txt while another test is reading it (via the loader). Fix the
issue by using a TemporaryFile as the LD_CONFIG_FILE.

Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests  --gtest_filter=dl.exec_with_ld_config_file:dl.exec_with_ld_config_file_with_ld_preload:dl.disable_ld_config_file --gtest_repeat=1000
Bug: b/77555708
Change-Id: I9763caa076ece30d1a0eb9c8892a310ac51543b6
(cherry picked from commit 6c3f97d236)
2018-04-04 16:10:37 -07:00
Ryan Prichard
9dac3e9efd Break libdl.so and ld-android.so's dependency on libc.so.
* Specify "nocrt: true" to avoid calling __cxa_finalize.

 * Define a dummy __aeabi_unwind_cpp_pr0 for arm32.

Bug: b/62815515
Bug: b/73873002
Test: boot AOSP hikey960-userdebug
Test: run ndk_cxa_example in special /system/bin/debug namespace
Test: run Bionic unit tests
Change-Id: I59bcb100a2753286b59c51a47d7a183507219a07
(cherry picked from commit 470b66644b)
2018-04-04 15:56:02 -07:00
Ryan Prichard
075f77d6d6 Fix build failure with dlext_testzip Bionic tests
Other build rules create and use a test config file in the intermediate
directory containing $(LOCAL_BUILT_MODULE). Currently, this makefile
deletes $(dir $(LOCAL_BUILT_MODULE)) (aka $(dir $@)), so it can delete
the config file after it's created and before it's used. Avoid this
issue by using $(dir $@)/zipdir as the working directory for
constructing a zip file.

Bug: b/74524170
Test: mmma bionic
Test: run Bionic unit tests
Change-Id: Icee4d7bc72ba1c136385a0cb2c28491649598e7c
(cherry picked from commit ef59154d41)
2018-04-04 15:55:56 -07:00
Christopher Ferris
8b70a0266d Refactor malloc debug.
Changes
- Refactor the code so that only guards require creating a special header
  for every pointer allocated.
- Store only a single copy of every backtrace. This saves memory so that
  turning on the backtrace option doesn't result in 10X memory usage.
- Added new option track_allocs that only verifies pointers are valid for
  free/malloc_usable_size/realloc.
- Remove suffix from test names.
- Add the TRACK_ALLOCS options to all guard options.
- Add new option verify_pointers that is a lightweight way to verify
  pointers that are passed to allocation routines.
- Do auto-formatting of the code.
- Updated documentation for all of these changes.

Bug: 74361929

Test: Ran unit tests.
Test: Ran libmemunreachable unit tests.
Test: Ran an app with backtrace enabled.

Change-Id: I3246c48ae4f9811f64622d90d0a9b4d9d818702c
(cherry picked from commit 4da2503d70)
2018-04-03 13:13:53 -07:00
Ben Schwartz
622a36923e Pad queries when EDNS0 is enabled.
Behavior is compliant with
https://tools.ietf.org/html/draft-ietf-dprive-padding-policy-04

EDNS0 is only enabled when the netcontext requests it, i.e. in DNS-over-TLS
mode.

Bug: 69623036
Bug: 64133961
Test: Wireshark verified. Integration tests echo padding and pass.
Merged-In: Ie5439b0ad505ebf393a83c87845fd02549afc4a2
Merged-In: I274d659782870818274526d23d3a3c4640cad92d
Change-Id: I5ef600e02a572d281441e890cc981614f150629b
(cherry picked from commit 23e4081009bb58d9c09e615186208b77749e72de)
2018-04-02 15:31:30 -07:00
TreeHugger Robot
d65576d406 Merge "Add libtest_missing_symbol_child_private." into pi-dev 2018-03-30 01:51:12 +00:00
TreeHugger Robot
5ec355926f Merge "Fix -/_ typo." into pi-dev 2018-03-29 23:40:23 +00:00
Elliott Hughes
e1b1b8387e Add libtest_missing_symbol_child_private.
Bug: http://b/77236525
Bug: http://b/77276121
Test: builds

(cherry picked from commit 06d31c94c2)

Change-Id: I6f4b6d2527c8146a252aaa935a46d09632c44a5f
2018-03-29 16:34:33 -07:00
TreeHugger Robot
6df2dc1675 Merge "Allow several syscalls to app process" into pi-dev 2018-03-29 23:21:50 +00:00
Elliott Hughes
34b18c0189 Fix -/_ typo.
Bug: http://b/77236525
Bug: http://b/77276121
Test: builds

(cherry picked from commit 51466528cd)

Change-Id: I6c892a2714760ccce4da1d71a02c08e3ec990223
2018-03-29 13:58:38 -07:00
Victor Hsieh
bbfcf78804 Allow several syscalls to app process
Several privileged syscalls are still needed before a zygote-fork hangs
over the execution to the apps.

Test: system starts, different apps run
Bug: 63944145
Bug: 76461821
Change-Id: I78da54dac509eb073bc2aa7b820a1f6b0c39a775
Merged-In: I78da54dac509eb073bc2aa7b820a1f6b0c39a775
2018-03-29 13:41:37 -07:00
Jiyong Park
d8dcb55693 Add missing shared library dependencies to bionic-unit-tests
Bug: 77236525

Test: 'make tests dist' and verify that these libraries are in the
*-continuous_native_tests-*.zip

(cherry picked from commit ce10b16294)

Change-Id: I85c2476e4523fd3cb0fbc1bf7845ca5f042ba7e0
2018-03-29 17:55:01 +00:00
Pirama Arumuga Nainar
d65f209ad1 Add missed shared library dependency to bionic-unit-tests
Test: N/A

(cherry picked from commit 1395f70f6c)

Bug: http://b/77276121
Change-Id: I1ea52e5624e741f6fb7bf6c11b0a520d02835278
2018-03-29 17:54:41 +00:00
Pirama Arumuga Nainar
744fe65dd1 Add missing shared library dependencies to bionic-unit-tests
Test: 'make tests dist' and verify that these libraries are in the
*-continuous_native_tests-*.zip

(cherry picked from commit c53e8b88d5)

Bug: http://b/77276121
Change-Id: I310f999c6cf2ef2d53b37bc7c53590fe9e0e2fe3
2018-03-29 17:53:59 +00:00
Victor Khimenko
5a6b9565c0 Mark getaddrinfo functions with __BIONIC_WEAK_FOR_NATIVE_BRIDGE mark
System libc talks to out-of-process daemon thus it's better to not
duplicate that functionality in native bridge.

Bug: 67993967

Test: make

Change-Id: Iabc887a94082806d048bc98bf8d3b21c7531d60d
(cherry picked from commit 5956847acc)
2018-03-27 17:32:38 +02:00
Elliott Hughes
16eeaab659 Merge "Reject .so files using ELF TLS." into pi-dev 2018-03-27 14:26:48 +00:00
Tom Cherry
0d5906594d Create PTHREAD_COND_INITIALIZER_MONOTONIC_NP
Needed for std::condition_variable to wait on CLOCK_MONOTONIC.

Bug: 35756266
Bug: 73951740
Test: boot bullhead
Change-Id: I32a30817f0ec2190393fcc6faec45b40822cba32
(cherry picked from commit f0f3d2f002)
2018-03-26 16:20:47 -07:00
Elliott Hughes
45a93c13bf Reject .so files using ELF TLS.
Bug: http://b/74361956
Test: ran tests

(cherry picked from commit 9724e93c19)

Change-Id: I287c926951c337aacd2246940a1e6474e4c661e1
2018-03-26 11:09:40 -07:00
Tom Cherry
1142f7e70d Merge "Add _monotonic_np versions of timed wait functions" into pi-dev 2018-03-21 19:41:25 +00:00
Tom Cherry
76f78fc709 Add _monotonic_np versions of timed wait functions
As a follow up to Ibba98f5d88be1c306d14e9b9366302ecbef6d534, where we
added a work around to convert the CLOCK_REALTIME timeouts to
CLOCK_MONOTONIC for pthread and semaphore timed wait functions, we're
introducing a set of _monotonic_np versions of each of these functions
that wait on CLOCK_MONOTONIC directly.

The primary motivation here is that while the above work around helps
for 3rd party code, it creates a dilemma when implementing new code
that would use these functions: either one implements code with these
functions knowing there is a race condition possible or one avoids
these functions and reinvent their own waiting/signaling mechanisms.
Neither are satisfactory, so we create a third option to use these
Android specific _monotonic_np functions that completely remove the
race condition while keeping the rest of the interface.

Specifically this adds the below functions:
pthread_mutex_timedlock_monotonic_np()
pthread_cond_timedwait_monotonic_np()
pthread_rwlock_timedrdlock_monotonic_np()
pthread_rwlock_timedwrlock_monotonic_np()
sem_timedwait_monotonic_np()

Note that pthread_cond_timedwait_monotonic_np() previously existed and
was removed since it's possible to initialize a condition variable to
use CLOCK_MONOTONIC.  It is added back for a mix of reasons,
1) Symmetry with the rest of the functions we're adding
2) libc++ cannot easily take advantage of the new initializer, but
   will be able to use this function in order to wait on
   std::steady_clock
3) Frankly, it's a better API to specify the clock in the waiter function
   than to specify the clock when the condition variable is
   initialized.

Bug: 73951740
Test: new unit tests
Change-Id: I23aa5c204e36a194237d41e064c5c8ccaa4204e3
2018-03-21 08:43:09 -07:00
Ben Schwartz
a56793c238 Enable EDNS and the DO-bit if the netcontext asks
This effectively enables these features only in TLS mode
Test: Integration tests pass
Bug: 69623036
Bug: 64133961
Merged-In: Idbfbc0343e21ad713d9b4204fc48d63fb5b8dcd4
Merged-In: Ie3ae2390f01dbdcccf55fdd4e87b8a258702cfbc
Change-Id: I153a259b0c07717f664ee268b43da867a9b42152
(cherry picked from commit e7190ce3f2)
2018-03-21 07:57:14 -07:00
Ben Schwartz
9864564fca Lay the groundwork for enabling EDNS0 in queries.
This change does not enable EDNS0, so it should not
result in any behavior change.  However, enabling EDNS0
should now be possible with only a small additional change
to "flip the switch".

This change has also landed in NetBSD upstream
(http://gnats.netbsd.org/52578) so this change reduces
divergence from upstream.

Most of the code in this change is for caching of queries that contain
an additional section.

Bug: 15132200
Bug: 64133961
Test: Added integration tests for fallback to the netd suite.
Merged-In: I9b0abc6e4f3ff7f9c23a5cb921d392d2d3065d99
Merged-In: I9c06bbaf1883de4bdebd822f9a052901bf3efc04
Merged-In: Ie438b77bc1aeea0b0c700a90998cec31ac9a0015
Change-Id: Ic64bed0754e1d529dc0c0ab6a5e2f1ea201ff0d5
(cherry picked from commit 6eed8e1bb6)
2018-03-19 08:22:07 -07:00
Yabin Cui
9e989f12d1 Check using destroyed mutexes.
For apps built for Android < P, return EBUSY.
For apps built for Android >= P, abort.

This is to keep old apps work, and help debugging
apps built for >= P.

Bug: http://b/74632097
Test: run bionic-unit-tests.
Test: run bionic-benchmark.

Change-Id: I5271565a1a6ad12678f85d558a7f862a2b7aab4b
(cherry picked from commit 9651fdf93a)
2018-03-15 17:42:27 -07:00
Erik Kline
b85d0bd2b9 Add flags field to struct android_net_context
This is for passing additional instructions through stages of the
DNS resolution pipeling.

Test: as follows
    - builds, flashes, boots
    - system/netd/tests/runtests.sh passes
Bug: 34953048
Bug: 64133961
Bug: 70694619
Bug: 72345192
Merged-In: I81c49586d675160b66dc2c51b76ad183cc418213
Merged-In: Ie8a8ee5784407d4ec304b3f40a6b234ebeaf6376
Merged-In: Icdec53cf5b210db5ad833dd3b64fa3d8ae74100a
Change-Id: I5a86cc5192e6cfa09c375ac9f5810102da3aba20
(cherry picked from commit 391143e51b)
2018-03-14 16:18:25 +09:00
Jerry Zhang
ed1b4547df Sign extend offset for pwritev/preadv.
Kernel expects a 64 bit offset, so if a
user's offset is 32 bit, the wrapper will
drop the sign. To fix, sign extend the
32 bit value before doing the syscall.

Bug: 31225071
Test: pwritev02 32 bit passes

(cherry picked from commit f55dbc0516)

Change-Id: Ie81d29a37cf4e99c9279cffc89f4fa1b4da9a898
2018-03-07 10:31:00 -08:00
Elliott Hughes
49b4fce967 Merge "clang-format local.h." am: 0a8d5f3eb8 am: 9d47ff97e0
am: a8ad2e2e96

Change-Id: I83fd10e67c3684a6fe39b40968710abe501ad50b
2018-03-02 08:44:16 +00:00
Elliott Hughes
a8ad2e2e96 Merge "clang-format local.h." am: 0a8d5f3eb8
am: 9d47ff97e0

Change-Id: Ib2f9d6ead64145846cb0f0c4889d0277db0a377a
2018-03-02 08:38:40 +00:00
Elliott Hughes
9d47ff97e0 Merge "clang-format local.h."
am: 0a8d5f3eb8

Change-Id: I24f53d545306bb8574ea466ae8aa4711b07747da
2018-03-02 08:33:36 +00:00
Treehugger Robot
0a8d5f3eb8 Merge "clang-format local.h." 2018-03-02 08:23:34 +00:00
Elliott Hughes
839a4269dc Merge "Separate the new P functions from the new P behavior in the docs." am: 2cb18c3460 am: 1ac5f9721a
am: 1274397363

Change-Id: I5619db03f95fbd07396783987a2d59c9f283adad
2018-03-02 07:19:53 +00:00
Elliott Hughes
1274397363 Merge "Separate the new P functions from the new P behavior in the docs." am: 2cb18c3460
am: 1ac5f9721a

Change-Id: I47cf82bf3fe903e6e3b3bd07ac4591c5a7ce4841
2018-03-02 07:13:16 +00:00
Elliott Hughes
1ac5f9721a Merge "Separate the new P functions from the new P behavior in the docs."
am: 2cb18c3460

Change-Id: If5468335c64767a29399fc54858fb2aa37fd1f71
2018-03-02 07:07:40 +00:00
Treehugger Robot
2cb18c3460 Merge "Separate the new P functions from the new P behavior in the docs." 2018-03-02 06:59:26 +00:00
Elliott Hughes
aabfcde817 Merge "Merge stdio/local.h and stdio/wcio.h." am: 3040a7a08c am: 84de501af4
am: 3dedf2294d

Change-Id: Icfe1a80c379ba2b3a51fe76306b821e14fbab809
2018-03-02 04:11:59 +00:00
Elliott Hughes
3dedf2294d Merge "Merge stdio/local.h and stdio/wcio.h." am: 3040a7a08c
am: 84de501af4

Change-Id: I13b097c4314cf353f39f382d2272df59d3e405f7
2018-03-02 04:05:25 +00:00
Elliott Hughes
84de501af4 Merge "Merge stdio/local.h and stdio/wcio.h."
am: 3040a7a08c

Change-Id: Ifcf9fe3bb858e816b12b76db7471fcee082cf1cf
2018-03-02 03:59:51 +00:00
Elliott Hughes
3040a7a08c Merge "Merge stdio/local.h and stdio/wcio.h." 2018-03-02 03:48:53 +00:00
Elliott Hughes
a14e05567d Merge "Document the strptime %s change." am: 66e49c0503 am: 22eb0a61dd
am: ea1dc9561d

Change-Id: I5fabd7475f16a6c3e841d239c7957eeaf81aea49
2018-03-02 01:43:44 +00:00
Elliott Hughes
ea1dc9561d Merge "Document the strptime %s change." am: 66e49c0503
am: 22eb0a61dd

Change-Id: Ia25c3fc4f77618740b0703daa4017b11ef62e76d
2018-03-02 01:38:13 +00:00
Elliott Hughes
22eb0a61dd Merge "Document the strptime %s change."
am: 66e49c0503

Change-Id: Ib5cd6c557fb643b1689f588a8a08b3301e2f0053
2018-03-02 01:33:09 +00:00
Treehugger Robot
66e49c0503 Merge "Document the strptime %s change." 2018-03-02 01:24:47 +00:00