Commit graph

24994 commits

Author SHA1 Message Date
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
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
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
Christopher Ferris
ca092c29a4 Merge "malloc debug: reset FreeTrackData mutex after fork" 2018-01-18 02:28:51 +00:00
Victor Hsieh
52d4c3a53e Deprecate set_seccomp_filter
Test: build
Bug: 63944145
Change-Id: Ifbef2727844cd46eb1f933ed89141186f50e1a1b
2018-01-17 16:44:17 -08:00
Treehugger Robot
0d63a3c233 Merge "Do not set PR_SET_NO_NEW_PRIVS when install seccomp filter" 2018-01-16 17:33:31 +00:00
Denis Hsu
1a8106ec1a malloc debug: reset FreeTrackData mutex after fork
Lock the FreeTrackData mutex during fork and reset it in the child.
Ensures that the FreeTrackData is consistent when forking from a
multi-threaded process, and that the mutex is in a defined state
in the child.

Test: 89hours MTBF test
Change-Id: I5e5892832a733ea85727ec65abc7094d95a725ef
2018-01-16 17:43:53 +08:00
Victor Hsieh
dab45ad936 Do not set PR_SET_NO_NEW_PRIVS when install seccomp filter
Setting PR_SET_NO_NEW_PRIVS actually breaks SELinux domain transition
(of debuggerd, for example). Do not set the bit when install the filter.
Instead, the caller must either have done it, or have CAP_SYS_ADMIN.

Test: build
Bug: 63944145
Bug: 71859146
Change-Id: I2af334fed61cac03fd0b3b5c8866e2e72b31cf17
2018-01-15 11:37:49 -08:00
Elliott Hughes
d16b09a4d2 Merge "Clean up the time(2) implementation." 2018-01-13 17:05:57 +00:00
Elliott Hughes
293d4633af Merge "Remove a test for backwards compatibility we no longer support." 2018-01-13 02:17:52 +00:00
Elliott Hughes
a4a485454a Remove a test for backwards compatibility we no longer support.
Bug: http://b/24465209
Test: ran tests
Change-Id: I80bb86379f108d88a6f4abb031450d13ac87c7b9
2018-01-12 15:27:48 -08:00
Elliott Hughes
f1515f6408 Clean up the time(2) implementation.
This is also slightly faster for the no VDSO case (56ns vs 66ns).

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I2b0edd06ee6942eb57c32678279278a53ca5ee9b
2018-01-12 15:20:28 -08:00
Dan Albert
a074ac79d7 Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines.""""
This reverts commit b37e9aa9a6.

Reason for revert: trying again
Test: make native
Change-Id: Ide23f0a752fd6ca88e44449e996eb5809db6712d
2018-01-11 09:43:23 -08:00
Treehugger Robot
25a3087d6d Merge "bionic: add vdso time()" 2018-01-11 15:46:18 +00:00
Mark Salyzyn
4473ccd5b0 bionic: add vdso time()
time() can be a hot call, and it currently uses __vdso_gettimeofday,
which is already pretty fast (~3 times faster than the syscall),
but with a __vdso_time call it is ~3 times even faster, in part
because __vdso_time does not require interlocking with updates,
and the read for just the seconds is atomic.  __vdso_time is
always available, whereas __vdso_gettimeofday is gated on access
to the physical timers.  arm improvement is compelling (x10),
x86 improvement is even more pronounced (x100).

[TL;DR]

w/vdso32 kernel patches, locked cores to MAX, little cores only.

BEFORE:

hikey960 vdso (aarch64):

----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
BM_time_clock_gettime                  48 ns         48 ns   15414753
BM_time_clock_gettime_syscall         175 ns        175 ns    4062031
BM_time_clock_gettime_REALTIME         44 ns         44 ns   15897875
BM_time_clock_gettime_BOOTTIME         47 ns         47 ns   14307903
BM_time_clock_gettime_TAI             210 ns        210 ns    3341372
BM_time_clock_gettime_unsupported     100 ns        100 ns    7030649
BM_time_gettimeofday                   47 ns         47 ns   14969643
BM_time_gettimeofday_syscall          163 ns        163 ns    4283542
BM_time_time                           59 ns         59 ns   11815385

hikey960 vdso32 (aarch32):

----------------------------------------------------------------------
Benchmark                               Time           CPU Iterations
----------------------------------------------------------------------
BM_time_clock_gettime                  90 ns         90 ns    7572898
BM_time_clock_gettime_syscall         251 ns        251 ns    2763442
BM_time_clock_gettime_REALTIME         81 ns         80 ns    8699536
BM_time_clock_gettime_BOOTTIME         97 ns         97 ns    7256667
BM_time_clock_gettime_TAI             272 ns        272 ns    2570419
BM_time_clock_gettime_unsupported     160 ns        160 ns    4379819
BM_time_gettimeofday                   73 ns         73 ns    9608922
BM_time_gettimeofday_syscall          200 ns        199 ns    3527957
BM_time_time                          123 ns        123 ns    5651095

x86_64 (glibc):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                  21 ns         21 ns   28873070
BM_time_clock_gettime_syscall         224 ns        224 ns    3095370
BM_time_clock_gettime_REALTIME         17 ns         17 ns   42083086
BM_time_clock_gettime_BOOTTIME        239 ns        239 ns    2924015
BM_time_clock_gettime_TAI             236 ns        236 ns    2961423
BM_time_clock_gettime_unsupported     221 ns        221 ns    3357696
BM_time_gettimeofday                 22 ns         22 ns   27975154
BM_time_gettimeofday_syscall        238 ns        238 ns    2882032
BM_time_time                          2 ns          2 ns  340354885
BM_time_time_syscall                207 ns        207 ns    3383073

imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a):
(virtual timers)

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                     20        477    1489362
BM_time_clock_gettime_syscall             20        487    1458333
BM_time_clock_gettime_REALTIME            19        464    1400000
BM_time_clock_gettime_BOOTTIME            29        700    1000000
BM_time_clock_gettime_TAI                 29        690    1000000
BM_time_clock_gettime_unsupported          9        227    3043478
BM_time_gettimeofday                      18        444    1555556
BM_time_gettimeofday_syscall              19        456    1555556
BM_time_time                              21        497    1166667

imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a):
(physical timers)

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                      6        144    4666667
BM_time_clock_gettime_syscall             20        486    1400000
BM_time_clock_gettime_REALTIME             6        136    5000000
BM_time_clock_gettime_BOOTTIME             6        153    4375000
BM_time_clock_gettime_TAI                 31        760    1000000
BM_time_clock_gettime_unsupported         10        233    3043478
BM_time_gettimeofday                       6        140    5000000
BM_time_gettimeofday_syscall              19        450    1555556
BM_time_time                               9        203    3500000

AFTER:

hikey960 vdso (aarch64):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                48 ns         48 ns   15414753
BM_time_clock_gettime_syscall       175 ns        175 ns    4062031
BM_time_clock_gettime_REALTIME       44 ns         44 ns   15897875
BM_time_clock_gettime_BOOTTIME       47 ns         47 ns   14307903
BM_time_clock_gettime_TAI           210 ns        210 ns    3341372
BM_time_clock_gettime_unsupported   100 ns        100 ns    7030649
BM_time_gettimeofday                 47 ns         47 ns   14975314
BM_time_gettimeofday_syscall        164 ns        164 ns    4278797
BM_time_time                         16 ns         16 ns   42932165

hikey960 vdso32 (aarch32):

--------------------------------------------------------------------
Benchmark                             Time           CPU Iterations
--------------------------------------------------------------------
BM_time_clock_gettime                90 ns         90 ns    7572898
BM_time_clock_gettime_syscall       251 ns        251 ns    2763442
BM_time_clock_gettime_REALTIME       81 ns         80 ns    8699536
BM_time_clock_gettime_BOOTTIME       97 ns         97 ns    7256667
BM_time_clock_gettime_TAI           272 ns        272 ns    2570419
BM_time_clock_gettime_unsupported   160 ns        160 ns    4379819
BM_time_gettimeofday                 73 ns         73 ns    9596230
BM_time_gettimeofday_syscall        199 ns        199 ns    3575428
BM_time_time                         35 ns         35 ns   19798801

imx7d_pico IOT nyc (w/arm,cpu-registers-not-fw-configured) (armv7a):

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                     20        477    1489362
BM_time_clock_gettime_syscall             20        487    1458333
BM_time_clock_gettime_REALTIME            19        464    1400000
BM_time_clock_gettime_BOOTTIME            29        700    1000000
BM_time_clock_gettime_TAI                 29        690    1000000
BM_time_clock_gettime_unsupported          9        227    3043478
BM_time_gettimeofday                      18        444    1555556
BM_time_gettimeofday_syscall              19        456    1555556
BM_time_time                               2         50   11666667

imx7d_pico IOT nyc (wo/arm,cpu-registers-not-fw-configured) (armv7a):

Benchmark                           Time(ns)    CPU(ns) Iterations
------------------------------------------------------------------
BM_time_clock_gettime                      6        144    4666667
BM_time_clock_gettime_syscall             20        486    1400000
BM_time_clock_gettime_REALTIME             6        136    5000000
BM_time_clock_gettime_BOOTTIME             6        153    4375000
BM_time_clock_gettime_TAI                 31        760    1000000
BM_time_clock_gettime_unsupported         10        233    3043478
BM_time_gettimeofday                       6        140    5000000
BM_time_gettimeofday_syscall              19        450    1555556
BM_time_time                               2         50   10000000

Test: bionic-unit-tests --gtest_filter=time.time
      taskset F bionic-benchmarks --bionic_xml=vdso.xml \
          --benchmark_filter='BM_time_(time*|clock_gettime*|gettimeofday*)'
Bug: 63737556
Change-Id: I81b088a12ca41a6c4733d46c5477527777138efa
2018-01-11 15:46:11 +00:00
Treehugger Robot
b1e90d29ac Merge "Remove obsolete workaround." 2018-01-11 04:45:24 +00:00
Treehugger Robot
39ee5a4b47 Merge "Adapt to the new libc++/libc++abi update." 2018-01-11 04:29:33 +00:00
Elliott Hughes
1b0f2b49d5 Remove obsolete workaround.
Bug: http://b/24465209
Test: manually ran the app.
Change-Id: I1e2a498864c74ff3a9886b97f7dc60ad7f6dfa44
2018-01-10 11:05:19 -08:00
Dimitry Ivanov
a238a9a328 Merge "Fix dlclose for libraries with thread_local dtors" 2018-01-10 13:50:01 +00:00
dimitry
06016f226e Fix dlclose for libraries with thread_local dtors
Introduce new flag to mark soinfo as TLS_NODELETE when
there are thread_local dtors associated with dso_handle
belonging to it.

Test: bionic-unit-tests --gtest_filter=dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Bug: https://github.com/android-ndk/ndk/issues/360
Change-Id: I724ef89fc899788f95c47e6372c38b3313f18fed
2018-01-10 10:24:06 +01:00
Dimitry Ivanov
41971399cf Merge changes I23bec365,I55645cc0,I38a246c8
* changes:
  Make ld-android.so export linker symbols
  Move ld-android.so build under linker/
  Unhardcode linker soname
2018-01-10 07:18:16 +00:00
Christopher Ferris
f0705fabb0 Merge "Remove workaround for running property tests." 2018-01-09 15:26:09 +00:00
dimitry
581723ebc7 Make ld-android.so export linker symbols
ld-android.so exports exact same set of symbols
as linker. Since it is not supposed to be loaded
every symbol points to fail() method.

Test: make
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I23bec365b302ce4ddf5f08832e665ae2b181cf8a
2018-01-09 11:27:23 +01:00
dimitry
11da1dcd8c Move ld-android.so build under linker/
This will allow us to apply linker's version script to the "fake"
version of ld-android.so.

Test: make
Change-Id: I55645cc0fc90e6c65e2269ba2340a908aeed1eaa
2018-01-09 11:13:40 +01:00
dimitry
8e8c2c0013 Unhardcode linker soname
Set and use DT_SONAME instead.

Test: bionic-unit-tests
Change-Id: I38a246c8a43664792424e8fef96ae2ff5f743ba6
2018-01-09 11:11:46 +01:00
Treehugger Robot
91c88ae54c Merge "Expose kernel input headers for toolbox" 2018-01-09 06:01:26 +00:00
Treehugger Robot
4a7c51a885 Merge "Mark abs/labs/llabs as 19+ rather than 21+" 2018-01-09 05:42:16 +00:00
Ryan Prichard
51a7fe8fbd Mark abs/labs/llabs as 19+ rather than 21+
The libc.map.txt file already defines these three functions as having
been introduced in API 19, but these header files had declared them as
21 and up.

See https://android-review.googlesource.com/c/platform/development/+/233407

imaxabs is already declared as 19 and up.

Test: build-ndk-prebuilts.sh && ./update_platform.py &&
  checkbuild.py && run_tests.py
Test: manually build app against 18 and 19

Change-Id: Iaeed48d7e6c438d816635a0433a056e557e8ebc2
2018-01-08 17:46:27 -08:00
Christopher Ferris
4c5fde0e5e Remove workaround for running property tests.
Also fix the tests for some missing benchmarks that have been
added recently.

Test: Ran bionic benchmarks tests and all pass.
Test: Ran bionic benchmarks to verify that there are no crashes.
Change-Id: I8501553e8a229c0c6ea81e894e91ac2f5f2fe26c
2018-01-08 16:13:14 -08:00
Dan Albert
4d1cc9df11 Adapt to the new libc++/libc++abi update.
C++17 removed a handful of things that are used in the libclang
headers, which are used by the versioner. Enable the flag that
re-exposes these until we have a C++17 compatible libclang.

Add a stub posix_memalign to the linker. libc++abi uses posix_memalign
when allocating exceptions, which the linker does not use.

Test: make checkbuild
Bug: None
Change-Id: I32f9d0591ef99a610f27efed90a5c9fd150f0d3e
2018-01-08 14:44:42 -08:00
Dan Willemsen
ca056d742f Expose kernel input headers for toolbox
Toolbox is moving to Android.bp, and its genrule needs access to these
kernel headers.

Test: mmma system/core/toolbox
Change-Id: I213a36e1f4bb5d4e3e3e105ed7ab01ec945014a2
2018-01-08 14:00:24 -08:00
Treehugger Robot
f9fcb1efae Merge "Fix typo in README.md for malloc_debug" 2018-01-08 21:11:24 +00:00
Treehugger Robot
035f4b6e30 Merge "Split zygote's seccomp filter into two" 2018-01-08 20:15:16 +00:00
Yi Kong
37e8b00ee0 Merge "Fix complex number printing rules" 2018-01-06 04:27:00 +00:00
Yi Kong
43ccab85ff Fix complex number printing rules
Prettifies the complex number debug printing and workaround Clang's
implicit complex to real casting bug.

Bug: 71638783
Test: mma
Change-Id: I0482044ade136fa4cc44aaa0bb515061b40e1f76
2018-01-05 16:26:38 -08:00
Victor Hsieh
4f02dd5755 Split zygote's seccomp filter into two
To pave the way to reducing app's kernel attack surface, this change
split the single filter into one for system and one for apps.  Note that
there is current no change between them.

Zygote will apply these filters appropriately to system server and apps.

Keep set_seccomp_filter() for now until the caller has switched to the
new API, which I will do immediately after this before the two filters
diverse.

Also remove get_seccomp_filter() since it doesn't seem to be used
anyway.

Test: diff the generated code, no difference except the variable names
Test: cts -m CtsSecurityTestCases -t android.security.cts.SeccompTest
Bug: 63944145

Change-Id: Id8ba05a87332c92ec697926af77bc5742eb04b23
2018-01-04 12:28:40 -08:00
Mikhail Naganov
5a1a9533fe Fix typo in README.md for malloc_debug
The examples on malloc options were erroneously
specifying to use 'guards' as an option to enable
both front and rear guards, whereas the correct
option name is 'guard.'

Change-Id: I7118a832b6b308a7c312787f276bb87c1244986e
2018-01-03 08:52:56 -08:00
Elliott Hughes
558a4f5923 Merge "Simplify atoi*/strto* for signed integers." 2017-12-22 17:48:31 +00:00
Elliott Hughes
cb239bda65 Simplify atoi*/strto* for signed integers.
Make the cost of strto<signed> closer to the cost of strto<unsigned>
by removing an `if` from the inner loop. Previously a signed conversion
cost 10ns more than an unsigned one.

After:

  BM_inttypes_strtoimax         81 ns         81 ns    8603362
  BM_inttypes_strtoumax         78 ns         78 ns    8967174
  BM_stdlib_strtol              81 ns         81 ns    8685537
  BM_stdlib_strtoll             81 ns         81 ns    8685481
  BM_stdlib_strtoul             78 ns         78 ns    8962569
  BM_stdlib_strtoull            78 ns         78 ns    8972023

Bug: N/A
Test: ran tests, benchmarks
Change-Id: I72dd5499427b6a940bd94c4d6f727f7efe134d7e
2017-12-21 17:44:22 -08:00
Elliott Hughes
f23ccdba77 Merge "Speed up __sfileext initialization." 2017-12-21 15:59:21 +00:00
Treehugger Robot
8039c49680 Merge "EndsWith now accepts std::string suffixes." 2017-12-21 02:34:35 +00:00
Treehugger Robot
2c5f914584 Merge "bionic: test: time()" 2017-12-20 23:57:36 +00:00
Mark Salyzyn
0b846e8c66 bionic: test: time()
Validate return values from time(), confirm progression.

Test: bionic-unit-tests --gtest_filter=time.time
Bug: 63737556
Change-Id: I08186780c42ded9648b3e788bb2caa2210d00dab
2017-12-20 12:36:57 -08:00
Elliott Hughes
6db9af0392 EndsWith now accepts std::string suffixes.
Bug: N/A
Test: ran tests
Change-Id: I947a94f1ef950452fb3f90b31448d915a12eb2ac
2017-12-20 12:28:30 -08:00