Commit graph

31095 commits

Author SHA1 Message Date
Ryan Prichard
afa983c8d4 Rewrite __cxa_atexit / __cxa_finalize
Simplify:
 - Use a single memory-mapped region to hold the table of destructors.
   Double its capacity each time it is expanded.
 - Add a recompaction pass at the end of __cxa_finalize that shifts
   entries forward and uses madvise to clean pages.

Bug: http://b/148055738
Test: bionic-unit-tests
Change-Id: Ieb9da2b88640a8a5277d217b43826b5b7e246781
2020-03-06 21:04:32 -08:00
Bill Yi
1a1888f801 Merge "Merge stage-aosp-master to aosp-master - DO NOT MERGE" 2020-03-05 18:27:31 +00:00
Bill Yi
3fc9c80e91 Merge stage-aosp-master to aosp-master - DO NOT MERGE
Change-Id: I402904753a20804e8709e8873e1a8962bb2d8056
2020-03-05 09:50:54 -08:00
Automerger Merge Worker
138897d14a Merge "Fix bugprone-macro-parentheses warnings" am: 608c74aecf
Change-Id: Ie9fee69253e70ad129eadd2d8d78d8beb1498918
2020-03-05 05:40:25 +00:00
Chih-hung Hsieh
608c74aecf Merge "Fix bugprone-macro-parentheses warnings" 2020-03-05 05:18:32 +00:00
Chih-Hung Hsieh
fa658eb094 Fix bugprone-macro-parentheses warnings
Bug: 150783705
Test: WITH_TIDY=1 make
Change-Id: If47b7adaa5f3ba3c518fb0be48f0ffdc81d204b2
2020-03-04 13:22:05 -08:00
Automerger Merge Worker
ada3844361 Merge "Remove return after GTEST_SKIP." am: b274746dd3
Change-Id: I3565a970f6d8accbb446ca52ef31eafe7c931129
2020-03-04 19:18:09 +00:00
Treehugger Robot
b274746dd3 Merge "Remove return after GTEST_SKIP." 2020-03-04 18:29:33 +00:00
Automerger Merge Worker
205790270a Merge "Update the scudo wrapper for bionic changes." am: 93517d1a27
Change-Id: I60f8ee282dbe8bb42ef0e87a00f5f31d1d0e58b3
2020-03-03 19:21:16 +00:00
Christopher Ferris
93517d1a27 Merge "Update the scudo wrapper for bionic changes." 2020-03-03 18:52:00 +00:00
Elliott Hughes
edaf03ea18 Remove return after GTEST_SKIP.
Test: treehugger
Change-Id: I5efc31f82a979fcd8d3051c72ed8e6201b3b0d1b
2020-02-28 18:27:09 -08:00
Automerger Merge Worker
8bd2ab6a26 Merge "[GWP-ASan] [heapprofd] Fix infinite recursion between malloc-racing threads." am: 0d303b42b5
Change-Id: I99b2dcb85dd7798f38319af16eefb7a31ae1bc39
2020-02-28 23:39:27 +00:00
Mitch Phillips
0d303b42b5 Merge "[GWP-ASan] [heapprofd] Fix infinite recursion between malloc-racing threads." 2020-02-28 23:18:14 +00:00
Christopher Ferris
2c447b0586 Update the scudo wrapper for bionic changes.
Bug: 137795072

Test: Built using jemalloc, and verified that the two processes that
Test: use libc_scudo do not crash.
Change-Id: Icf773b656d7e2bcdf41b4979e9b6cd980b02d34d
2020-02-28 14:34:13 -08:00
Automerger Merge Worker
c61f25f47f Merge "[GWP-ASan] Don't intercept calloc." am: 95c772f734
Change-Id: Ifa001a6bcd53cdd9aa7491b2f9951ba387a1fdf0
2020-02-28 21:27:29 +00:00
Automerger Merge Worker
85cf71fa3d Merge "Switch to the arm-optimized-routines string routines on aarch64 where possible." am: ddedd9828b
Change-Id: I262dff78db57ccff995bc7fe8ca3d12206afb246
2020-02-28 21:27:20 +00:00
Treehugger Robot
95c772f734 Merge "[GWP-ASan] Don't intercept calloc." 2020-02-28 21:19:51 +00:00
Peter Collingbourne
ddedd9828b Merge "Switch to the arm-optimized-routines string routines on aarch64 where possible." 2020-02-28 21:15:24 +00:00
Mitch Phillips
5c65e87579 [GWP-ASan] Don't intercept calloc.
See linked bug for more information.

Bug: 150456936
Test: N/A
Change-Id: Ibdd4331d005cf488e24c238e67e46cee13198334
2020-02-28 16:58:23 +00:00
Automerger Merge Worker
d53f4f847d Merge "Update bionic to the v2 MTE patch set." am: 2dd382d9b6
Change-Id: I834d141534b9facc306e9f2f2a05b8c9a644e140
2020-02-28 16:54:25 +00:00
Peter Collingbourne
2dd382d9b6 Merge "Update bionic to the v2 MTE patch set." 2020-02-28 16:43:22 +00:00
Mitch Phillips
449c26a47d [GWP-ASan] [heapprofd] Fix infinite recursion between malloc-racing threads.
When the heapprofd lazy-initialization dispatch table is installed, two
threads can call malloc() at the same time. One will do the
lazy-initialization, the other will fail the atomic_exchange of
gHeapprofdInitHookInstalled and go to system malloc. The system malloc
still contains the lazy-init malloc, and will recurse.

Fix it so the second thread goes directly to the previous dispatch
table, or to the system allocator directly (instead of through libc
malloc()).

Bug: 150085813
Test: atest perfetto_integrationtests
Test: TracedPerfCtsTest.SystemWideDebuggableApp on cuttlefish x86.
Change-Id: Ia85ad619a0d5e3f558136d84c34dbada4e8b845d
2020-02-28 08:33:27 -08:00
Automerger Merge Worker
0b5e9257b3 Merge "Cleans up logging and comments in ifaddrs." am: 188f87a1b6
Change-Id: I111451f607c95e57bc106b6314f2b1c1a29bc6bb
2020-02-28 09:22:41 +00:00
Bram Bonné
188f87a1b6 Merge "Cleans up logging and comments in ifaddrs." 2020-02-28 09:07:20 +00:00
Peter Collingbourne
80af1b0a2c Update bionic to the v2 MTE patch set.
The values of some constants have changed, and the tag mask has changed from
being an exclusion mask to an inclusion mask.

Bug: 135772972
Change-Id: I322fceae7003bee6b391e7187194ed4c0cb28c58
2020-02-28 01:55:20 +00:00
Automerger Merge Worker
1622ac9a76 Merge "Handle the alternate signal stack correctly in android_unsafe_frame_pointer_chase." am: c00691aa9e
Change-Id: I698fa42731d09b15cda7e8100200ef3b2486692f
2020-02-28 01:41:06 +00:00
Peter Collingbourne
c00691aa9e Merge "Handle the alternate signal stack correctly in android_unsafe_frame_pointer_chase." 2020-02-28 01:28:37 +00:00
Automerger Merge Worker
7ebbfd329a Merge "[unit tests] Add '-mbranch-protection=standard' flag to arm64" am: 0dd87c37d4
Change-Id: Ie21ac0f0824be809d3793018ee73d74628d2a504
2020-02-27 22:26:28 +00:00
Treehugger Robot
0dd87c37d4 Merge "[unit tests] Add '-mbranch-protection=standard' flag to arm64" 2020-02-27 22:11:19 +00:00
Peter Collingbourne
b8d1348788 Handle the alternate signal stack correctly in android_unsafe_frame_pointer_chase.
If an alternate signal stack is set and the frame record is in bounds of
that stack, we need to use the top of the alternate signal stack for bounds
checking rather than the normal stack.

Bug: 150215618
Change-Id: I78b760d61b27da44f8e0cfee3fe94a791011fe58
2020-02-27 10:44:15 -08:00
Automerger Merge Worker
c5725110ed Merge "[GWP-ASan] [heapprofd] Nullptr deref in dispatch." am: c4f9c9d171
Change-Id: Iab3a808f494146de5840b4ac67db1122c67c8615
2020-02-27 18:18:29 +00:00
Mitch Phillips
c4f9c9d171 Merge "[GWP-ASan] [heapprofd] Nullptr deref in dispatch." 2020-02-27 18:04:08 +00:00
Bram Bonné
918bd72225 Cleans up logging and comments in ifaddrs.
To prevent unnecessary SELinux denials, the check referred to by the
comment is kept in place. This allows us to keep auditing the
SELinux denial in order to catch apps that intentionally send
RTM_GETLINK messages.

Fix: 141455849
Test: atest bionic-unit-tests-static
Test: atest NetworkInterfaceTest
Change-Id: I41e5ad6f071c820a8246177a0c629b3be788a942
2020-02-27 16:02:30 +01:00
Tamas Petz
d901ec6964 [unit tests] Add '-mbranch-protection=standard' flag to arm64
This change adds standard branch protection to bionic unit tests
for arm64 targets. For more information see
https://developer.arm.com/search#q=branch-protection

Both Armv8.3-A Pointer Authentication (using the A-key) hint-space
instructions and Armv8.5-A Branch Target Identification hint-space
landing pads are added to the generated code.

Test: 1. Tested on flame
      2. Tested on FVP

Change-Id: Ice991c538a9101448dea64c357f3f6bfb93877eb
2020-02-27 12:58:13 +01:00
Mitch Phillips
5f91bf42e3 [GWP-ASan] [heapprofd] Nullptr deref in dispatch.
Heapprofd uses an ephemeral dispatch table to ensure that GWP-ASan can
be called during heapprofd initialization. Previously, we grabbed the
backup dispatch table from the globals, which is wrong if GWP-ASan isn't
installed (as the malloc_dispatch_table is linker-initialised and not
set to a known good value if a malloc hooker isn't used).

Instead, grab the correct ephemeral dispatch table. When GWP-ASan is
installed, use a copy of its table as the dispatch. When nothing is
installed, fall back to using the native allocator dispatch.

Bug: 135634846
Bug: 150085813
Test: atest perfetto_integrationtests
Test: TracedPerfCtsTest.SystemWideDebuggableApp on cuttlefish x86.

Change-Id: I4beaf9192acadbe00adc02de2e0b0aab6f7a2190
2020-02-26 16:50:58 -08:00
Automerger Merge Worker
ebfaa8ba20 Merge "Override SIGSYS during profiling signal handler" am: 6cf75230d9
Change-Id: Ib2475be582e656b08326032fac55a061aa344372
2020-02-26 16:28:19 +00:00
Treehugger Robot
6cf75230d9 Merge "Override SIGSYS during profiling signal handler" 2020-02-26 14:53:26 +00:00
Peter Collingbourne
337a5b3f9a Switch to the arm-optimized-routines string routines on aarch64 where possible.
This includes optimized strrchr and strchrnul routines, and an MTE-compatible
strlen routine.

Bug: 135772972
Change-Id: I48499f757cdc6d3e77e5649123d45b17dfa3c6b0
2020-02-25 13:11:55 -08:00
Ryan Savitski
1dc4122a1d Override SIGSYS during profiling signal handler
This is a best-effort mitigation for potential crashes when the
profiling signal handler is triggered within certain secomp'd processes.
In particular, we're working around cases where the seccomp policy
doesn't allow some of the handler syscalls, and has a crashing
disposition towards violations via SECCOMP_RET_TRAP, plus a crashing
SIGSYS handler. While not general, this covers the configurations seen
in practice on Android (which are all using minijail in the same way).

By overriding the SIGSYS handling for the duration of the profiling
handler, we can instead receive such SIGSYS signals, and instead recover
from them in a non-crashing manner (the handler is responsible for
filling the syscall return register, since the syscall itself was
skipped).

For simplicity, we're swallowing all SIGSYS signals during this window,
without trying to figure out whether they're something that could be
caused by the profiling signal handler. I've quite convinced myself that
-ENOSYS seems to be safe to return to all of bionic's syscall wrappers
across the four architectures (looking at gensyscalls + the
special-cases like vfork and clone). It is theoretically possible for
all kinds of conflicting (ab)uses of SIGSYS to exist, but I'm assuming
it's not a realistic concern until proven otherwise.

Tested: manually sigqueue'd configstore on crosshatch, confirmed that
        the SIGSYS override log was printed, and the process did not
        crash (as it does on master).
Bug: 149328505
Change-Id: Iab8f09e51169807c9d3e1e0bcfd042f09f7df6a4
2020-02-25 19:00:18 +00:00
Automerger Merge Worker
ed9ebe001c Merge "Add a libc wrapper for statx(2)." am: 33318f5197
Change-Id: I176a13f96ebd11cd2e5d9a4bfccf6d7bb41d8ead
2020-02-25 16:46:12 +00:00
Automerger Merge Worker
846cef8625 Merge "Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>." am: 521dab3b36
Change-Id: I12a6cbf8b0207596956cf485394188fff305c8d8
2020-02-25 16:45:53 +00:00
Elliott Hughes
33318f5197 Merge "Add a libc wrapper for statx(2)." 2020-02-25 16:37:09 +00:00
Elliott Hughes
521dab3b36 Merge "Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>." 2020-02-25 16:36:26 +00:00
Automerger Merge Worker
cea478eca2 Merge "Try to resolve interface names before removing nameless interfaces." am: 9f8e1d52cb
Change-Id: Id5751c2e9c8882b5cdc58d786195d0f518880a43
2020-02-25 09:10:32 +00:00
Bram Bonné
9f8e1d52cb Merge "Try to resolve interface names before removing nameless interfaces." 2020-02-25 08:59:49 +00:00
Elliott Hughes
c5d9036f80 Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>.
Noticed by ARM when adding BTI support to the linker.

Test: treehugger
Change-Id: If3b87d0bd4682ff478b7805251fc9a88a7f439f9
2020-02-24 09:52:14 -08:00
Bram Bonné
14e5c3c3b6 Try to resolve interface names before removing nameless interfaces.
For interfaces that didn't get their name set, try to resolve their name
using if_indextoname first, before removing them from the list.

This allows getifaddrs() to keep returning interfaces that only have an
IPv6 address set (as opposed to the previous behavior where only
interfaces with an IPv4 address would be returned).

Change-Id: I0e4e6611948b12794cd3e354538f2964fbf31078
Fix: 148886805
Bug: 141455849
Test: atest NetworkInterfaceTest
Test: atest bionic-unit-tests-static
Test: atest IpSecManagerTunnelTest
2020-02-24 10:56:57 +01:00
Elliott Hughes
733cedd1c4 Add a libc wrapper for statx(2).
Bug: http://b/127675384
Bug: http://b/146676114
Test: treehugger
Change-Id: I844edc12f62717e579870a040cf03dfe60dc280b
2020-02-23 11:36:53 -08:00
Automerger Merge Worker
ec5b567170 Merge "Fix wrong link in getauxval(3) doc comment." am: 438ddfedfe
Change-Id: I20b3ec454c21d355d164008e832d0a6892a848b8
2020-02-22 15:35:33 +00:00
Treehugger Robot
438ddfedfe Merge "Fix wrong link in getauxval(3) doc comment." 2020-02-22 15:27:05 +00:00