Commit graph

9990 commits

Author SHA1 Message Date
Ryan Prichard
f3110d6840 Merge "x86: Switch get_pc_thunk to comdat" 2020-04-20 23:02:12 +00:00
Ryan Prichard
a992a06701 x86: Switch get_pc_thunk to comdat
Switch the __x86.get_pc_thunk.{bx,cx} functions from .gnu.linkonce to
comdat section groups. lld doesn't implement .gnu.linkonce and will
instead discard the input sections. Currently, it might produce a
faulty binary that has no get_pc_thunk function in it, which would
crash.

Normally, these functions are generated by GCC and are present in many
object files compiled with PIC. Clang doesn't use them, and instead
initializes the PIC base register with a "call 1f; 1: pop %ebx" pair.

Bug: http://b/154376560
Bug: https://bugs.llvm.org/show_bug.cgi?id=45594
Test: bionic-unit-tests
Change-Id: I3e4857aecdc281b32232270bff4880433e5b6afa
2020-04-20 14:28:10 -07:00
Mitch Phillips
c8480193db Merge "Set the top bit for tagged pointers." 2020-04-20 20:57:41 +00:00
Elliott Hughes
0361a4f867 Merge "tmpfile(3): use O_TMPFILE where available." 2020-04-17 23:29:24 +00:00
Mitch Phillips
b125ca48de Set the top bit for tagged pointers.
Some applications may incorrectly assume that a "negative" pointer
indicates error. By setting the top bit in TBI mode, we catch these
cases as well. Although they don't directly indicate incompatibility
with MTE (as MTE uses the 2nd-highest nibble) - this ensures we catch
HWASan errors as well as reserve the bits for future MTE expansion.

Bug: 154272452
Test: Boot flame, device boots successfully.
Change-Id: I94a6821a82ce7ead59e6ca2dd113a5a50ee9e56b
2020-04-17 22:04:27 +00:00
Peter Collingbourne
23ec1421b5 Merge "Add PTRACE_PEEKTAG to mte_kernel.h." 2020-04-17 18:16:05 +00:00
Treehugger Robot
a06df5faef Merge "arc4random.h: remove some cruft." 2020-04-17 15:32:47 +00:00
Elliott Hughes
bb575d93c4 arc4random.h: remove some cruft.
This hasn't been used since the code was rewritten years ago.

Test: builds
Change-Id: I2c4bccb3fffb15115083afbb178519bd133c64de
2020-04-16 23:14:38 +00:00
Elliott Hughes
a4c2f33fc7 tmpfile(3): use O_TMPFILE where available.
This also removes the ScopedSignalBlocker, which doesn't seem to have
made any sense since threads were invented.

Test: treehugger
Change-Id: I9a323ab4a0b43f14fd5d1f0df1f80184aef63770
2020-04-16 16:12:03 -07:00
Treehugger Robot
1ddfe48a9c Merge "Set apex_available property" 2020-04-11 04:59:53 +00:00
Tom Cherry
03581d7aa9 Merge changes I6c9c2bf5,I23991692
* changes:
  Tighten pwd/grp iteration tests.
  Cleanup some trivial TODOs.
2020-04-10 23:04:55 +00:00
Tom Cherry
6f2e810198 Cleanup some trivial TODOs.
1) "fix the system properties design" is written for the old protocol,
   so we've already changed the design.  There are no other further
   planned changes.
2) "don't drag in all the macros, just the types." is not likely to
   happen or be particularly impactful.
3) "Find a location suitable for these functions ..." is refering to
   legacy code.  More likely that this code will be removed before we
   find a serious reason to fix this TODO.
4) "(73062966) We still don't have a good way ..." is stale; we fixed
   this bug and added the appropriate mechanism.

Test: n/a
Change-Id: I23991692cdeb81ad00844a6a1680900ff384208b
2020-04-10 11:46:03 -07:00
Christopher Ferris
bb9fcb4636 Update to v5.6 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.6

Add a new method for removing structures. This is to deal with the kernel
headers changing some definitions of timeval to __kernel_old_timeval
and itimerval to __kernel_old_itimerval. Remove the __kernel_old_XX
strutures and change the other structures to the previous definitions.

This only works so long as these structures stay the same, if they
diverge, then a different strategy will need to be implemented.

Test: Booted cuttlefish/walleye.
Test: Ran bionic-unit-tests on cuttlefish/walleye.
Change-Id: I0a61f4fa6e4155c602e0414d9b38c2e1637829af
2020-04-10 10:53:48 -07:00
Jiyong Park
2aa19dcb59 Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Bug: 150999716
Test: m
Change-Id: I6ea7fee2a135298085d3965d3578d9ecd53ee405
2020-04-08 22:52:06 +09:00
Peter Collingbourne
6e316e6112 Add PTRACE_PEEKTAG to mte_kernel.h.
This constant is used by the experimental ptrace API for reading
tags in other processes.

Also expose the platform headers to libunwindstack.

Bug: 135772972
Change-Id: I2daecdaa4c8b557b42222f65fc6b68d13da84ad4
2020-04-07 16:49:36 -07:00
Ryan Prichard
a924442816 Merge "Stop exporting unwinder from arm32 libc.a" 2020-04-03 23:07:04 +00:00
Ryan Prichard
379e05fd5d Stop exporting unwinder from arm32 libc.a
The unwinder is still exported from libc.so.

Previously, the object files from libunwind_llvm.a were repackaged into
arm32's libc.a. For a static library output, whole_static_libs did not
repackage the symbols from libgcc_stripped, which is a
toolchain_library, so only the arm32 libc.a exported an unwinder.

Bug: http://b/153028957
Test: bionic-unit-tests / bionic-unit-tests-static
Change-Id: I3048179032d8bc08e1cbad7cd7e2b1fd2e213f7f
2020-04-01 20:10:25 -07:00
Maciej Żenczykowski
666b12e25a icmp6.h - add captive portal and pref64 nd opts
Test: builds
Bug: 150648313
Change-Id: I41bcd4d46c0736b613870dba382ebc079e5759d7
2020-04-01 20:54:45 +00:00
Elliott Hughes
dd8c4f84b2 Merge "Add documentation to <dirent.h>." 2020-03-31 15:26:59 +00:00
Elliott Hughes
02f9f4cfb6 Add documentation to <dirent.h>.
This was a side-effect of something else I was doing. May as well check
this in now though.

Test: treehugger
Change-Id: Ibe8a3640d309c1980fa6e8ef003d4f255384c9e7
2020-03-30 14:26:35 -07:00
Jiyong Park
ad9946c09a libc_header is available to any apex but only visible to certain places
The header library is used by some libraries, such as libunwind_llvm,
which are automatically added as dependencies when stl is set to
libc++_static. Since such dependencies are not specificy to any APEX,
let's mark the header library be available (can be directly or
indirectly be part of an APEX) to any APEX. At the same time, limit the
visibility of the header library so that its uses are strictly limited
to the certain places that we acknowledge. (the places would be reduced
further when we will be successful in dropping the dependency to
libc_headers.)

Bug: 152668052
Test: m
Change-Id: I85ee900947df2c9ce076e2f3aa3145645da77d2b
2020-03-30 18:36:07 +09:00
Florian Mayer
e7221986c8 Merge "dynamic libc: ignore ART profiling signal by default." 2020-03-28 10:15:32 +00:00
Florian Mayer
96272df35c dynamic libc: ignore ART profiling signal by default.
These solves the issue that targetting non-profilable apps crashed them.
There is still a race condition between starting the app and the SIG_IGN
being installed, but that will be fixed in follow-ups.

This also does not cover programs that statically link libc, but those are
rare.

This might be reverted if we find a more general solution to
b/151835887.

Bug: 151328035
Test: java profile sysui, doesn't crash
Test: atest CtsBionicTestCases

Change-Id: I6b99352ed50afe15a609f7ddb85312c2676ddf11
2020-03-27 19:22:00 +01:00
Treehugger Robot
e05c449cd8 Merge "Add ffsl(3), ffsll(3)." 2020-03-26 21:14:36 +00:00
Elliott Hughes
4a6899ce0c Add ffsl(3), ffsll(3).
POSIX added these GNU extensions for issue 8.

I've made these always inline without the usual "until API level X"
proviso because they're single instructions that the compiler can inline
and there's really no point providing these if they add function call
overhead --- everyone should just use __builtin_ffs() and friends
instead in that case.

Bug: https://austingroupbugs.net/view.php?id=617
Test: treehugger
Change-Id: I33fc4b8648ea25917329e81c1b4c60eb9a66d667
2020-03-26 11:43:05 -07:00
Treehugger Robot
4b466292d0 Merge "Set apex_available property" 2020-03-26 10:16:03 +00:00
Mitch Phillips
3309b3dbb9 [GWP-ASan] Allow libc header access from GWP-ASan.
GWP-ASan is part of libc, and the tests (in future) will have to access
the internal headers of libc (particularly, the frame pointer unwinder).

Allow GWP-ASan to have access to the header package.

Bug: 152414185
Test: N/A
Change-Id: I09f771a667be867ec0acc90ddd6b52a432098c57
2020-03-25 15:05:48 -07:00
Jiyong Park
922a5c7d75 Set apex_available property
The marked library(ies) were available to the APEXes via the hand-written
whitelist in build/soong/apex/apex.go. Trying to remove the whitelist
by adding apex_available property to the Android.bp of the libraries.

Bug: 150999716
Test: m
Change-Id: Id5691b02c107ed7b844a186f0a5effa3cb0fe52a
2020-03-25 09:22:22 +09:00
Tom Cherry
1995d74baa Remove ANDROID_LOG_RDONLY
This macro hasn't been meaningful in years.

Test: logging unit tests
Change-Id: I849a466052524c24f1dba585a6423e80198c6b9c
2020-03-23 13:41:06 -07:00
Peter Collingbourne
2528dab741 Clean up untag_address.
We had two copies of this function, one (not quite correct) in tests/utils.h
and another in bionic/macros.h. Delete the former and have the users include
the latter.

Also, create an overload of the function that takes a uintptr_t, which will
be useful for out-of-process scenarios such as the MTE support in debuggerd.

Bug: 135772972
Change-Id: Ia3c2652c97797663146b3f05fa786afe09f7ea97
2020-03-20 15:35:54 -07:00
Mitch Phillips
d92b03887d Merge "[GWP-ASan] Intercept calloc() again." 2020-03-16 20:18:04 +00:00
Mitch Phillips
32abb0b81e [GWP-ASan] Intercept calloc() again.
Bug: 150456936
Test: N/A

Change-Id: Id273e1811f9919c8bdbdbf0ad850421e7c1cd8da
2020-03-16 20:17:39 +00:00
Florian Mayer
c84d295f7c Merge "Add explicit state for heapprofd hooking." 2020-03-12 17:12:17 +00:00
Florian Mayer
fdd5eb1977 Add explicit state for heapprofd hooking.
The double hooking is currently controlled by two separate atomic
booleans. In this state, it is very hard to guard against very subtle
race conditions. Adding an explicit enum to encode the state makes it
easier to reason about the behaviour of the program.

Also introduce a MaybeModifyGlobals to consistently guard accesses to
globals. We would sometimes modify them without swapping the
gGlobalsMutating, introducing a window for race with
HandleHeapprofdSignal.

Test: while true; do atest HeapprofdCtsTest; done
Test: flash blueline and manually test profile
Bug: 150741354
Change-Id: I77102b0bd906b8ec2d6806bd43ba6cbf7191e37c
2020-03-11 10:21:27 -07:00
Ryan Prichard
7aa6ba4aec Merge "Rewrite __cxa_atexit / __cxa_finalize" 2020-03-09 21:00:58 +00:00
Treehugger Robot
7d97c36b3f Merge "Add 29 to stubs.versions of libc/libdl/libm" 2020-03-07 08:44:32 +00:00
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
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
Christopher Ferris
93517d1a27 Merge "Update the scudo wrapper for bionic changes." 2020-03-03 18:52:00 +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
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
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
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
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
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