Commit graph

9307 commits

Author SHA1 Message Date
Tom Cherry
a06c49c37f Add recovery_available: true to libseccomp_policy
Init needs this in order to be built in Android.bp

Test: build

Change-Id: I0ce67a3c84cf476b28be039b9c9b345bc381de7b
2018-07-24 13:36:59 -07:00
Tom Cherry
0fe2203309 Fixup an out of date comment.
Test: n/a
Change-Id: Ieb5d18d479becb8c92cbf71a8bb7cd67f7c27dba
2018-07-24 13:34:34 -07:00
Elliott Hughes
7763ab4bcb Use the FreeBSD __CONCAT.
We had the NetBSD __CONCAT macro, despite the fact that our only callers
are FreeBSD code. The FreeBSD libm changes in FreeBSD r336665 require
the FreeBSD implementation rather than the NetBSD one.

Unfortunately for me, that libm code is built in the NDK build too,
where it's built against the NDK's <sys/cdefs.h>. So I need to update
__CONCAT first before I can update the libm code.

Bug: http://b/111710419
Test: ran tests
Change-Id: I70e76e4caab2929c939bfb7009df9fe79d26806a
2018-07-24 12:45:58 -07:00
Elliott Hughes
0d1a8a5b0b Reland "Retire GCC FORTIFY."
This reverts commit 4dbe8fc22f.

The angler/bullhead builds are now dead, so this can go in.

Bug: https://issuetracker.google.com/74404306
Change-Id: I130cdcd6375b6125cb8a1e63a4a540b0dbe41ceb
2018-07-24 19:36:51 +00:00
Elliott Hughes
4dbe8fc22f Revert "Retire GCC FORTIFY."
This reverts commit 067bdc9546.

The angler/bullhead builds still use GCC, so I'll wait until they're turned down.

Bug: https://issuetracker.google.com/74404306
Change-Id: I777b08dd6ab5250d532b4b5cc56e9a790c13db20
2018-07-24 18:54:16 +00:00
Elliott Hughes
ab52807685 Update to FreeBSD libm r336665.
This reverts commit 253a830631 and moves
us forward to a revision that contains fixes for the problem with the
previous attempt.

This also makes sincos(3)/sincosf(3)/sincosl(3) available to `_BSD_SOURCE`
as well as `_GNU_SOURCE`.

The new FreeBSD libm code requires the FreeBSD `__CONCAT` macro, and all
our existing callers are FreeBSD too, so update that.

There's also an assumption that <complex.h> drags in <math.h> which isn't
true for us, so work around that with `-include` in the makefile. This
then causes clang to recognize a bug -- returning from a void function --
in our fake (LP32) sincosl(3), so fix that too.

Bug: http://b/111710419
Change-Id: I84703ad844f8afde6ec6b11604ab3c096ccb62c3
Test: ran tests
2018-07-24 10:36:00 -07:00
Josh Gao
fe380887c8 fdsan: improve diagnostics.
Generate a tombstone instead of just a log message when warning. Also,
don't use async_safe_fatal_va_list when we're not calling abort, as
this will permanently set the abort message.

Test: bionic_unit_tests
Test: setprop debug.fdsan warn; crasher fdsan_file
Change-Id: I2fe271da9004c8fd1f50ad3d8280be254eeaf656
2018-07-23 18:36:16 -07:00
Elliott Hughes
067bdc9546 Retire GCC FORTIFY.
NDK r18 (which removes GCC) is about to ship. We don't need this any more.

The immediate motivation for removing this right now is that the test
fails whenever we add Clang-only flags to the build system.

While we're here, clean up <stdatomic.h> too.

Bug: https://issuetracker.google.com/74404306
Test: ran tests
Change-Id: Iaad5d634d1ba76f0b6f19ad32cc27b2533771a4a
2018-07-23 17:22:58 -07:00
Andreas Gampe
253a830631 Revert "Update to FreeBSD libm r336523."
This reverts commit f86ee10278.

Incorrect result for fmodf(3.0f, 0f) = 1.0f breaks ART tests.

Bug: 111710419
Test: art/test/testrunner/testrunner.py -b -t 436-rem-float --target
Change-Id: I7eae68fb92740db33415d16418447bcbbd98ecba
2018-07-21 12:23:03 -07:00
Josh Gao
e899e798b8 Mark fdsan functions as __attribute__((weak)).
Make it so that users can check for availability of fdsan at runtime.

Bug: http://b/110100358
Test: treehugger
Test: make libjnitest
Change-Id: Ief3054161f3e255d048370975f7dd90cf7ad3687
2018-07-20 13:51:28 -07:00
Treehugger Robot
170540398a Merge "Update to FreeBSD libm r336523." 2018-07-20 20:21:33 +00:00
Treehugger Robot
402ca1130b Merge "Introduce api to track fd ownership in libc." 2018-07-19 23:43:37 +00:00
Elliott Hughes
f86ee10278 Update to FreeBSD libm r336523.
This includes an ld128 powl, plus the clog* and cpow* families.

Also teach the NOTICE generator to strip SPDX-License-Identifier lines.

Bug: N/A
Test: ran tests
Change-Id: Ic8289d1253666a19468a4088884cf7540f1ec66d
2018-07-19 16:17:06 -07:00
Josh Gao
f6e5b58260 Introduce api to track fd ownership in libc.
Add two functions to allow objects that own a file descriptor to
enforce that only they can close their file descriptor.

Use them in FILE* and DIR*.

Bug: http://b/110100358
Test: bionic_unit_tests
Test: aosp/master boots without errors
Test: treehugger
Change-Id: Iecd6e8b26c62217271e0822dc3d2d7888b091a45
2018-07-19 14:28:54 -07:00
Florian Mayer
24ded2df58 Merge "Fix malloc_hooks for hooks_write_malloc_leak_info." 2018-07-19 09:10:56 +00:00
Florian Mayer
2d6030b2f5 Fix malloc_hooks for hooks_write_malloc_leak_info.
Change-Id: I99f9ee0221bc7bbb5e7dd173ae5a6007f0fa871d
2018-07-18 15:25:45 +01:00
Elliott Hughes
bf74815b52 setjmp is a macro.
POSIX says it's unspecified whether setjmp is a macro or a function,
but C11 says it's a macro, and the C standard always wins.

Bug: https://github.com/android-ndk/ndk/issues/744
Test: ran tests
Change-Id: I4a1abc37724f8e9d9498f2093ef3c1f3b8253949
2018-07-17 13:55:36 -07:00
Elliott Hughes
f98d87b831 Add C11 timespec_get.
Bug: https://github.com/android-ndk/ndk/issues/744
Test: ran tests
Change-Id: Iad9514946e06d55b6a3aa0f945d9a63bff900881
2018-07-17 13:21:05 -07:00
Elliott Hughes
3a5fd0014c Expose __res_randomid.
I don't think this will help the original submitter, because <resolv.h>
is mostly useless on Android. One day we might have a deprecation and
removal policy for the NDK, but until then we should probably maintain
this header.

Bug: https://github.com/android-ndk/ndk/issues/739
Test: ran tests
Change-Id: I2db859abfdebc3824c997462fa6133d5b355a8dd
2018-07-17 13:02:52 -07:00
Christopher Ferris
a9713035ba Merge "Disable malloc debug intercepts when exiting." 2018-07-13 18:15:59 +00:00
Treehugger Robot
2e457f5128 Merge "Call __emutls_unregister_key on dlclose" 2018-07-12 04:33:19 +00:00
Christopher Ferris
97b4747102 Disable malloc debug intercepts when exiting.
There is a hang when enabling leak_track since the dumping of the
leak data can wind up doing an allocation.

Add new system unit test to make sure this doesn't happen again.

Bug: 111146059

Test: Test program that leaks does not hang forever.
Test: Unit tests pass.
Change-Id: Icf99be58ba5db98ee124a471b957a086045f5870
2018-07-11 15:23:00 -07:00
Treehugger Robot
06f217d399 Merge "Remove workarounds for old versions of clang and GCC." 2018-07-11 22:08:46 +00:00
Elliott Hughes
3012b9636b Remove workarounds for old versions of clang and GCC.
Bug: N/A
Test: ran tests
Change-Id: I89d224c743f5113771de41c74161a7a5ccad05e4
2018-07-11 13:18:29 -07:00
Elliott Hughes
468efc80da Reimplement popen(3)/pclose(3).
pclose(3) is now an alias for fclose(3). We could add a FORTIFY check
that you use pclose(3) if and only if you used popen(3), but there seems
little value to that when we can just do the right thing.

This patch also adds the missing locking to _fwalk --- we need to lock
both the global list of FILE*s and also each FILE* we touch. POSIX says
that "The popen() function shall ensure that any streams from previous
popen() calls that remain open in the parent process are closed in the
new child process", which we implement via _fwalk(fclose) in the child,
but we might want to just make *all* popen(3) file descriptors O_CLOEXEC
in all cases.

Ignore fewer errors in popen(3) failure cases.

Improve popen(3) test coverage.

Bug: http://b/72470344
Test: ran tests
Change-Id: Ic937594bf28ec88b375f7e5825b9c05f500af438
2018-07-11 12:15:26 -07:00
Treehugger Robot
f0296f35f6 Merge "Include uchar.h only for bionic" 2018-07-10 00:42:25 +00:00
Christopher Ferris
bcff244134 Merge "Update to v4.17.3 kernel headers." 2018-07-09 19:23:00 +00:00
Pirama Arumuga Nainar
6c0eab9c5b Include uchar.h only for bionic
Bug: http://b/111265772

uchar.h is not available in the glibc used for the host.  Since Bionic's
stdatomic.h is also used for the host (via a copy in prebuilts/clang)
guard the include with a check for __BIONIC__.

Also replace the check for C11 around definition of
atomic_char_{16,32}_t with a check for __BIONIC__.  While we're here,
check if __cplusplus is defined before checking its value.  This avoids
a potential -Wundef warning.

Test: Build
Change-Id: Icb62150d978703175b78d8ad12b42cf98b424b9a
2018-07-09 12:03:23 -07:00
Elliott Hughes
07a7c9b316 Merge "Fix some long-standing UTF-8 bugs." 2018-07-09 18:27:31 +00:00
Elliott Hughes
402c762fc9 Fix some long-standing UTF-8 bugs.
We we incorrectly rejecting U+fffe and U+ffff, and incorrectly accepting
characters above U+10ffff (see https://tools.ietf.org/html/rfc3629
section 12 for that restriction).

Bug: http://lists.landley.net/pipermail/toybox-landley.net/2017-September/009146.html
Test: ran tests
Test: also ran the exhaustive test from that email thread
Change-Id: I8ae8e41cef01b02933bd4f653ee07791932b79a5
2018-07-06 17:18:05 -07:00
Bernie Innocenti
b664724525 bionic: Convert res_send.c to poll()
Bug: 5854418
Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Test: manually:
    - flash and boot device
    - connect to wifi
    - launch WebView and resolv a few domains
Change-Id: I7b488e6d061d99a8a3c4bba69c2ac8609257eb6a
2018-07-05 11:39:09 +09:00
Treehugger Robot
cc9fa92694 Merge "<sys/un.h>: add SUN_LEN." 2018-06-27 22:59:52 +00:00
Treehugger Robot
a2389a01bc Merge "<netinet/ip_icmp.h>: ensure struct icmphdr is available." 2018-06-27 21:17:59 +00:00
Christopher Ferris
76a1d45599 Update to v4.17.3 kernel headers.
Test: Builds, boots on a walleye.
Change-Id: I389d8b61ec00ea309e38d1b1a2e0dace48c21edb
2018-06-27 14:12:29 -07:00
Elliott Hughes
e7d185f59e <sys/un.h>: add SUN_LEN.
Also used by lldb.

Bug: N/A
Test: ran tests
Change-Id: I4c2aa60e7a3d8c691742c12ebde142d9438bf60f
2018-06-27 14:08:48 -07:00
Elliott Hughes
e5a5eec5e5 <netinet/ip_icmp.h>: ensure struct icmphdr is available.
Needed to build toybox ping.

Bug: N/A
Test: ran tests
Change-Id: Ifd0f0ccbb8351c6a0ece526b050778fd02e984bf
2018-06-27 12:29:06 -07:00
Adhemerval Zanella
37d4e67bb0 Set __bionic_asm_align to 16 for arm64
As for others targets, it is better to align function text by minimim
cacheline size.  This patch changes arm __bionic_asm_align to 16.

Test: bionic tests on aarch64.
Change-Id: Ib121663c65493d33d6803e2c5139d247a8cae858
2018-06-26 15:58:52 -03:00
Ryan Prichard
bcea0e2afd Call __emutls_unregister_key on dlclose
We want to delay the emutls pthread key deletion to keep
__thread/thread_local variables working as long as possible.

Currently, emutls has its own __attribute__((destructor)) function that
deletes its pthread key. That function runs even on process exit, and it
can run before other destructor functions and before C++ static object
destructors.

Move the destructor function to crtbegin_so.c, where an
__attribute__((destructor)) function is only called on dlclose. Use a
priority 0 destructor, which runs after every destructor with a default or
greater priority value.

__emutls_unregister_key will still run before destructor functions of
DT_NEEDED solibs. It also still leaks memory (both the emutls arrays and
each emutls object).

Bug: b/80453944
Test: manual
Change-Id: I6789bcf168415ab8badf2f64687c6a0136c5c917
2018-06-19 13:22:36 -07:00
Bernie Innocenti
0912d76b96 bionic: Remove libc/Android.mk file
Since there are no longer any Android.mk files in subdirs, the
top-level one can go.

Test: m
Change-Id: Ifc51545fc82a5eaa0801babd3ede20d911f1b9c3
2018-06-18 05:22:15 +00:00
Christopher Ferris
2e1a40a203 Change heap dump format slightly.
Bump the version from v1.1 to v1.2 and add a build fingerprint line.

Update the heap dump documentation to match the new format and reflect
what made it in P and what made it in Q.

Update the unit tests for this change.

Add -O0 to unit test code to make it easier to debug.

Add an external function that can be used by the framework code
so that there is only one way to dump the heap.

Bug: 110095681

Test: Ran unit tests.
Test: Did a dump of a real process and verified fingerprint.
Test: Did a dump of a process without malloc debug enabled.
Change-Id: I769a476cbeaf4c85c5d75bd6d6385f0e3add948c
Merged-In: I769a476cbeaf4c85c5d75bd6d6385f0e3add948c
(cherry picked from commit c84a2a2601)
2018-06-15 12:29:13 -07:00
Treehugger Robot
2583b0adb2 Merge changes from topic "sharedlib_in_recovery"
* changes:
  dynamic linker is running for init
  Build recovery variant of the dynamic linker
2018-06-13 23:14:29 +00:00
Treehugger Robot
79d8ecb9fb Merge "Remove valgrind workarounds." 2018-06-13 00:30:28 +00:00
Elliott Hughes
95bca3f7d4 Remove valgrind workarounds.
Bug: http://b/77856586
Test: ran 32-bit x86 tests on host
Change-Id: I98f6262bb1363ed5c8dd533b1f89b59b2b188525
2018-06-12 15:29:36 -07:00
Haibo Huang
8a0f0ed5e7 Make memcpy memmove
Bug: http://b/63992911
Test: Change BoardConfig.mk and compile for each variant
Change-Id: Ia0cc68d8e90e3316ddb2e9ff1555a009b6a0c5be
2018-06-11 18:12:45 +00:00
Jiyong Park
8d7866c58f Build recovery variant of the dynamic linker
In order to support shared libraries in the recovery mode, the dynamic
linker is now built with recovery_available: true option.

In addition, a few more modules (such as libasync, etc.) are also marked
as recovery_available: true as they are transitive dependencies of the
dynamic linker.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: `adb root && adb shell` and then
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: Idd981d8cf25568a85b24032cf78e50adfd5f4a7f
2018-06-08 14:49:56 +09:00
Elliott Hughes
7c5bbf627c Add missing __INTRODUCED_IN to pthread_attr_setinheritsched/pthread_attr_getinheritsched.
Bug: https://github.com/android-ndk/ndk/issues/716
Test: N/A
Change-Id: Ie49f96976f93b0f0d59796169e98918a9f69c0df
2018-06-07 09:11:47 -07:00
Christopher Ferris
1d52a7b1be Add an example of how to use multiple options.
Test: NA
Change-Id: I67b6c2f8eb8ad8ead98969e69990f540ecd9a770
2018-06-01 13:42:25 -07:00
Treehugger Robot
fe55c272ad Merge "Initialize __libc_sysinfo early on." 2018-05-31 22:32:32 +00:00
Florian Mayer
14e54c0d30 Fix name of env variable in malloc_hooks README.
Change-Id: I172ef71c9d74ec6e4bc51fe2bd8e4587b801b71c
2018-05-31 17:36:24 +01:00
Treehugger Robot
6ef8415d09 Merge "Inline __libc_init_global_stack_chk_guard." 2018-05-31 02:22:06 +00:00
Treehugger Robot
8b14ed45ec Merge "Clean up TLS_SLOT_BIONIC_PREINIT usage a bit" 2018-05-31 01:45:41 +00:00
Ryan Prichard
27475b5105 Initialize __libc_sysinfo early on.
__libc_sysinfo is hidden, so accessing it doesn't require a relocated GOT.
It is important not to have a relocatable initializer on __libc_sysinfo,
because if it did have one, and if we initialized it before relocating the
linker, then on 32-bit x86 (which uses REL rather than RELA), the
relocation step would calculate the wrong addend and overwrite
__libc_sysinfo with garbage.

Asides:

 * It'd be simpler to keep the __libc_sysinfo initializer for static
   executables, but the loader pulls in libc_init_static (even though it
   uses almost none of the code in that file, like __libc_init).

 * The loader has called __libc_init_sysinfo three times by the time it
   has relocated itself. A static executable calls it twice, while libc.so
   calls it only once.

Bug: none
Test: lunch aosp_x86-userdebug ; emulator
Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Test: adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
Change-Id: I5944f57847db7191608f4f83dde22b49e279e6cb
2018-05-30 16:44:23 -07:00
Ryan Prichard
cb5f410006 Inline __libc_init_global_stack_chk_guard.
Prior to b6453c52ac, this function
was called from two C++ files.

Test: boot hikey
Change-Id: Ieeae6ea617c5b19e2cd76c1b37c9511a72d01597
2018-05-30 16:10:35 -07:00
Ryan Prichard
6631f9b03d Clean up TLS_SLOT_BIONIC_PREINIT usage a bit
- It is only needed for dynamic executables, so move the initialization
   out of __libc_init_main_thread and just before the solib constructor
   calls. For static executables, the slot was initialized, then never
   used or cleared. Instead, leave it clear.

 - For static executables, __libc_init_main_thread already initialized the
   stack guard, so remove the redundant __init_thread_stack_guard call.

 - Simplify the slot access/clearing a bit in __libc_preinit.

 - Remove the "__libc_init_common() will change the TLS area so the old one
   won't be accessible anyway." comment. AFAICT, it's incorrect -- the
   main thread's TLS area in a dynamic executable is initialized to a
   static pthread_internal_t object in the linker, then reused by libc.so.

Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
Test: adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
Change-Id: Ie2da6f5be3ad563fa65b38eaadf8ba6ecc6a64b6
2018-05-30 15:43:43 -07:00
Haibo Huang
d0c330b5d8 Merge "Use cortex-a53/bionic/memmove.S by default for arm64" 2018-05-30 22:26:57 +00:00
Haibo Huang
ece43e14c9 Use cortex-a53/bionic/memmove.S by default for arm64
cortex-a53/bionic/memmove.S looks like a more optimized version. It
should be used in most cases. It delegates small (<= 96 bytes) moves
to memcpy.

The only exception is denver64. It is using its own memcpy, which
doesn't allow overlap for < 96 bytes copies. Only for this variant we
need generic/bionic/memmove.S.

Benchmark result looks pretty close through (on marlin)

Before: using generic/bionic/memmove.S

-------------------------------------------------------------------
Benchmark                            Time           CPU Iterations
-------------------------------------------------------------------
BM_string_memcpy/8/0/0               6 ns          6 ns  108872005   1.15787GB/s
BM_string_memcpy/64/0/0              7 ns          7 ns  107387438   9.14365GB/s
BM_string_memcpy/512/0/0            21 ns         20 ns   34165353   23.2734GB/s
BM_string_memcpy/1024/0/0           40 ns         39 ns   17766657   24.2346GB/s
BM_string_memcpy/8192/0/0          311 ns        310 ns    2259904   24.6339GB/s
BM_string_memcpy/16384/0/0         616 ns        613 ns    1143027   24.8852GB/s
BM_string_memcpy/32768/0/0        1322 ns       1316 ns     530799   23.1835GB/s
BM_string_memcpy/65536/0/0        2672 ns       2661 ns     229638    22.937GB/s
BM_string_memcpy/131072/0/0       5379 ns       5357 ns     128316    22.788GB/s

After: using cortex-a53/bionic/memmove.S

-------------------------------------------------------------------
Benchmark                            Time           CPU Iterations
-------------------------------------------------------------------
BM_string_memcpy/8/0/0               6 ns          6 ns  116610749   1.24646GB/s
BM_string_memcpy/64/0/0              6 ns          6 ns  115634093   9.84708GB/s
BM_string_memcpy/512/0/0            21 ns         21 ns   34167322   22.8938GB/s
BM_string_memcpy/1024/0/0           39 ns         39 ns   17859445   24.3312GB/s
BM_string_memcpy/8192/0/0          311 ns        310 ns    2260192   24.6325GB/s
BM_string_memcpy/16384/0/0         610 ns        608 ns    1151889   25.0987GB/s
BM_string_memcpy/32768/0/0        1488 ns       1482 ns     532508   20.5988GB/s
BM_string_memcpy/65536/0/0        2421 ns       2411 ns     290502   25.3146GB/s
BM_string_memcpy/131072/0/0       5278 ns       5256 ns     132710   23.2234GB/s

Test: Build and benchmark on marlin
Bug: http://b/63992911
Change-Id: Id85961aca18ba841bcbcfe0d8b162843eab30584
2018-05-30 11:09:19 -07:00
Elliott Hughes
d7cabc96ae Merge "Fix the map for pthread_cond_timedwait_monotonic_np." 2018-05-30 00:24:46 +00:00
Elliott Hughes
12306f0aa0 Fix the map for pthread_cond_timedwait_monotonic_np.
Bug: https://github.com/android-ndk/ndk/issues/708
Test: builds
Change-Id: Icaa1f8cb796a0a117cbe2e10391c965c857d6d37
2018-05-29 13:12:21 -07:00
Christopher Ferris
770cbb35cf Point to online documentation.
Test: Unit tests pass.
Change-Id: Ibbdc260bfdf6a6daf091c4a49cdf03e51f6ca6cf
2018-05-25 13:28:05 -07:00
Elliott Hughes
149671875d Link to native_heapdump_viewer.py.
Bug: N/A
Test: N/A
Change-Id: I1e448f30922d948513ebb65abc25c474ffbd5a24
2018-05-24 18:44:31 -07:00
Elliott Hughes
ebf58a6cef Merge "Add generic arm non-neon memmove." 2018-05-24 23:53:36 +00:00
Christopher Ferris
7caf313168 Merge "Modify the script to use the linux source tree." 2018-05-24 23:50:07 +00:00
Treehugger Robot
b2341cdfe3 Merge "Adapt to versioned_ndk_headers renaming." 2018-05-24 23:47:56 +00:00
Christopher Ferris
764049dce4 Modify the script to use the linux source tree.
The current code checks out the android kernel tree. Long ago, we moved
to using the linux kernel source code. Modify the script to actually
do this.

Bug: 6653610

Test: Ran the script using the --download_kernel option and without.
Change-Id: I769e769edea272f4f8c9c8d2e76bd336059c66e3
2018-05-24 15:10:33 -07:00
Elliott Hughes
da46caee09 Add generic arm non-neon memmove.
From OpenBSD.

Bug: http://b/63992911
Test: ran tests
Change-Id: If7d9166922776cdc9333ff04205f9c6312a812b3
2018-05-24 14:57:15 -07:00
Dan Albert
26e1c41f5c Adapt to versioned_ndk_headers renaming.
Test: make checkbuild
Bug: None
Change-Id: I89b931c8519eb4f336fb1a338d6b6518c50bcee1
2018-05-24 14:56:46 -07:00
Christopher Ferris
7bfc149b43 Merge "Add support for using the new unwinder." 2018-05-24 18:06:02 +00:00
Christopher Ferris
93bdd6ae3a Add support for using the new unwinder.
This adds a new option backtrace_full, when it is set, then it will use
libunwindstack.

Modify the dump to file data to dump the extra information from libunwindstack.
Along with the new dump file format, change the version to v1.1.
Updated document for new format of file data.

Add unit tests for the new functionality.

Bug: 74361929

Test: Ran unit tests.
Change-Id: I40fff795f5346bba7b9d7fde2e04f269ff4eb7f1
2018-05-24 08:44:53 -07:00
Chih-Hung Hsieh
ecbff8382d Work around b/24465209, do not pack relocation table.
Global flag --pack-dyn-relocs=android is used with clang lld.
For b/24465209, we need to override that with --pack-dyn-relocs=none.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: Ic3837446ff0deccf4e66425b39d3b062abcacc5e
2018-05-23 18:45:53 -07:00
Chih-Hung Hsieh
0fc5df0fde Work around b/24465209, do not use clang lld
See longer explanation in b/80093890.
Clang lld does not generate expected DT_REL and DT_RELA tags
with --hash-style=both and --pack-dyn-relocs=android.
I am not sure about the extent of b/24465209, so
I would rather not to use lld for these .so files for now.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I94e9fe8d687daeadb0182ae26596ca11d3f8bd9b
2018-05-23 17:14:22 +00:00
Treehugger Robot
b886592923 Merge "Mark as recovery_available: true" 2018-05-22 05:16:20 +00:00
Tom Cherry
903e5702f4 Merge "Require vendor users and groups to start with vendor_" 2018-05-16 16:19:28 +00:00
Tom Cherry
c2b9fec50b Require vendor users and groups to start with vendor_
Require that users and groups found in /vendor/etc/{passwd,group}
start with vendor_.  This is needed to compliance with Treble as
without this prefix, it is possible for a new system image to create a
user/group name that a vendor has already used, causing a collision.

Bug: 79528966
Test: new unit test
Change-Id: I07500641e165f41526a8101592d83fa174e7a711
2018-05-15 14:10:21 -07:00
Jiyong Park
5603c6e6b9 Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Bug: 63673171
Bug: 29921292
Test: m -j
Change-Id: I59bf859a10a218af6591025a0fe7d1853e328405
2018-05-14 18:08:01 +09:00
Elliott Hughes
3f185dc01e Merge changes I8693c641,I9efbc23b,Ifa03eb36
* changes:
  Switch to FreeBSD's actual sincos.
  Switch to FreeBSD catrigl.c for complex arc trig functions.
  Update libm from upstream.
2018-05-12 00:48:08 +00:00
Christopher Ferris
4da58cf630 Add support for cortex-a55/cortex-a75.
Bug: 78133793
Bug: 78242072

Test: Builds and ran to verify best libc routines.
Change-Id: I2299b8f0f6379c9003072764978ea917b74aee4f
Merged-In: I2299b8f0f6379c9003072764978ea917b74aee4f
(cherry picked from commit 3162eb3b81)
2018-05-11 00:43:01 +00:00
Tom Cherry
e267f1a7aa Fix typo in comment
Test: n/a
Change-Id: I2a869ad920a9867fda9864e11fdaa0d66611b181
2018-05-10 20:41:44 +00:00
Elliott Hughes
e332f658e0 Switch to FreeBSD's actual sincos.
Before:
  BM_math_sin_fast                48 ns         48 ns   14693053
  BM_math_sincos                  61 ns         61 ns   11470219

After:
  BM_math_sin_fast                48 ns         48 ns   14725120
  BM_math_sincos                  43 ns         43 ns   16329843

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I8693c64135233c0641af5302c38748f47ac76737
2018-05-09 12:25:12 -07:00
Elliott Hughes
8da8ca4528 Update libm from upstream.
Bug: N/A
Test: ran tests
Change-Id: Ifa03eb36d412a2776208cd2921936be4724e5547
2018-05-09 12:24:21 -07:00
Elliott Hughes
68e1c5b752 Merge "Fix various ftw/nftw "shall fail"s from POSIX." 2018-05-09 15:27:50 +00:00
Elliott Hughes
70a8f2272e Fix various ftw/nftw "shall fail"s from POSIX.
POSIX says ftw/nftw "shall fail" in various cases where BSD's fts_open
doesn't. Since our ftw/nftw are written in terms of fts_open, add a back
door so we can hint to ourselves when we should have the POSIX semantics.

Also pull several O_CLOEXEC and don't-null-check-before-free cleanups
from upstream, and add a couple of tests.

Bug: http://b/31152735
Test: ran bionic tests and LTP "nftw01" test
Change-Id: Ib05facacc1da4c8b2ab48e9ecce88f11a5406630
2018-05-08 15:20:07 -07:00
Lorenzo Colitti
5f02720c88 fchown DNS lookup sockets to AID_DNS.
Currently DNS lookups are all sent as UID 0. In N we added an
AID_DNS user, but we never used it. A separate UID allows us to
account for and route DNS traffic differently from other UID 0
traffic such as kernel-originated traffic.

Bug: 70673901
Test: DNS lookups continue to work
Test: netd_{unit,integration}_test pass
Change-Id: Ife3ca7df45de51b92437d2cfe627fb4703b672fb
2018-05-09 01:04:05 +09:00
Christopher Ferris
5a6c866dd5 Merge "Fix nullptr dereference during sort." 2018-05-02 20:18:18 +00:00
Ryan Prichard
d91285f166 Fix PROP_FILENAME_MAX overflow handling
Bug: b/79117743
Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests
Change-Id: Idd5aa4d195abc13c06d3e5b57aef69a68c2a9a9d
2018-05-01 18:19:21 -07:00
Ryan Prichard
5258c2518e Fix async_safe_fatal overflow handling
Bug: b/79116392
Test: manual
Change-Id: I46cd1007be165489db27cdcd4b42ec69de40d645
2018-05-01 17:59:59 -07:00
Christopher Ferris
c151bc3078 Fix nullptr dereference during sort.
Add new unit test that will crash without this fix.

Bug: 78900050

Test: Ran unit tests.
Change-Id: I73e1b89e965a7b399822c3a6f25cbc70d2d355e2
2018-05-01 14:49:15 -07:00
Elliott Hughes
8602538a15 Merge "Fix sysconf errno for unknown names." 2018-04-26 18:09:31 +00:00
Elliott Hughes
d6f57306d2 Fix sysconf errno for unknown names.
The code (and comment) have been like this since the initial commit, but
there was never a test of this, and glibc seems to have been returning
EINVAL (as POSIX says it should) since long before Android existed.

Bug: http://b/31154352
Test: ran tests
Change-Id: Ica1ea836a4a5699ef0d956fe9c0f322e567de34d
2018-04-25 22:13:14 -07:00
Christopher Ferris
5ed15ba733 Remove ion.h from bionic uapi headers.
Bug: 77976082

Test: Ran the generate script and verified ion.h is deleted.
Change-Id: I33b3aeef66f08f35dd496a073931b2fe2c80a1d6
2018-04-24 13:33:30 -07:00
Evgeny Eltsin
47e41c8d24 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
(cherry picked from commit 4c9504aa6c)
2018-04-22 17:55:50 +02:00
Treehugger Robot
97ef43553a Merge "Revert "Add 64-bit slm optimized strlcpy and srlcat."" 2018-04-20 22:35:11 +00:00
Dan Albert
e219cefc17 Fix posix_memalign introduced tag.
Apparently this didn't make it to all android-16 devices. As far as
we know it did make it for all android-17 devices.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/647
Change-Id: I2f07cfb1254e2a203c1c10b91b0be46bf37ea853
2018-04-20 10:46:16 -07:00
Chih-Hung Hsieh
0e87940961 Disable lld, libc_malloc_debug failed to boot.
* Linker rules for lld do not work with libunwind_llvm yet.

Bug: 78118944
Test: make checkbuild and boot
Change-Id: I0eda2409d9f365029f70f4255edffbeae49cb6d2
2018-04-16 10:50:52 -07:00
Treehugger Robot
af0ad77af5 Merge "Bionic: Always use fortified versions of FD_X macros" 2018-04-16 15:34:14 +00:00
Treehugger Robot
9ee88bdbc7 Merge "Type of second __sched_cpucount should be "const cpu_set_t*"." 2018-04-14 01:27:28 +00:00
Andreas Gampe
00a6d5fe0a 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.

Bug: 77986327
Test: mmma bionic
Test: m
Test: bionic_unit_tests
Change-Id: I9096c6872770e46ba5ab64e7375ff83fc0518e07
2018-04-13 17:57:21 -07:00
Tong Shen
37793a1892 Type of second __sched_cpucount should be "const cpu_set_t*".
Test: none

Bug: 77341596
Change-Id: Ib4f1a75d2cfe147855b4d5f0203f4a64c22c116a
2018-04-13 16:07:21 -07:00
Dan Albert
da1994ced6 Add dlext.h to the libdl doc group.
Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/libdl
Bug: http://b/77236573
Change-Id: Ie09351ee961554488e34c79511712b07c345b8ad
2018-04-13 14:32:37 -07:00
Jeremy Compostella
611ad621c6 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.

Change-Id:  If90450de430ba9b7cd9282a422783beabd701f3d
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2018-04-12 14:00:43 -07:00
Elliott Hughes
5ad142157d Point to the NDK wrap.sh docs.
Bug: N/A
Test: N/A
Change-Id: Ic4c12a2ae43a6d733a23dcd2c901c2b6478eee97
2018-04-06 15:13:14 -07:00
Elliott Hughes
7dc7d2b7f2 Stop claiming that malloc debug is only usable on rooted devices.
Bug: N/A
Test: N/A
Change-Id: Ie9d753e7c2b6cc06e1c8e562970a000858f1072e
2018-04-06 14:44:49 -07:00
Elliott Hughes
46a943c833 Support getting/setting API level in static binaries.
Bug: http://b/27917272
Test: fixes static semaphore.sem_wait_no_EINTR_in_sdk_less_equal_than_23 test
Change-Id: Ifeeff20772ff0308aab9417d48671b604a3e9665
2018-04-03 21:53:29 -07:00
Christopher Ferris
4cdde64728 Merge "Refactor malloc debug." 2018-04-03 17:36:47 +00:00
Christopher Ferris
4da2503d70 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
2018-04-02 18:59:23 -07:00
Treehugger Robot
72d60a95fa Merge "Revert "Revert system seccomp filter changes"" 2018-04-02 23:43:50 +00:00
Ben Schwartz
27dd915147 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.
Change-Id: I5ef600e02a572d281441e890cc981614f150629b
2018-04-02 05:28:16 +00:00
Victor Hsieh
1afb40c9fe Revert "Revert system seccomp filter changes"
This reverts commit 040c28a023.

Reason for revert: reland since the actual problem has been fixed

Change-Id: Ifd8a85b0de2eb6f2a76a6458570fc03b020a90ab
Test: the apps in the bug no longer crashes.
Bug: 76461821
2018-03-30 16:48:36 +00:00
Victor Hsieh
e15233cc6b 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
2018-03-28 16:30:20 -07:00
Christopher Ferris
85f0542544 Merge "Use the ion.h from the kernel headers." 2018-03-28 19:18:52 +00:00
Victor Hsieh
040c28a023 Revert system seccomp filter changes
521b41 "Allow system processes to use vfork"
ed74ab "Move some syscalls in commmon whitelist to app"

An implementation bug actually assigns the system seccomp filter to all
processes after zygote forks.

Test: the apps in the bug no longer crashes.
Bug: 76461821
2018-03-27 13:43:24 -07:00
Tom Cherry
60fd72e8a3 Merge "Create PTHREAD_COND_INITIALIZER_MONOTONIC_NP" 2018-03-26 23:15:11 +00:00
Tom Cherry
f0f3d2f002 Create PTHREAD_COND_INITIALIZER_MONOTONIC_NP
Needed for std::condition_variable to wait on CLOCK_MONOTONIC.

Test: boot bullhead
Change-Id: I32a30817f0ec2190393fcc6faec45b40822cba32
2018-03-26 09:00:51 -07:00
Elliott Hughes
9724e93c19 Reject .so files using ELF TLS.
Bug: http://b/74361956
Test: ran tests
Change-Id: I53e71252eb08c607c2c436dcba433374c8c53887
2018-03-23 18:46:07 -07:00
Elliott Hughes
90234e5748 Merge "Fortify ppoll64." 2018-03-22 23:49:40 +00:00
Elliott Hughes
b83bf14a35 Fortify ppoll64.
I've deliberately not bothered with the GCC implementation because we'll
have removed GCC from the NDK before anyone gets to use this.

Bug: http://b/72493232
Test: ran tests
Change-Id: Icfc2a3b214739ab53aa41bacacc11b5c67498fb4
2018-03-22 13:59:02 -07:00
Treehugger Robot
1315e3ef85 Merge "libc: silence unsigned->signed warnings with ioctl" 2018-03-22 02:06:34 +00:00
Elliott Hughes
1423bb8498 Merge "timer_create: use SIG_SETMASK restore the signal mask." 2018-03-21 17:01:41 +00:00
Tom Cherry
861ff85a19 Merge "Add _monotonic_np versions of timed wait functions" 2018-03-21 15:29:02 +00:00
Tom Cherry
c6b5bcd182 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-20 18:41:22 -07:00
Ben Schwartz
e7190ce3f2 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

Change-Id: I153a259b0c07717f664ee268b43da867a9b42152
2018-03-21 01:01:29 +00:00
Elliott Hughes
48a69742fe timer_create: use SIG_SETMASK restore the signal mask.
Bug: http://b/73144101
Test: ran tests
Change-Id: I9adf3a512c120ef2280ad469ad11366222d61463
2018-03-20 17:58:11 -07:00
George Burgess IV
de45dcbbab libc: silence unsigned->signed warnings with ioctl
This also tweaks cdefs to make __overloadable usable outside of
FORTIFY. It had to be FORTIFY-only before we had unmarked overload
support in clang+Bionic.

Bug: https://github.com/android-ndk/ndk/issues/402
Test: Internal master builds + `mma`. `mma` in Bionic fails if the
change to ioctl is undone.

Change-Id: Ib386b1786e1dca625e6d5a18682005adc734d9c1
2018-03-20 15:59:46 -07:00
Treehugger Robot
7ba06d85f2 Merge "Remove -Wno-uninitialized for libc." 2018-03-16 20:17:34 +00:00
Narayan Kamath
5e3eb0d4e4 Merge "bionic_fortify: clarify error message for an out of bounds FD." 2018-03-16 10:09:38 +00:00
Yabin Cui
41328eb827 Merge "Check using destroyed mutexes." 2018-03-16 00:15:14 +00:00
Elliott Hughes
0b66dd4413 Remove -Wno-uninitialized for libc.
Bug: N/A
Test: builds
Change-Id: I79e66374b4eeba671705fdc7728f19f3a5c1fa64
2018-03-15 14:17:55 -07:00
Yabin Cui
9651fdf93a 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
2018-03-15 10:44:30 -07:00
Victor Khimenko
5956847acc 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
2018-03-14 17:42:15 +01:00
Narayan Kamath
38e960b7aa bionic_fortify: clarify error message for an out of bounds FD.
It seems clearer to include FD_SETSIZE in the message. set_size
is sizeof(fd_set) so there's an extra mental hoop to jump if that's
in the error message.

Test: make
Change-Id: I5cdb62465b658ac0eaeccbfb826d135820cf613a
2018-03-14 12:37:25 +00:00
Treehugger Robot
35e620cf98 Merge "Lay the groundwork for enabling EDNS0 in queries." 2018-03-13 20:48:34 +00:00
Erik Kline
391143e51b 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: 70694619
Bug: 72345192
Change-Id: I5a86cc5192e6cfa09c375ac9f5810102da3aba20
2018-03-12 16:34:56 +09:00
Treehugger Robot
860d27bd88 Merge "Allow system processes to use vfork" 2018-03-09 22:14:46 +00:00
Victor Hsieh
521b412aa1 Allow system processes to use vfork
java.lang.ProcessBuilder is internally using vfork in the current
configuration (see UNIXProcess_md.c in libcore).

Test: On an x86 Chromebook, trigger dropbox error event (1. settings
      put global logcat_for_system_app_anr 50; 2. kill -19 `pidof
      com.android.settings'; touch Settings).  Saw seccomp error in
      logcat but only without this fix.
Test: fyi, not reproducible on walleye (arm64)
Bug: 74441404

Change-Id: I1f40ae0fe0607c5834ecbe040ed31c4c0e42131d
2018-03-09 11:52:32 -08:00
Elliott Hughes
398c5ee6fc Merge "Call __fortify_fatal if printf sees %n." 2018-03-09 18:23:38 +00:00
Elliott Hughes
435e669776 Merge "Rewrite system(3) to use posix_spawn(3)." 2018-03-09 18:08:00 +00:00
Treehugger Robot
0a2060c090 Merge "Move some syscalls in commmon whitelist to app" 2018-03-07 23:14:25 +00:00
Elliott Hughes
41398d03b7 Call __fortify_fatal if printf sees %n.
We've ignored %n for a long time, but that's dangerous too because it
makes it unclear whether the corresponding pointer argument should be
supplied or not.

Remove the ambiguity by just rejecting %n outright.

Bug: http://b/31832608
Test: ran tests
Change-Id: Ic046ad3436a30c6f8f580ea738bdcaeb01c858f8
2018-03-07 13:32:58 -08:00
Jerry Zhang
832f4907f0 Merge "Sign extend offset for pwritev/preadv." 2018-03-07 01:28:26 +00:00
Jerry Zhang
f55dbc0516 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
Change-Id: Ie272601662c2c35b0e8d8fc3823c9063c2f73e64
2018-03-06 15:39:44 -08:00
Elliott Hughes
71ba5899ae Rewrite system(3) to use posix_spawn(3).
We saw crashes from pthread_exit+debuggerd on LP32
(https://issuetracker.google.com/72291624), and it seems like the
equivalent problem should exist with system(3). I fixed posix_spawn(3)
as part of that bug, so the easiest fix is probably to reuse that.

Bug: http://b/72470344
Test: ran tests
Change-Id: I05f838706f2b4a14ac3ee21292833e6c8579b0d4
2018-03-05 17:20:12 -08:00
Treehugger Robot
0a8d5f3eb8 Merge "clang-format local.h." 2018-03-02 08:23:34 +00:00
Elliott Hughes
3040a7a08c Merge "Merge stdio/local.h and stdio/wcio.h." 2018-03-02 03:48:53 +00:00
Elliott Hughes
9412cb3308 clang-format local.h.
Bug: N/A
Test: builds
Change-Id: I3b1b238eefc67e6d627dbd6820849522fd7d961b
2018-03-01 16:07:54 -08:00
Victor Hsieh
ed74abc8dc Move some syscalls in commmon whitelist to app
Test: system boots and basically runs
Bug: 63944145

Change-Id: I5cb080d13fb98a2106201037f3817f027912a8aa
2018-03-01 11:07:13 -08:00
Elliott Hughes
81baaf272c Add strptime %s.
Bug: https://issuetracker.google.com/37128336
Test: ran tests
Change-Id: I1a660dbdb5f008e42226f26489f0f01b6db18025
2018-02-28 16:29:40 -08:00
Elliott Hughes
5a98234c04 Merge stdio/local.h and stdio/wcio.h.
Bug: N/A
Test: ran tests
Change-Id: I683a1c45db0b880c73f8d190a46deeeab4cfef6e
2018-02-28 12:55:46 -08:00
Treehugger Robot
bf6c0c8eaf Merge "Reduce max DNS response from 64K to 8K" 2018-02-28 01:28:25 +00:00
Ben Schwartz
47fb0e826d Reduce max DNS response from 64K to 8K
No reasonable response is larger than about 4K, and this should reduce the ability of misbehaving DNS servers to waste system resources.

Test: Integration tests pass
Change-Id: I43da94f57f9b376d08a1b176e0aedb6720148833
2018-02-27 23:30:34 +00:00
Josh Gao
6fcba93b17 Filter out reserved signals in functions that take sigset_t.
Prevent processes from blocking libc-reserved signals by filtering them
out.

Bug: http://b/73144101
Test: 32/64-bit bionic-unit-tests-glibc
Test: 32/64-bit bionic-unit-tests on taimen
Change-Id: Ibadcaa7f668ed8be885cc61b67fb4b611fce8b17
2018-02-27 14:12:30 -08:00
Elliott Hughes
7ae39129e1 Move sigprocmask into its own file.
Otherwise clang inlines it into pthread_sigmask(3), which breaks libsigchain.

Bug: http://b/73344857
Test: ran tests, plus the app this broke
Change-Id: Ie4a1dc8f9c6ba58d1a2fa69aeff961c70b74767d
2018-02-26 16:59:37 -08:00
Christopher Ferris
038ef23f62 Use the ion.h from the kernel headers.
All code that needs to use the frozen version of ion.h header should
have a copy, so move to the version as parsed from the real headers.

Test: Compiled and boots.
Change-Id: If9feae9c163ca64c4862045e86611fd3cf1fc18e
2018-02-22 20:22:14 +00:00
Ryan Prichard
8f419579ed Reject exit-time destructors in libc
Test: m libc
Bug: b/73485611
Change-Id: Idc5da0f8a21e3f58fc68085577fa5fca40057276
2018-02-21 15:10:24 -08:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed.  This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.

Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2018-02-21 15:10:17 -08:00
Tom Cherry
44c7b6ad0a Merge changes Ibcd45e9b,I1ff5c0fa
* changes:
  Do not munmap in MmapFile::~MmapFile
  Build bionic/tests with cpp_std experimental.
2018-02-21 04:41:21 +00:00
Tom Cherry
5fe73268f3 Do not munmap in MmapFile::~MmapFile
Having any destructor with a global variable in bionic is causing
some issues. Since we don't actually need to munmap in this case, we
remove the destructor to work around that issue.

A small class is used to still munmap during tests.

Bug: 73485611
Test: bionic unit tests
Change-Id: Ibcd45e9b1ab22d187ecfc2738bb87244250d81ea
2018-02-20 16:02:13 -08:00
Tom Cherry
cb4d42173e Fix mmap leak in MmapFile
If the mmap'ed file doesn't end in a new line, previously we'd leak
the mmap'ed region.  This change now munmap's the region.

Test: unit tests
Change-Id: If28d3d9a6b1b9c54123beecb3bbbe8ed984ca81d
2018-02-20 15:50:04 -08:00
Treehugger Robot
d5172fced0 Merge "Add __fseterr." 2018-02-15 02:36:38 +00:00
Elliott Hughes
665ce210fa Merge "Add remaining _l function stubs." 2018-02-15 01:26:17 +00:00
Elliott Hughes
457852666c Add __fseterr.
Trivial, obvious counterpart to the standard ferror(3) and clearerr(3),
and lets us build bison out of the box.

Bug: http://b/64273806
Test: ran tests
Change-Id: I20affabddb71210051165c41e86adfe5ae04f77f
2018-02-14 15:25:21 -08:00
Elliott Hughes
38a78728c3 Merge "Add uc_sigmask64." 2018-02-14 21:24:11 +00:00
Elliott Hughes
3376c23dac Add remaining _l function stubs.
Bug: http://b/65595804
Test: ran tests
Change-Id: I3bea3af20b354d1f0d3e05fd35421a9045f29020
2018-02-13 23:14:12 -08:00
Elliott Hughes
23415fc60d Add uc_sigmask64.
Added to each ucontext_t for source compatibility between platforms where
sigset_t and sigset64_t differ (arm, x86) and where they're the same
(all the rest).

Bug: http://b/72493232
Test: ran tests
Change-Id: I65a37bfa177933701bbe6c2350448885fd0f9c43
2018-02-13 19:09:04 -08:00
Treehugger Robot
2d1e1011cf Merge "Switch the rest of our internal headers to #pragma once." 2018-02-14 02:53:37 +00:00
Elliott Hughes
cbc80ba9d8 Switch the rest of our internal headers to #pragma once.
We've been using #pragma once for new internal files, but let's be more bold.

Bug: N/A
Test: builds
Change-Id: I7e2ee2730043bd884f9571cdbd8b524043030c07
2018-02-13 14:27:17 -08:00
Christopher Ferris
db478a6274 Implement malloc hooks.
Use the malloc debug framework to implement the malloc debug hooks
since it can introduce a performance issue.

Also, modify the bionic/tests/utils.h slightly to dump an error message
when the exe failed.

Bug: 30561479

Test: Ran malloc hook unit tests.
Test: Ran malloc debug unit tests.
Test: Enabled malloc hooks and ran bionic unit tests and verified no
Test: unexpected failures.
Test: Enabled malloc debug and malloc hooks and verified malloc debug wins.
Test: Enabled malloc debug using env, property, and property with name
Test: still works.

Change-Id: Ib50046a0493c5c2050cf831befb812310bdcc249
(cherry picked from commit d6a1dc2379)
2018-02-13 13:37:30 -08:00
Elliott Hughes
25f17e48df Better backwards compatibility for stat64.
Caused problems for some Google source switching to unified headers
because the legacy headers just used #define instead.

Bug: http://b/73210428
Test: builds
Change-Id: If8a36f284031e57af419903610029a8c34a23d91
2018-02-12 15:48:01 -08:00
Treehugger Robot
919dd9dcb4 Merge "MIPS32: Make sigset64_t equal to sigset_t" 2018-02-12 18:49:12 +00:00
Tom Cherry
ab8c861597 Merge "Add ability to read /etc/passwd and /etc/group" 2018-02-12 16:27:20 +00:00
Goran Jakovljevic
379666996d MIPS32: Make sigset64_t equal to sigset_t
sigset_t is already large enough on mips so use the same principle
as on LP64 architectures: typedef sigset_t sigset64_t

Also prevent accessing sa_restorer field for architectures which
don't define SA_RESTORER in signal_test.

This allows compilation of signal_test.

Test: bionic-unit-tests in QEMU (MIPS32)
Change-Id: I965e202c9a7f7d109e4ec25ad87172dc7c1b8806
2018-02-12 09:03:10 +01:00
Treehugger Robot
4362da8076 Merge "Remove __overloadable/__RENAME_CLANG" 2018-02-10 02:30:37 +00:00
Treehugger Robot
5bf2c20f43 Merge "crtbegin: Correctly align ESP to 16 for __i386__" 2018-02-09 06:56:31 +00:00
Treehugger Robot
59a0a37b9d Merge "Add _FORCE_CRT_ATFORK config for crtbegin." 2018-02-09 05:41:31 +00:00
Ryan Prichard
a0d177d010 crtbegin: Correctly align ESP to 16 for __i386__
The (lowest) address of the argument area (aka ESP immediately prior to
the call instruction) must be aligned to 0 mod 16. Here, it is aligned to
12 mod 16.

From the SysV ABI doc (2.2.2 The Stack Frame)

"""The end of the input argument area shall be aligned on a 16 (32, if
__m256 is passed on stack) byte boundary. In other words, the value
(%esp + 4) is always a multiple of 16 (32) when control is transferred to
the function entry point."""

Test: extract code into a separate C file and verify stack alignment in a
  "start_main" function
Test: use the upcoming NDK r17-beta1 (with new Bionic crtbegin*.o files)
  with an M-23 x86 system image, check alignment in main (compiled with
  Clang not GCC, compiled w/o -mstackrealign)
Bug: b/73140672

Change-Id: Ia8d93fe5668d0a514a9fd22c40bf8362805111e6
2018-02-08 20:55:57 -08:00
Tom Cherry
6034ef85d8 Add ability to read /etc/passwd and /etc/group
Add the capability to read /etc/passwd and /etc/group for getpw* and
getgr* functions.

Bug: 27999086
Test: pwd, grp, grp_pwd_file unit tests
Test: Read in custom users/groups from /etc/{passwd,group}
Change-Id: Idc1f054af8a7ca34743a90493495f0ccc775a0d8
2018-02-08 12:38:57 -08:00
Treehugger Robot
aac0dd9891 Merge "Don't use SA_RESTORER if it is not defined" 2018-02-08 07:47:21 +00:00
Treehugger Robot
1a5737a48f Merge "Fix __gnu_Unwind_Find_exidx again." 2018-02-07 20:10:01 +00:00
Treehugger Robot
13dec2354d Merge "Add a few more legacy inlines for strto*_l." 2018-02-07 19:55:43 +00:00
Goran Jakovljevic
87c6aac6d2 Don't use SA_RESTORER if it is not defined
This is a follow up to I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8.
This fixes MIPS32 build.

Test: successful build and boot aosp_mips-eng
Change-Id: Ia5b245f5536d8fd037f1798bbdf6215c5f059045
2018-02-07 16:56:33 +01:00
Christopher Ferris
cae21a9b53 Add aligned_alloc to libc.
Bug: 72969374

Test: Bionic unit tests pass.
Test: Malloc debug unit tests pass.
Change-Id: I235985bbc638855d94249c97c98f14ab2924bda0
(cherry picked from commit d69ee59594)
2018-02-07 06:57:14 -08:00
Treehugger Robot
be6fbae74f Merge "Inline __libc_arc4random_has_unlimited_entropy." 2018-02-07 03:19:12 +00:00
Dan Albert
55ca56c27c Fix __gnu_Unwind_Find_exidx again.
The math on the size calculation was wrong as the type of
__exidx_start/__exidx_end was unsigned rather than a char. Make a
struct that represents each item instead and remove the division.

Test: built artifacts and used them in the NDK
Bug: None
Change-Id: Ic2c0c123a369b9319e8645d806d659290eb2f69c
2018-02-06 17:23:33 -08:00
Elliott Hughes
fe44c3cde0 Merge "Make sigaction consistent about SA_RESTORER and sa_restorer" 2018-02-06 23:41:46 +00:00
Elliott Hughes
c11fb66739 Inline __libc_arc4random_has_unlimited_entropy.
The name is misleading anyway.

Bug: http://b/67015565
Test: boots
Change-Id: Ic765e376d84e1ca474d3324eab32e14ea1ae9712
2018-02-06 15:35:15 -08:00
Dan Albert
4d4a7832ad Add a few more legacy inlines for strto*_l.
These three functions are the only reason we need libandroid_support
post-L. Add these so we can remove it entirely for LP64 or users
targeting L+.

Test: make checkbuild
Test: build/soong/scripts/build-ndk-prebuilts.sh
Test: Imported the prebuilts generated from the above to the NDK,
      `./checkbuild.py && ./run_tests.py` with a handful of patches
      to remove libandroid_support for L+.
Bug: None

Change-Id: I39f8ee686bd76ebdb2fc3745b013d56175ba8ff0
2018-02-06 13:45:29 -08:00
George Burgess IV
9024235005 Remove __overloadable/__RENAME_CLANG
Now that we have a clang that supports transparent overloads, we can
kill all of this cruft, and restore our upstream sources to their
untouched glory. Woohoo!

Bug: 12231437
Test: Built aosp_marlin; no obvious patch-related aosp_mips issues.
Change-Id: I520a19d014f12137f80e43f973dccd6711c571cd
2018-02-06 13:35:56 -08:00
Treehugger Robot
177429cb8d Merge "Improve the comment in the ARM setjmp.S." 2018-02-06 19:27:12 +00:00
Treehugger Robot
0f546f45d7 Merge "Run bpfmt manually." 2018-02-06 03:58:23 +00:00
Elliott Hughes
d50a1de565 Run bpfmt manually.
Bug: N/A
Test: builds
Change-Id: I0cf145c3b699ac8ef170a63366832f63a9cc1a91
2018-02-05 17:30:57 -08:00
Elliott Hughes
a325151da0 Merge "Rewrite getentropy." 2018-02-06 01:12:35 +00:00
Elliott Hughes
e58d49e76c Improve the comment in the ARM setjmp.S.
Based on code review comments for 460130b7d0.

Bug: N/A
Test: N/A
Change-Id: Ia86bc92dfe3f18261e06af33488a548ea9911b10
2018-02-05 13:36:02 -08:00
Elliott Hughes
733c1e4221 Avoid trademarks.
API levels are generally more useful anyway.

Bug: N/A
Test: N/A
Change-Id: Ie7bd69c3d0223c9bc8ed52c871b1d2d34373e2d0
2018-02-05 13:29:33 -08:00
Evgeny Eltsin
11f6076410 Make sigaction consistent about SA_RESTORER and sa_restorer
Bug: http://b/72493232
Test: bionic-unit-tests --gtest_filter=*signal.sigaction*
Change-Id: Ia9fceb478498d09c8f2f6222d6a81725e1f6eb23
2018-02-05 22:08:25 +01:00
Elliott Hughes
211c4d35f2 Rewrite getentropy.
The error handling was a mess, resulting in an infinite loop
(and a test timeout) if you actually took the /dev/urandom
fallback. I'm also unconvinced that the getrandom(2) path was correct
because of the various reasons why we might get a short count back
(http://man7.org/linux/man-pages/man2/getrandom.2.html). In this version,
the two paths look very similar except for the getrandom(2) failure case,
where it's now much clearer that we just give up so that we can boot
(http://b/33059407).

Bug: http://b/33059407
Bug: http://b/67015565
Test: ran tests on hikey and a ICS Galaxy Nexus
Change-Id: Ie715d59b46f7a70bae66943c316168838787b40d
2018-02-05 12:57:22 -08:00
Ben Schwartz
6eed8e1bb6 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
Test: Added integration tests for fallback to the netd suite.
Change-Id: Ic64bed0754e1d529dc0c0ab6a5e2f1ea201ff0d5
2018-02-05 14:41:01 -05:00
Yabin Cui
a026108ec1 Merge "Avoid abort when calling pthread_mutex_destroy more than once." 2018-02-03 02:03:47 +00:00
Yabin Cui
2dec3d7021 Avoid abort when calling pthread_mutex_destroy more than once.
Bug: http://b/72878088
Test: run bionic-unit-tests.
Change-Id: I0c3a6c5a625d187d5f32ec8c821cfdd5e807a671
2018-02-02 15:45:24 -08:00
Yabin Cui
b82dcc6fa7 Merge "Support priority inheritance mutex in 32-bit programs." 2018-02-02 19:44:51 +00:00
Elliott Hughes
ed95f37bc8 Merge "Add struct sigaction64 and sigaction64." 2018-02-02 17:11:20 +00:00
Christopher Ferris
86a7806c9e Merge "Update to v4.15 kernel headers." 2018-02-02 14:42:19 +00:00
Yabin Cui
5a00ba7c1c Support priority inheritance mutex in 32-bit programs.
Add fast path calling PIMutexTryLock() in pthread_mutex_lock.
Add trace for pi mutex waiting.

Bug: http://b/29177606
Test: run bionic-unit-tests.
Test: run bionic-benchmarks.

Change-Id: I30b6436692d5ea6b63ca9905df745edb843b5528
2018-02-01 16:01:46 -08:00
Elliott Hughes
3e235911c9 Add struct sigaction64 and sigaction64.
Bug: http://b/72493232
Test: ran tests
Change-Id: I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8
2018-02-01 14:45:15 -08:00
Christopher Ferris
934ec94955 Update to v4.15 kernel headers.
Test: Compiles, boots bullhead/hikey960.
Change-Id: I118beb8b6cac0881b1270f9bf6981959297a41a8
2018-02-01 10:51:01 -08:00
Bowgo Tsai
a9fc82fefe Renames nonplat_property_contexts to vendor_property_contexts
Bug: 64240127
Test: build
Change-Id: Ifff956fa1a0557d7d10e1012b29d16f25bb80e8f
2018-02-01 23:32:24 +08:00
Elliott Hughes
460130b7d0 Fix sigsetjmp/siglongjmp to save/restore RT signals on arm/x86 too.
Our arm and x86 ABIs shipped with a 32-bit `sigset_t`, so we need to
use sigprocmask64 to save/restore the RT signals too. (This is important
because several are in use by the system, and the behavior of our 32-bit
`sigset_t` is to clear the RT signals.)

Bug: http://b/72493232
Test: ran tests
Change-Id: Idff91f8b2849276e5a3073d07eccd84e02a34410
2018-01-31 17:47:16 -08:00
Elliott Hughes
5905d6f879 Add sigset64_t and accompanying functions.
This doesn't address `struct sigaction` and `sigaction`. That will
come later.

Bug: http://b/72493232
Test: ran tests
Change-Id: I4134346757ce3a4dac6feae413361cec16223386
2018-01-30 18:47:16 -08:00
Elliott Hughes
cc0fe6e8c0 The future is now (2018 edition).
Bug: N/A
Test: builds
Change-Id: Ic638e5b1f4e5901885fe7bc60b2a265817636b21
2018-01-30 08:54:12 -08:00
Treehugger Robot
4cd3550d50 Merge "Move static variable out of should_trace()." 2018-01-30 01:17:47 +00:00
Elliott Hughes
7ebafb365a Use sigprocmask rather than sigblock/sigsetmask.
No effect right now, because sigprocmask on LP32 also only touches
the non-RT signals, but this makes it easier to switch to __rt_sigprocmask.

Bug: http://b/72460436
Test: ran tests
Change-Id: I693f0ea36701e9ab5d10e6aefb26387ba45a6064
2018-01-29 10:23:01 -08:00
Elliott Hughes
6dafb4ac78 Move all the short <signal.h> functions together.
Bug: N/A
Test: ran tests
Change-Id: Ie5509e4108efcd5d403227ce99bef2b61c79f757
2018-01-26 17:47:56 -08:00
Treehugger Robot
2e2a8930e5 Merge "linker: simpler encoding for SHT_RELR sections." 2018-01-27 00:00:17 +00:00
Treehugger Robot
97d1c75ca5 Merge "Better handling of sigset_t on LP32." 2018-01-26 23:07:49 +00:00
Elliott Hughes
4b1c6e7385 Better handling of sigset_t on LP32.
The main motivation here is that the sigprocmask in pthread_exit wasn't
actually blocking the real-time signals, and debuggerd (amongst other
things) is using them. I wasn't able to write a test that actually won
that race but I did write an equivalent one for posix_spawn.

This also fixes all the uses of sigset_t where the sigset_t isn't
exposed to the outside (which we can't easily fix because it would be
an ABI change).

Bug: https://issuetracker.google.com/72291624
Test: ran tests
Change-Id: Ib6eebebc5a7b0150079f1cb79593247917dcf750
2018-01-26 13:04:57 -08:00
Rahul Chaudhry
f16b65932b linker: simpler encoding for SHT_RELR sections.
This change modifies the encoding used in SHT_RELR sections to a simpler
version that gives better results. This encoding was suggested by Andrew
Grieve and is described in this post on generic-abi@googlegroups.com:
    https://groups.google.com/d/msg/generic-abi/bX460iggiKg/Pi9aSwwABgAJ

Bug: None
Test: Built image for marlin, flashed on device, ran arm and
      aarch64 binaries containing '.relr.dyn' sections using
      the new encoding.

Change-Id: I266affe0fbad91dc375995985a221cb02499447b
2018-01-26 11:46:47 -08:00
Chih-hung Hsieh
c6ea39d33b Merge "Use __BIONIC_FORTIFY_VARIADIC for variadic functions." 2018-01-26 17:08:26 +00:00
Elliott Hughes
4debf20829 Merge "Make the <android/dlext.h> docs show up on the web." 2018-01-26 16:06:54 +00:00
Elliott Hughes
c9cd4eb163 Merge "<sys/ioctl.h> shouldn't pollute the namespace as much." 2018-01-26 16:05:24 +00:00
Wei Li
2cb5f7f578 Move static variable out of should_trace().
Static variable initialization calls pthread_mutex_lock() and may lead to
deadlock if should_trace() is called in pthread_mutex_lock context.

Here is a stack of blocked init process:
__cxa_guard_acquire ->
should_trace        ->
bionic_trace_begin  ->
__pthread_mutex_lock_with_timeout ->
__cxa_guard_release ->
should_trace        ->
bionic_trace_begin  ->
__pthread_mutex_lock_with_timeout ->
mutex::lock        ->
LogMessage::~LogMessage
......
So we need to move it out

Test: 1 Compiled and booted.
      2 Reboot pressure test for more than 30000 times.

Change-Id: I8d97745161f1aa8942b63338208ea74830768ae1
Signed-off-by: Wei Li <sirius.liwei@huawei.com>
Signed-off-by: Jinguang Dong <dongjinguang@huawei.com>
2018-01-26 17:01:55 +08:00
Elliott Hughes
5f6d1a59a8 <sys/ioctl.h> shouldn't pollute the namespace as much.
The history has no motivation for <asm/termbits.h>, and other C libraries
don't seem to include any of the extra types and constants that gains us.

This caused problems building FFMPEG, which defines its own B0.

Bug: https://github.com/android-ndk/ndk/issues/630
Test: builds
Change-Id: If032b9fa7860777c13f7bd8e68fb78ff606dcd94
2018-01-25 22:21:25 -08:00
Chih-Hung Hsieh
f81abef148 Use __BIONIC_FORTIFY_VARIADIC for variadic functions.
* Variadic functions usually cannot be inlined.
* Do not use misleading __always_inline attribute,
  and also avoid early clang 7.0 compiler bug.

Bug: 72412382
Test: build and boot aosp*-eng in emulator
Change-Id: I7490976166581abc626f397ad408581ada0ed308
2018-01-25 17:54:50 -08:00
Elliott Hughes
5046e5fe87 Make the <android/dlext.h> docs show up on the web.
Just enough doxygen so that
https://developer.android.com/ndk/reference/dlext_8h.html won't be completely
devoid of all this.

Bug: N/A
Test: ran doxygen manually
Change-Id: I1e0667feae93227e32c1bd671065359f5be85d9d
2018-01-25 15:48:32 -08:00
Yabin Cui
25ac4476d8 Merge "Support priority inheritance mutex in 64bit programs." 2018-01-25 23:43:25 +00:00
Treehugger Robot
4a2407b3a1 Merge "Fix __gnu_Unwind_Find_exidx for static executables." 2018-01-25 22:53:44 +00:00
Dan Albert
aeb5bc658f Fix __gnu_Unwind_Find_exidx for static executables.
__exidx_start and __exidx_end are not actual values to be read, just
symbols placed before and after .ARM.exidx.

The default linker script for ARM static executables includes these
lines:

    __exidx_start = .;
   .ARM.exidx   : { *(.ARM.exidx*) }
    __exidx_end = .;

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474c/BABEHEDA.html

Test: used __gnu_Unwind_Find_exidx in a static executable and showed
      non-bogus values
Test: verified that this fixes #593 in the NDK
Bug: https://github.com/android-ndk/ndk/issues/593
Change-Id: Ib35a4b6c82920666ae8a45aa0a2d43e458699b51
2018-01-25 12:48:57 -08:00
Dan Albert
3e4d4d4cf2 Add _FORCE_CRT_ATFORK config for crtbegin.
libc.a is always the latest library regardless of target API level.

Test: treehugger
Bug: None
Change-Id: I844dc85a9283693b01d0fbdc26854bde82c750dc
2018-01-24 22:36:31 -08:00
Dan Albert
586b6761d0 Partial revert of "Remove obsolete __stack_chk_fail_local."
These sources are going to be used for the NDK as well, and the NDK
still uses GCC.

This partially reverts commit
4af220cfef. That commit also removed
this symbol from the linker's crtbegin (it has its own). That is
still only built with Clang, so we don't need to revert that part.

Test: treehugger
Bug: None
Change-Id: Iba231baf298e228135bdf48dfed87f9089975eb1
2018-01-24 16:37:48 -08:00
Dan Albert
2e2c72d61f Pre-M and GCC compatibility for crtbegin.
We're going to start using the bionic sources for the NDK CRT
objects, so we need to avoid using symbols that weren't around in
early versions of Android. The NDK is currently building the CRT
objects with GCC as well (there were some segfaults that have yet to
be diagnosed), so move `__used` to the GCC compatible location.

Test: treehugger
Bug: None
Change-Id: I1f5c23eafadc2e3bc0b84bc3305f79a04d35c7d8
2018-01-24 16:37:48 -08:00
Yabin Cui
6b9c85b36d Support priority inheritance mutex in 64bit programs.
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
2018-01-24 16:11:07 -08:00
Elliott Hughes
73871ad09b Merge "Deprecate readdir_r." 2018-01-23 21:51:22 +00:00
Treehugger Robot
6ea80375e6 Merge "Block bunch of privileged syscalls to apps" 2018-01-23 17:54:30 +00:00
Victor Hsieh
2f23ceda44 Block bunch of privileged syscalls to apps
Test: build, run some app
Bug: 63944145
Change-Id: I13eb56f923732e110851dec02eaa11f6cb44535c
2018-01-22 22:30:17 -08:00
Elliott Hughes
f19af37b5e Deprecate readdir_r.
I've been campaigning against readdir_r for years:

  http://elliotth.blogspot.com/2012/10/how-not-to-use-readdirr3.html

and glibc deprecated it in 2.24, so we should join the club.

Bug: http://b/32678321
Test: builds
Change-Id: Ie3887ed75989aced9324266aa3b93e85c11bdbc9
2018-01-22 17:15:25 -08:00
Elliott Hughes
d00d38b36b Merge "linker: add experimental support for SHT_RELR sections." 2018-01-23 00:24:26 +00:00
Rahul Chaudhry
b7feec7454 linker: add experimental support for SHT_RELR sections.
This change adds experimental support for SHT_RELR sections, proposed
here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg

Definitions for the new ELF section type and dynamic array tags, as well
as the encoding used in the new section are all under discussion and are
subject to change. Use with caution!

Bug: None
Test: Built image for marlin, flashed on device, ran arm and
      aarch64 binaries containing '.relr.dyn' sections.

Change-Id: I2953ae932d3c42ae394e71f8fa058013758a1778
2018-01-22 12:41:27 -08:00
Dan Albert
40f15ec4b1 Package bionic static libraries in the NDK.
Test: build/soong/scripts/build-ndk-prebuilts.sh
Bug: https://github.com/android-ndk/ndk/issues/272
Change-Id: Ibb21d799fdcf230ed45db0b809e20dd86d2d8e52
2018-01-22 12:40:56 -08:00
Dan Albert
8583d5a766 Include what we use.
Test: mma
Bug: None
Change-Id: I88a23673fdad3babaaef89acd7e369419dc1ee3a
2018-01-22 12:20:16 -08:00
Treehugger Robot
c728aa3127 Merge "Reland "Cleanup transitive includes in the legacy inlines."" 2018-01-22 19:32:23 +00:00
Treehugger Robot
e5fbd983cb Merge "Address a bunch of clang-tidy complaints." 2018-01-20 18:15:12 +00:00
Elliott Hughes
3048a36a34 Simplify CT_CCL and CT_STRING inner loop.
Makes no difference to the benchmarks, but does make the code a bit
more readable.

Bug: http://b/68672236
Test: ran tests, benchmarks
Change-Id: I63fa5f78d077c86e4f4f194f2c76ab5510c29109
2018-01-19 17:58:07 -08:00
Treehugger Robot
2b66844a0b Merge "Support %mc/%ms/%m[ in sscanf." 2018-01-20 01:17:25 +00:00
Elliott Hughes
5cec377f49 Address a bunch of clang-tidy complaints.
There were a bunch more unreasonable/incorrect ones, but these ones
seemed legit. Nothing very interesting, though.

Bug: N/A
Test: ran tests, benchmarks
Change-Id: If66971194d4a7b4bf6d0251bedb88e8cdc88a76f
2018-01-19 15:56:12 -08:00
Elliott Hughes
38e4aefe6c Support %mc/%ms/%m[ in sscanf.
Also support the "long" (wchar_t) variants.

Bug: http://b/68672236
Test: ran tests
Change-Id: I060e98b4d2feb61e12986d9d51e4710b2b1d9724
2018-01-19 14:53:55 -08:00
Treehugger Robot
df4c92888e Merge "Fixing app compat issue b/72143978" 2018-01-19 02:38:33 +00:00
Treehugger Robot
0dac05642e Merge "Add bpf syscall to seccomp whitelist" 2018-01-19 01:59:05 +00:00
Ian Pedowitz
b6310c2aa7 Fixing app compat issue b/72143978
This is a squash revert of a4a4854 and 1b0f2b4

  Revert "Remove a test for backwards compatibility we no longer support."

  This reverts commit a4a485454a.

  # This is the commit message #2:

  Revert "Remove obsolete workaround."

  This reverts commit 1b0f2b49d5.

Bug: 72143978
Bug: 24465209
Test: Tested failing case on sailfish, reverted back all CL's since
Test: 3471433 for b/24465209 and apps open
2018-01-18 16:26:45 -08:00
Dan Albert
989d804859 Reland "Cleanup transitive includes in the legacy inlines."
This reverts commit 54c71521b5.

Bug: None
Test: make checkbuild
Change-Id: Ica6a4f7ecadfcc854160a60a5db1b44ae3b6c821
2018-01-18 23:39:48 +00:00
Treehugger Robot
ee88e76f14 Merge "Deprecate set_seccomp_filter" 2018-01-18 20:37:24 +00:00
Chenbo Feng
60f3ed41a3 Add bpf syscall to seccomp whitelist
The netd service and system server will use bpf syscalls to get network
stats information when kernel supported. And the syscall from system
server will need seccomp permission to run it.

Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Bug: 30950746
Change-Id: I01c46f243dca0933a44cbfd3148f9e4748f9bc99
2018-01-18 12:08:34 -08:00
Joachim Sauer
62cb397383 Merge "Revert "Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines."""""" 2018-01-18 11:38:44 +00:00
Joachim Sauer
54c71521b5 Revert "Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines."""""
This reverts commit a074ac79d7.

Reason for revert: Broke several builds.

Change-Id: I406f0b0aa0c37961ad031d2f6c5ea4241f3f1111
2018-01-18 11:37:34 +00:00
Treehugger Robot
8e81d9751e Merge "Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines.""""" 2018-01-18 02:31:25 +00:00