Commit graph

9871 commits

Author SHA1 Message Date
Christopher Ferris
0e0b473a4c Merge "Update to remove direct include of jemalloc_new." 2020-01-29 17:22:01 +00:00
Elliott Hughes
b070cabea8 elf.h: move all the Android extensions together.
...and document them slightly better.

Test: N/A
Change-Id: I32ad209f4086f617978c093782ac45977561445f
2020-01-27 16:00:19 -08:00
Christopher Ferris
4df29ed9b4 Update to remove direct include of jemalloc_new.
In order to support scudo for non-svelte malloc and jemalloc5 for
svelte malloc, do not include jemalloc_new directly. Move that to
the export_include_dirs for libjemalloc5.

Also, change the way to enable scudo so that it only enables it
for the non-svelte config for now.

Bug: 137795072

Test: Builds
Change-Id: I3d68b443fe4d6b21729795649d0dcf66b7e95e03
2020-01-27 14:50:52 -08:00
Elliott Hughes
1d8f6f2f5d Merge "Modernize SHT_RELR support." 2020-01-27 18:10:13 +00:00
Bram Bonné
f62865767f Merge "Soft-enables MAC address restrictions." 2020-01-27 08:36:08 +00:00
Elliott Hughes
6663f5525d Modernize SHT_RELR support.
Until now we've only supported RELR with our own OS-private-use
constants. Add support for the official numbers (while maintaining
support for the historical numbers).

Add tests to ensure we continue to support both indefinitely.

We can't yet flip the build system over to using the official constants
because the old GNU binutils objcopy we still use in most cases (for the
mini-debug section) only supports the historical constants.

Bug: http://b/147452927
Test: treehugger
Change-Id: If214fce7fade4316115947e90b78ab40864b61f2
2020-01-24 15:39:01 -08:00
Yifan Hong
29546b9133 Merge "Make ramdisk_available." 2020-01-24 22:39:41 +00:00
Mitch Phillips
484b0cd5d4 Fix includes for MTE builds.
Fixes includes in heap tagging to ensure that bionic under MTE builds
successfully.

Thanks Kevin for finding this!

Test: TARGET_EXPERIMENTAL_MTE=true mmma bionic
Bug: N/A
Change-Id: Idd1b9ed3737e48a35f8d8628d13e85f1d58f5c93
2020-01-24 09:16:44 -08:00
Bram Bonné
3af2071f76 Merge "Extends ifaddrs for cases where the client cannot send RTM_GETLINK requests." 2020-01-24 08:40:14 +00:00
Evgenii Stepanov
3ff4245c70 Merge "Add tagged pointers to bionic." 2020-01-24 00:26:32 +00:00
Elliott Hughes
8fe1fcd804 Merge "Reimplement realpath." 2020-01-23 20:34:15 +00:00
Mitch Phillips
3b21ada5f1 Add tagged pointers to bionic.
This patch introduces tagged pointers to bionic. We add a static tag to
all pointers on arm64 compatible platforms (needs requisite
top-byte-ignore hardware feature and relevant kernel patches).

We dynamically detect TBI-compatible devices (a device with the TBI feature and
kernel support) at process start time, and insert an implementation-dependent
tag into the top byte of the pointer for all heap allocations. We then check
that the tag has not been truncated when deallocating the memory.

If an application incorrectly writes to the top byte of the pointer, we
terminate the process at time of detection. This will allow MTE-incompatible
applications to be caught early.

Bug: 135754954
Bug: 147147490

Test: cd bionic && atest .
Change-Id: Ie424325ba1e3c4443040ac265aeaa28d9e405d28
2020-01-23 10:37:24 -08:00
Elliott Hughes
51aa2cfe79 Merge "Initialize __progname correctly." 2020-01-23 18:07:39 +00:00
Elliott Hughes
75064c177f Initialize __progname correctly.
setprogname() does a basename, but we were initializing __progname
directly. Stop doing that, and add some tests.

Test: treehugger
Change-Id: I06f306ade4161b2f0c7e314a3b1b30c9420117b7
2020-01-23 08:28:48 -08:00
Bram Bonné
d3df35e026 Soft-enables MAC address restrictions.
Updates getifaddrs() to behave as if RTM_GETLINK requests are not
allowed for non-system apps that have their target SDK set to R.

This change will be reverted when kernel changes enforcing this behavior
are merged, and is purely meant to check for potential appcompat issues
beforehand.

Bug: 141455849
Test: atest bionic-unit-tests-static
Test: atest NetworkInterfaceTest
Test: Connect to Wi-Fi network
Test: Set up hotspot
Test: Cast from device
Test: Pair Bluetooth device
Test: Call getifaddrs() directly from within an app.
Test: Call NetworkInterface#getNetworkInterfaces() from within an app.
Test: Repeat above tests with an app that targets Android R.
Change-Id: I472891d3e8a18c86ae478be1bab1048636aa95b4
2020-01-23 17:05:42 +01:00
Bram Bonné
d54ad07f50 Extends ifaddrs for cases where the client cannot send RTM_GETLINK requests.
The previous implementation of getifaddrs() depended on RTM_GETLINK requests being allowed, returning an error otherwise. This change makes getifaddrs() attempt to get all necessary information from RTM_NEWADDR messages when RTM_NEWLINK messages are not available.

The code is functionally the same when RTM_GETLINK requests are allowed. When RTM_GETLINK requests are denied, only interfaces that have a network address are returned, and physical addresses for these interfaces remain unset.

In addition, this change updates the copyright notice because repohooks asked nicely.

Bug: 141455849
Test: atest bionic-unit-tests-static
Test: atest NetworkInterfaceTest
Test: Connect to Wi-Fi network
Test: Set up hotspot
Test: Cast from device
Test: Pair Bluetooth device
Test: Call getifaddrs() directly from within an app.
Test: Call NetworkInterface#getNetworkInterfaces() from within an app.

Change-Id: Ia47e037d181ca5df6d9fdae19b405cabfafc6b0f
2020-01-23 16:15:44 +01:00
Christopher Ferris
00a131f387 Update for change MapInfo constructor.
Bug: 148075852

Test: Ran unit tests.
Change-Id: I8326d8db9887e2bba26d6d94786a72c49edc5d21
2020-01-22 23:29:43 -08:00
Elliott Hughes
22fb267ad6 Reimplement realpath.
Use O_PATH like musl to let the kernel do the hard work, rather than the
traditional BSD manual scheme.

Also add the most obvious missing tests from reading the man page, plus
a non-obvious test for deleted files.

Bug: http://b/131435126
Test: treehugger
Change-Id: Ie8a8986fea55f045952a81afee377ce8288a49d5
2020-01-22 18:30:50 -08:00
Treehugger Robot
3d34bfc45c Merge "Update the copyright notice" 2020-01-22 23:51:46 +00:00
Ryan Prichard
8bff8bb622 Update the copyright notice
The repo/pore upload hook made this change automatically.

Bug: none
Test: manual
Change-Id: I1a00edc525f05b53511d8affd84bff926a5c090d
2020-01-22 13:59:15 -08:00
Yifan Hong
5a39cee1ce Make ramdisk_available.
Test: pass
Bug: 147347110
Change-Id: I142311a7558a19d209bcd63207a88e12cf6f130e
2020-01-22 12:09:33 -08:00
Elliott Hughes
73e9f242ed Merge "There are no typewriters in 2020." 2020-01-22 00:59:19 +00:00
Christopher Ferris
c8226ec23d Merge "Revert "Enable the scudo native allocator."" 2020-01-21 21:32:32 +00:00
Peter Collingbourne
39d9156bdc Merge "Export the unwinder implementation from libc." 2020-01-21 21:28:44 +00:00
Elliott Hughes
a8c4542450 There are no typewriters in 2020.
The BSD "Not a typewriter" translation of ENOTTY looks very weird in
2020. The glibc "Inappropriate ioctl for device" is more generic, and
so much less likely to be inappropriate.

Test: strace on a failed fs ioctl
Change-Id: Iad374d6b91ca9f2e4fa1079986fd698feef8359f
2020-01-21 13:10:13 -08:00
Treehugger Robot
b04be9b4ee Merge "platform profiler signal: add traced_perf codepath" 2020-01-21 19:35:25 +00:00
Anna Trostanetski
9981a1dac8 Revert "Enable the scudo native allocator."
This reverts commit b198958412.

Reason for revert: b/147838132. Breaks JNI calls.

Bug: 147838132

Change-Id: I657cf9fddc1e8ee60c1830a1b3f560ab51928a40
2020-01-20 20:17:10 +00:00
Tom Cherry
2185a12312 Add a README.md for async_safe
Particularly to document why both this and liblog exist, when they do
essentially the same thing.

Test: n/a
Change-Id: I216194402a12270cfbb6bc9b840d054dc9c1dc16
2020-01-17 12:12:26 -08:00
Ryan Savitski
b72fed164e Merge "allow for heapprofd's signal to be multiplexed" 2020-01-16 16:04:08 +00:00
Ryan Savitski
e95316330b platform profiler signal: add traced_perf codepath
This patch adds a case for the profiling signal handler (previously just
for native heapprofd profiling) when si_value == 1, corresponding to
traced_perf being the requesting party.

The handler opens /proc/self/{maps,mem}, connects to (init-created)
/dev/socket/traced_perf, and then sends the fds over the socket.
Everything happens synchronously within the signal handler. Socket is
made non-blocking, and we do not retry.

Bug: 144281346
Change-Id: Iea904694caeefe317ed8818e5b150e8819af91c2
2020-01-15 22:55:04 +00:00
Ryan Savitski
175c8867b0 allow for heapprofd's signal to be multiplexed
This patch refactors heapprofd_malloc to make it easier to reuse the
reserved signal for multiple purposes. We define a new generic signal
handler for profilers, which dispatches to more specific logic based on
the signal's payload (si_value).

The profiler signal handler is installed during libc preinit, after
malloc initialization (so races against synchronous heapprofd
initialization need not be considered). In terms of code organization, I
copied the existing approach with a loosely referenced function in
bionic_globals.h. Do tell if you'd rather a different approach here.

The profileability of a process is quite tied to the malloc
files/interfaces in bionic - in particular, it's set through
android_mallopt. I do not change that, but instead introduce a new
android_mallopt option to be able to query profileability of the
process (which is now used by the new profiler signal handler). As part
of that, gZygoteChildProfileable is moved from heapprofd_malloc to
common (alongside gZygoteChild).

I've removed the masking and reraising of the heapprofd signal when
racing against malloc_limit init. We're ok with taking a simpler
approach and dropping the heapprofd signal in such an unlikely race.

Note: this requires a corresponding change in heapprofd to use sigqueue()
instead of kill(), as the latter leaves the si_value uninitialized(?) on
the receiving side.

Bug: 144281346
Change-Id: I93bb2e82cff5870e5ca499cf86439860aca9dfa5
2020-01-15 22:55:03 +00:00
Christopher Ferris
5ad528917b Merge "Enable the scudo native allocator." 2020-01-15 19:50:35 +00:00
Jing Ji
be64282b8c Merge "libc: Add pidfd_open to common seccomp allowed list" 2020-01-15 06:25:34 +00:00
Christopher Ferris
b198958412 Enable the scudo native allocator.
This is attempt number two, all known failures and issues have
been fixed.

Bug: 137795072

Test: Built both svelte and non-svelte versions. Ran enormous numbers
Test: of performance testing.
Test: Ran scudo unit tests.
Test: Ran bionic unit tests.
Test: Ran libmemunreachable tests.
Test: Ran atest CtsRsBlasTestCases on cuttlefish instance.
Change-Id: Ib0c6ef38b63b7a1f39f4431ed8414afe3a92f9b5
2020-01-14 17:25:10 -08:00
Jing Ji
e986722e65 libc: Add pidfd_open to common seccomp allowed list
Apps could use this API to monitor the death of processes

Bug: 118991081
Test: manual
Change-Id: If38e0b6c57713a069706b59128b22a94f23a497c
2020-01-14 14:35:34 -08:00
Elliott Hughes
26f583f046 Merge "Consistent <termios.h> behavior on all API levels." 2020-01-14 19:08:41 +00:00
Robert Sesek
2f21482f14 Merge "Revert "Move pipe, open, and getdents from the APP to COMMON seccomp whitelist."" 2020-01-14 16:59:18 +00:00
Robert Sesek
866387dc32 Revert "Move pipe, open, and getdents from the APP to COMMON seccomp whitelist."
This reverts commit 74cdb253ba.

Chromium (and thus WebView) no longer uses Breakpad for crash reporting,
so the old compat syscalls that were whitelisted for Breakpad can be
moved back to the APP list.

Test: `am start com.android.settings/.SettingsLicenseActivity`
Test: Get the pid of the sandboxed_process0 for the license viewer.
Test: Send the process SIGABRT and check logcat for Crashpad log
      messages.

Bug: 115557900
Change-Id: I877ebe6bfabec544e58723b2e9a2f84c9cbf0a57
2020-01-13 14:20:59 -05:00
Peter Collingbourne
6a363f7f41 Let libmemunreachable use bionic_libc_platform_headers.
Bug: 135772972
Change-Id: I2702abce849a46292dc467f9083f3b6816bfc5e6
2020-01-13 10:40:08 -08:00
Peter Collingbourne
f2b1e03606 Export the unwinder implementation from libc.
This supports the soong commit which causes most platform binaries to stop
statically linking against the unwinder implementation. The soong commit
message has more motivation for this change.

ARM32 uses LLVM libunwind, while all other platforms use libgcc as the
unwinder implementation. This matches the current choices of unwinders on
the various architectures, but means that apps which were directly linking
against the libc.so unwinder symbols on ARM32 are now using LLVM libunwind
instead of libgcc.

Set libc_headers sdk_version to 1 so that libunwind_llvm can depend on it,
and stop statically linking libunwind into libc_malloc_debug.

Bug: 144430859
Change-Id: I52c7f7893d93f500383aeb0b76086c3b6f1935a5
2020-01-10 19:07:59 -08:00
Peter Collingbourne
6dfde988e3 Merge "Add an android_mallopt for controlling the heap tagging level." 2020-01-10 15:22:24 +00:00
Elliott Hughes
f39b0856fe Consistent <termios.h> behavior on all API levels.
Bug: https://issuetracker.google.com/146886722 (where the difference was noticed)
Bug: http://b/69816452 (most recent fixes)
Test: treehugger
Change-Id: I487399c44f63ba276ccde74bf0c4a01e4cd4f4bf
2020-01-09 16:42:15 -08:00
Peter Collingbourne
1e110fb717 Add an android_mallopt for controlling the heap tagging level.
This doesn't add any functionality for now, but there are
a couple of changes in flight that will want to add enumerators
to the mallopt, so let's give them a place to add them.

Bug: 135772972
Bug: 135754954
Change-Id: I6e810020f66070e844500c6fa99b703963365659
2020-01-09 16:39:10 -08:00
Treehugger Robot
3779d6da40 Merge "Add /system_ext/bin to shell search path" 2020-01-08 03:43:18 +00:00
Logan Chien
932a83399a Merge changes from topic "update-clang-tools-6114689"
* changes:
  versioner: Add __VERSIONER_FORTIFY_INLINE
  versioner: Only enable annotation while running versioner
2020-01-08 02:32:17 +00:00
Justin Yun
580d17d2ad Add /system_ext/bin to shell search path
/system_ext/bin has executable binaries. They must be in the shell
search path.

Bug: 134909174
Bug: 134359158
Test: check PATH in the adb shell
Change-Id: I997a2347fa85c444f2e335bede0d63b7703ba001
2020-01-07 20:39:52 +09:00
Elliott Hughes
51d158f38d Fix a few incorrect types in SYSCALLS.TXT.
Nothing that actually affected the generated code.

Test: treehugger
Change-Id: I14b3a5f4608d9f446beb1d039bc434a214632a6b
2020-01-06 14:29:06 -08:00
Logan Chien
171cf7a66e Merge "versioner: Fix fortified sendto" 2020-01-06 18:50:46 +00:00
Josh Gao
5074e7d28f Move sigrtmin.h into platform headers.
Test: mma
Change-Id: Ibc97ef96fe9e32b948c245b06039b95fe4342f39
2020-01-02 14:14:15 -08:00
Josh Gao
4956c372cf Move bionic_macros.h from private to platform.
Test: treehugger
Change-Id: Ie473914f4c8924c7240b3ac22093a9daf42fc948
2020-01-02 14:09:50 -08:00