Commit graph

2935 commits

Author SHA1 Message Date
Treehugger Robot
4b6a29dbe9 Merge "Improve fchmod() coverage." 2021-03-11 19:19:17 +00:00
Elliott Hughes
ac3fcc6b8c Merge "Improve system() coverage." 2021-03-09 16:15:37 +00:00
Peter Collingbourne
6ba27e04df Merge "Add some slack at the end of large allocations when target SDK level < S." 2021-03-09 01:15:54 +00:00
Elliott Hughes
db6223f46e Improve fchmod() coverage.
Test: treehugger
Change-Id: I8ebccce7ab3c0a77cd84d0830f75e9d68c64bd52
2021-03-08 14:10:46 -08:00
Elliott Hughes
b82f5cfeb2 Improve <sys/xattr.h> coverage.
Also fix a comment copy & paste mistake and some formatting.

Test: treehugger
Change-Id: I0af3ab2eb4f180f86b0ab7d2af260f0f30692fdd
2021-03-08 14:09:43 -08:00
Elliott Hughes
bbbe27ff6e Improve system() coverage.
There's a weird POSIX special case that we implement but don't test.
Found from looking through the coverage data.

Test: treehugger
Change-Id: I74f5f57c4d8062034a3f6e986f9e57091bfc7f7c
2021-03-08 14:07:01 -08:00
Peter Collingbourne
2659d7b6c2 Add some slack at the end of large allocations when target SDK level < S.
This works around buggy applications that read a few bytes past the
end of their allocation, which would otherwise cause a segfault with
the concurrent Scudo change that aligns large allocations to the right.

Because the implementation of
android_set_application_target_sdk_version() lives in the linker,
we need to introduce a hook so that libc is notified when the target
SDK version changes.

Bug: 181344545
Change-Id: Id4be6645b94fad3f64ae48afd16c0154f1de448f
2021-03-05 14:29:17 -08:00
Josh Gao
3de19151e5 Add wrappers for pidfd_{open,getfd,send_signal}.
Bug: http://b/172518739
Test: `/data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter="*pidfd*"` on blueline
Change-Id: Ibae32bbedbcf26535a80a5cbfb55ce180906b610
2021-02-25 13:55:12 -08:00
Bob Badour
8ae9d017f3 Merge "Add LOCAL_LICENSE_KINDS to bionic" 2021-02-21 15:24:32 +00:00
Elliott Hughes
a0d3da5999 Merge "Fix fdsan death tests." 2021-02-20 21:26:29 +00:00
Elliott Hughes
d76dd14ea7 Fix fdsan death tests.
Disable debuggerd for these expected failures.

Also use the usual naming pattern.

Bug: http://b/180605583
Test: check logs
Change-Id: I0254cb658d8a68e963ef59264106de4775e3fedd
2021-02-19 15:48:49 -08:00
Elliott Hughes
526a888d3f Merge "Don't dump backtraces while running fdtrack tests." 2021-02-19 23:40:07 +00:00
Bob Badour
aa7d835fdd Add LOCAL_LICENSE_KINDS to bionic
Added SPDX-license-identifier-Apache-2.0 to:
  apex/Android.bp
  libdl/Android.bp
  tools/Android.bp
  tools/versioner/Android.bp
  tools/versioner/src/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  benchmarks/Android.bp
  benchmarks/linker_relocation/gen/Android.bp
  libc/malloc_debug/Android.bp
  libc/system_properties/Android.bp
  tests/Android.bp
  tests/libs/Android.bp
  tests/libs/Android.build.dlext_testzip.mk
  tests/make_fortify_compile_test.mk

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-ISC SPDX-license-identifier-MIT
    legacy_notice legacy_unencumbered
to:
  libc/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT legacy_unencumbered
to:
  libm/Android.bp

Added SPDX-license-identifier-Apache-2.0 legacy_unencumbered
to:
  libc/tools/Android.bp

Added SPDX-license-identifier-BSD
to:
  benchmarks/linker_relocation/Android.bp
  benchmarks/spawn/Android.bp
  libc/async_safe/Android.bp
  libc/malloc_hooks/Android.bp
  libfdtrack/Android.bp
  linker/Android.bp
  tests/headers/Android.bp
  tests/headers/posix/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Exempt-From-Owner-Approval: janitorial work
Change-Id: Ib05bcaa276b3aa71a7654ccbe8e67e1f16aec9f3
2021-02-19 23:38:28 +00:00
Elliott Hughes
35e81bfc9f Merge "Fix some bionic death tests." 2021-02-19 19:02:24 +00:00
Elliott Hughes
fabcc96a7c Merge "Use death tests correctly." 2021-02-19 18:26:00 +00:00
Treehugger Robot
3b7cc4ad89 Merge "Switch BionicDeathTest to #pragma once." 2021-02-19 18:22:53 +00:00
Elliott Hughes
7f7efa92df Merge "Use BionicDeathTest for an assert(3) test." 2021-02-19 18:09:44 +00:00
Treehugger Robot
6fe4daaa16 Merge "iconv(3): ignore src_bytes_left if src_bytes is null." 2021-02-19 18:09:17 +00:00
Treehugger Robot
18dd0731f6 Merge "Increase leniancy in an inherently flaky test." 2021-02-19 18:06:36 +00:00
Elliott Hughes
ba3187f102 Don't dump backtraces while running fdtrack tests.
I'm assuming this was useful while debugging, but isn't needed now.

Bug: http://b/180605583
Test: check logs
Change-Id: I9d5bb8db60e7709a9a52e29469f7fd1d5a9cb085
2021-02-18 17:25:53 -08:00
Elliott Hughes
6249f9b44e Don't involve debuggerd in a SIGFPE test.
We just want to check that SIGFPE is raised, not try to "debug" this
expected behavior.

Bug: http://b/180605583
Test: check logs
Change-Id: I11571e02c4608570e0d406adeabc36186c5bb107
2021-02-18 17:25:07 -08:00
Elliott Hughes
e657eb4f8a Fix some bionic death tests.
These were creating tombstones and spewing to the log.

You need TEST_F() rather than TEST(), and the modern style is apparently
to use `using` rather than an empty subclass.

Bug: http://b/180605583
Test: run tests, check logcat
Change-Id: I1e639d34854aeff6f042c24643b769a6bcfab877
2021-02-18 17:23:04 -08:00
Elliott Hughes
61d0706507 Use death tests correctly.
The existing attempt at a death test wrapper wasn't functional (because
the tests were TEST rather than TEST_F), and the code in that class
doesn't work anyway. Since I don't understand the intent behind the
failing dup2() calls, I've just removed this and replaced it with
BionicDeathTest which we do need to suppress all the debuggerd work
which caused this bug to be filed.

Bug: http://b/180605583
Test: treehugger
Change-Id: I7717f7ae2620452656cf07db299774dadef55766
2021-02-18 17:17:27 -08:00
Elliott Hughes
15122842ae Use BionicDeathTest for an assert(3) test.
Bug: http://b/180605583
Test: check logs
Change-Id: I5eebef156ea1185c605060fb7e9457ccaaadaf5d
2021-02-18 17:16:09 -08:00
Elliott Hughes
d63ea5627c Switch BionicDeathTest to #pragma once.
Test: treehugger
Change-Id: I3daded12812fb579e8b7d7abeb885ee7f17032e3
2021-02-18 17:15:25 -08:00
Elliott Hughes
527b78d194 Increase leniancy in an inherently flaky test.
The example in the bug was 16ms instead of 10ms. Try 20ms?

Bug: http://b/180581857
Test: treehugger
Change-Id: I58302ad576ab5a031124244edef9df733d796c7e
2021-02-18 10:46:35 -08:00
Elliott Hughes
20c023fdb2 iconv(3): ignore src_bytes_left if src_bytes is null.
This is undefined behavior, but glibc and macOS are both lenient, and
someone hit this in the wild, so we may as well be lenient too. (The
only cost is that it's now slightly easier to write code that works on
everything except old versions of Android.)

Bug: https://issuetracker.google.com/180598400
Test: treehugger
Change-Id: Ia217169ea6283cc53f4fbf71e5abfa08356c2049
2021-02-18 10:37:22 -08:00
Elliott Hughes
aa8db1b9d1 Fix/update notices.
Auto-generate NOTICE files for all the directories, and for each one
individually rather than mixing libc and libm together.

Test: N/A
Change-Id: I7e251194a8805c4ca78fcc5675c3321bcd5abf0a
2021-02-16 15:06:50 -08:00
Ryan Prichard
ef0ec82684 Merge "Revert "Disable signal frame unwinding tests on arm64"" 2021-02-10 23:31:31 +00:00
Ryan Prichard
cdace2f227 Revert "Disable signal frame unwinding tests on arm64"
This reverts commit 315969a67e.

Reason for revert: r407598b has llvm.org/D90898, which should fix the test.

Change-Id: I466e2122a700ba4df9160b57a5d3c94867472615
2021-02-10 07:08:18 +00:00
Elliott Hughes
6d5662d22a Merge "Fix freopen() where the path is null." 2021-02-08 20:07:12 +00:00
Elliott Hughes
a988ed65e4 Remove obsolete cpp_std: "experimental".
This is why I prefer being specific...

Test: treehugger
Change-Id: Ia2f2f5a2a4499df8ab4041c573b0ef78aecbaf3c
2021-02-08 09:25:35 -08:00
Elliott Hughes
f9cfecf3d4 Fix freopen() where the path is null.
This has been in the standard since C99, but we've never supported it
before. It's apparently used by SPIRV-Tools.

I tried implementing this the other way (with fcntl(2)) first, but
eventually realized that that's more complicated and gives worse
results. This implementation assumes that /proc is mounted, but so much
of libc relies on that at this point that I don't think there's any
realistic case where the fcntl(2) implementation would be preferable,
and there are many where it's not.

The fact that no-one's mentioned this until now suggests that it's not a
heavily used feature anyway.

I've also replaced AssertCloseOnExec() with a CloseOnExec()
boolean-valued function instead, because it's really annoying getting
assertion failures that don't point you at the test line in question,
and instead point to some common helper code.

Test: treehugger
Change-Id: Ia2e53bf2664a4f782581042054ecd492830e2aed
2021-02-04 17:01:55 -08:00
Julien Desprez
11874f8f99 Mark bionic-stress-test as not unit tests as it run forever
This timed out the invocation when trying to run all cc_test, excluding it from unit tests.

Change-Id: I67758d5e49b607b7c10052bc193d885d9123bedf
Test: presubmit
Bug: 179092189
2021-02-05 00:52:20 +00:00
Mitch Phillips
bfa3688606 Merge "[MemInit] Remove old API, introduce new MemInit API." 2021-02-01 23:32:24 +00:00
Chih-hung Hsieh
f700de5f53 Merge "Do not run clang-tidy with fortify tests." 2021-01-27 22:57:07 +00:00
Chih-Hung Hsieh
247892e0dc Do not run clang-tidy with fortify tests.
* When clang-tidy is called, its checks
  gave different diagnostic messages.

Bug: 178534530
Test: mm with WITH_TIDY=1
Change-Id: I5eec8239d5531f88caefca3c4032f9764deb9e09
2021-01-27 12:28:20 -08:00
Treehugger Robot
e91aebd4fe Merge "Increase leniancy in an inherently flaky test." 2021-01-26 23:19:14 +00:00
Elliott Hughes
82c3c11c18 Increase leniancy in an inherently flaky test.
The example in the bug was 6ms instead of 5ms. Try 10ms?

Bug: http://b/178437652
Test: treehugger
Change-Id: I192d602fa4f3499cbf072507245543d0435c5329
2021-01-26 11:31:29 -08:00
Edgar Arriaga
cf81e7ca6a Merge changes from topic "proc_madvise_framework"
* changes:
  Add bionic headers for process_madvise
  Add a flag to distinguish shared VMAs
2021-01-26 19:29:37 +00:00
Mitch Phillips
9cad8424ff [MemInit] Remove old API, introduce new MemInit API.
Introduces new heap-zero-init API. We've realised that it's better to be
able to individually control MTE and heap zero-init. Having
heap-zero-init not be controllable without affecting MTE affects our
ability to turn off heap-zero-init in zygote-forked applications.

Bug: 135772972
Test: On FVP: atest -s localhost:5555 malloc#zero_init \
Test: malloc#disable_mte heap_tagging_level
Change-Id: I8c6722502733259934c699f4f1269eaf1641a09f
2021-01-25 15:19:31 -08:00
Ryan Prichard
ee16c724f9 Merge "Ensure same order of global group members in all NS's" 2021-01-22 23:48:49 +00:00
Ryan Prichard
058eb8fa4e Ensure same order of global group members in all NS's
During "step 1" of find_libraries, the linker finds the transitive
closure of dependencies, in BFS order. As it finds each library, it
adds the library to its primary namespace (so that, if some other
library also depends on it, find_loaded_library_by_soname can find the
library in the process of being loaded).

LD_PRELOAD libraries are automatically marked DF_1_GLOBAL, and any
DF_1_GLOBAL library is added to every linker namespace. Previously,
this secondary namespace registration happened after step 1. The result
is that across different namespaces, the order of libraries could vary.
In general, a namespace's primary members will all appear before
secondary members. This is undesirable for libsigchain.so, which we
want to have appear before any other non-preloaded library.

Instead, when an soinfo is added to its primary namespace, immediately
add it to all the other namespaces, too. This ensures that the order of
soinfo objects is the same across namespaces.

Expand the dl.exec_with_ld_config_file_with_ld_preload and
dl.exec_with_ld_config_file tests to cover the new behavior. Mark
lib1.so DF_1_GLOBAL and use a "foo" symbol to mimic the behavior of a
signal API interposed by (e.g.) libsigchain.so and a ASAN preload.

Test: bionic unit tests
Bug: http://b/143219447
Change-Id: I9fd90f6f0d14caf1aca6d414b3e9aab77deca3ff
2021-01-22 03:27:43 -08:00
Elliott Hughes
370e963dec Remove a tautological #if guard.
Test: treehugger
Change-Id: Idc144c663f8bf10eec93f80f3dfedf73a095a42b
2021-01-21 14:40:49 -08:00
Elliott Hughes
73366636e1 Remove the now-unnecessary android_mallopt() options.
These are available from mallopt() now, and all callers have been
switched over.

Bug: http://b/135772972
Test: treehugger
Change-Id: I90c7a7573b261c27001a2dfd4589b23861ad613b
2021-01-15 18:08:25 -08:00
Ryan Prichard
9f72aae9e3 Merge "Disable signal frame unwinding tests on arm64" 2021-01-15 23:02:20 +00:00
Edgar Arriaga
d02148c31a Add a flag to distinguish shared VMAs
This flag is required to filter out shared VMAs when compacting memory
using process_madvise.

Test: atest bionic-unit-tests-static
Bug: 173258203

Change-Id: I01fc0cc614b03128a5a9b0a6c8c5c2d829b701f9
2021-01-14 19:34:39 -08:00
Ryan Prichard
315969a67e Disable signal frame unwinding tests on arm64
The current libunwind.a LLVM prebuilt lacks the special arm64 signal
frame unwinder (https://reviews.llvm.org/D90898), so disable the signal
frame unwinding tests temporarily. (It's not clear who needs this
functionality on Android -- typically crash dumping should use
libunwindstack instead of _Unwind_Backtrace.)

Bug: http://b/153025717
Test: bionic unit tests
Change-Id: I36644dfe4acbedd937768c3aaaad1010099d602c
2021-01-14 17:33:38 -08:00
Elliott Hughes
e925485acd Merge "Make "disable memory mitigations" and "set heap tagging level" more available." 2021-01-15 00:49:45 +00:00
Elliott Hughes
446b4dde72 Make "disable memory mitigations" and "set heap tagging level" more available.
These were only available internally via android_mallopt(), but they're
likely to be needed by more code in future, so move them into mallopt().

This change leaves the android_mallopt() options for now, but I plan on
coming back to remove them after I've switched the handful of callers
over to mallopt() instead.

Bug: http://b/135772972
Test: treehugger
Change-Id: Ia154614069a7623c6aca85975a91e6a156f04759
2021-01-14 13:34:20 -08:00