Commit graph

11238 commits

Author SHA1 Message Date
zijunzhao
02c4ef4d78 Nullability check for string module
Bugs: b/245972273
Test: adb shell
Change-Id: I4c71bca1ff72553b27805722c3076ed105612a21
2023-02-14 20:47:10 +00:00
Zijun Zhao
06c7a8c2cb Merge "Nullability check for epoll module" 2023-02-14 17:24:17 +00:00
zijunzhao
d555a333c8 Nullability check for epoll module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic09eb9c503992178b5f271f80208ea159ee040be
2023-02-14 02:27:20 +00:00
Treehugger Robot
f81027468c Merge "librust_baremetal: No HAVE_ASSEMBLER___MEMCPY_CHK" 2023-02-14 00:57:52 +00:00
Zijun Zhao
b080a0c8f7 Merge "Nullability check for signal module." 2023-02-10 17:34:27 +00:00
Pierre-Clément Tosi
885f894553 Merge "libc_fortify: Fix typo" 2023-02-10 15:14:25 +00:00
zijunzhao
38c5344446 Nullability check for signal module.
Bugs: b/245972273
Test: None
Change-Id: I958e7fd7836afd1e6ff9f2c808171faa602022c7
2023-02-10 02:16:41 +00:00
Pierre-Clément Tosi
467e58e9ea libc_fortify: Fix typo
Test: -
Change-Id: I7ad5def655d0dbfe6b0138d322ca0c25c32c4635
2023-02-09 12:14:17 +00:00
zijunzhao
195b90b83f Nullability check for math module
Bugs: b/245972273
Test: adb shell
Change-Id: I46bf02e1ed3d6e6143c780e30f95fa3af2745216
2023-02-09 00:25:29 +00:00
Treehugger Robot
bc516bf20a Merge "Nullability check for eventfd module" 2023-02-07 22:50:56 +00:00
zijunzhao
9729c193cb Nullability check for eventfd module
Bugs: b/245972273
Test: None
Change-Id: I5a74318850f3e49dd9d78180476e2a9d76853606
2023-02-07 20:47:11 +00:00
Treehugger Robot
f82ee4a37a Merge "Nullability check for klog module" 2023-02-07 16:35:27 +00:00
zijunzhao
1cda74daba Nullability check for stat module
Bugs: b/245972273
Test: None
Change-Id: I8611c7d7c22e2fb6b0cec4b5101dbcb3174ae706
2023-02-07 06:58:39 +00:00
Elliott Hughes
475275b3ec Merge "Fix setfsgid()/setfsuid() for LP32." 2023-02-06 21:22:36 +00:00
Treehugger Robot
a3357c28f5 Merge "Nullability check for quota module" 2023-02-04 04:12:16 +00:00
Elliott Hughes
8dc9f46a3f Fix setfsgid()/setfsuid() for LP32.
These are system calls where the "good" names are camped by
implementations that only work for 16-bit ids, and you need to say "32"
on LP32 to get sensible behavior.

Noticed when disabling CONFIG_UID16 in the kernel.

Bug: http://b/266732373
Test: llvm-objdump -d
Change-Id: Ib1b5822b030c4f86df755b129ec7b435a7f77cd3
2023-02-03 23:10:04 +00:00
zijunzhao
e716b1b3ee Nullability check for klog module
Bugs: b/245972273
Test: adb shell
Change-Id: I43634184ff8785fa8096d7e8034b22da452cfdd4
2023-02-03 21:56:56 +00:00
zijunzhao
4b8a126255 Nullability check for sysinfo module
Bugs: b/245972273
Test: None
Change-Id: Ie351c609136d1873d3969788246d8a4d8b77ac55
2023-02-03 20:05:05 +00:00
zijunzhao
7833a70000 Nullability check for quota module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic300055163c852d1955d0dc419794b25395ce9a3
2023-02-03 20:03:34 +00:00
Mitch Phillips
3d577a836d Merge "Add the recoverable GWP-ASan feature." 2023-02-03 18:35:08 +00:00
Mitch Phillips
64c7d18f29 Merge "[GWP-ASan] Add TURN_ON_FOR_APP_SAMPLED_NON_CRASHING to android_mallopt" 2023-02-03 18:35:08 +00:00
Mitch Phillips
2480f491be [GWP-ASan] Add TURN_ON_FOR_APP_SAMPLED_NON_CRASHING to android_mallopt
This mode allows an android_mallopt(M_INITIALIZE_GWP_ASAN, ...) to turn
on the recoverable, sampled mode. This is the intended mode for
non-system apps that don't specify the gwpAsanMode in Android U.

Bug: 247012630
Test: Patch the zygote to use this option, launch an app with
gwpAsanMode unspecified, trigger a use-after-free, assert the app uses
the recoverable mode.

Change-Id: I701e10f44b2e2694789cc5ec6f0af4bc0c55b9e4
2023-02-02 15:58:35 -08:00
Mitch Phillips
a493fe4153 Add the recoverable GWP-ASan feature.
GWP-ASan's recoverable mode was landed upstream in
https://reviews.llvm.org/D140173.

This mode allows for a use-after-free or a buffer-overflow bug to be
detected by GWP-ASan, a crash report dumped, but then GWP-ASan (through
the preCrashReport() and postCrashReportRecoverableOnly() hooks) will
patch up the memory so that the process can continue, in spite of the
memory safety bug.

This is desirable, as it allows us to consider migrating non-system apps
from opt-in GWP-ASan to opt-out GWP-ASan. The major concern was "if we
make it opt-out, then bad apps will start crashing". If we don't crash,
problem solved :). Obviously, we'll need to do this with an amount of
process sampling to mitigate against the 70KiB memory overhead.

The biggest problem is that the debuggerd signal handler isn't the first
signal handler for apps, it's the sigchain handler inside of libart.
Clearly, the sigchain handler needs to ask us whether the crash is
GWP-ASan's fault, and if so, please patch up the allocator. Because of
linker namespace restrictions, libart can't directly ask the linker
(which is where debuggerd lies), so we provide a proxy function in libc.

Test: Build the platform, run sanitizer-status and various test apps
with recoverable gwp-asan. Assert that it doesn't crash, and we get a
debuggerd report.
Bug: 247012630

Change-Id: I86d5e27a9ca5531c8942e62647fd377c3cd36dfd
2023-02-02 15:35:25 -08:00
zijunzhao
3d59110f72 Nullability check for unistd module
Bugs: b/245972273
Test: None
Change-Id: I6037b1cd0bf233476a1cc0fbc8308a87de50c550
2023-02-01 20:40:35 +00:00
Treehugger Robot
b8a7a2ffbc Merge "Add BIONIC_COMPLICATED_NULLNESS as _Null_unspecified" 2023-02-01 01:41:10 +00:00
zijunzhao
93eb87007a Add BIONIC_COMPLICATED_NULLNESS as _Null_unspecified
In some cases, the nullability of the pointer argument is too
complicated. Developers have better check relevant manuals or
code before annotating.

Bugs: b/245972273
Test: None
Change-Id: I3589a5080b267d1766cc8ed99868129ac16e4012
2023-01-31 22:51:30 +00:00
Christopher Ferris
c36823f7e8 Merge "Purge memory." 2023-01-31 22:19:00 +00:00
Christopher Ferris
aa3e57469c Purge memory.
Some operations wind up allocating then freeing a significant
amount of memory. So after those operations, do a purge so that
the RSS of the process is not artificially inflated.

Bug: 262321164

Test: Ran unit tests.
Test: Verified after this change, the RSS does not go up after running
Test: am dumpheap -n <PID>.
Change-Id: I08477f8ce12c06fd2a068f536a81f4a577d619e2
2023-01-31 01:37:11 +00:00
zijunzhao
4aa1ea04d7 Nullability check for fcntl module
Bugs: b/245972273
Test: None
Change-Id: I48d23c7bc80863cd3a67ab424780308fe6929292
2023-01-30 19:48:44 +00:00
Elliott Hughes
b0360a94c3 Merge "Add (no-op) ifuncs for SVE optimized routines." 2023-01-27 00:06:57 +00:00
zijunzhao
64b1fe21b7 Nullability check for nl_types module
Bugs: b/245972273
Test: None
Change-Id: Idc05efd6613c99292bd3c095679ac20bb6e8bf8f
2023-01-26 06:48:13 +00:00
Elliott Hughes
3d8e98f8bd Add (no-op) ifuncs for SVE optimized routines.
This patch doesn't *enable* the SVE optimized routines, but it does let
us see if switching them to ifuncs will cause any app compat issues, so
that we can more easily use the optimized routines in future.

Test: treehugger
Change-Id: Ic5fe570bd21687da397b48127bf688f7ec68dd0c
2023-01-25 23:33:39 +00:00
Treehugger Robot
b1f9b1b224 Merge "Nullability check for utmp module" 2023-01-25 21:34:27 +00:00
zijunzhao
d9755064a6 Nullability check for utmp module
Bugs: b/245972273
Test: None
Change-Id: Ie37781b87ad13119d1ebc4cd053e184d482d5b58
2023-01-25 19:22:27 +00:00
Elliott Hughes
5ec0bfae50 Track upstream arm-optimized-routines changes.
The MTE-compatible routines are now faster than the incompatible ones,
so they merged them upstream.

I've left the ifunc boilerplate on the assumption that I'll be back
later to enable the new SVE variants.

Test: treehugger
Change-Id: Ic894bfb350b9aa70e307bca1c4978624b3e5f4fd
2023-01-25 18:12:18 +00:00
Elliott Hughes
98c641b096 Merge "Sync strptime.c with upstream." 2023-01-23 22:04:29 +00:00
Treehugger Robot
6ffb6e89f9 Merge "librust_baremetal: Add strtol" 2023-01-23 10:59:25 +00:00
Elliott Hughes
357908ddf6 Defer to getpagesize() in sysconf().
It makes sense that callers to getauxval() should have to pay for a
search --- that's exactly what they're asking for. But it seems silly
and unfair for the same to be true of sysconf() --- that's just an
implementation detail. Call getpagesize() directly instead.

Test: treehugger
Change-Id: I327adc55ace73bc6da68c4b34bf829d377bcbd1a
2023-01-19 21:30:26 +00:00
Christopher Ferris
cc66ba30e5 Merge "Add aliases for backtrace related options." 2023-01-18 18:57:11 +00:00
zijunzhao
4730fb6cc8 Nullability check for termios module
Bugs: b/245972273
Test: None
Change-Id: Ic91fa6ebc87bff513740c1b757a726505e4dae0e
2023-01-14 01:01:51 +00:00
zijunzhao
e951acd2ca Nullability check for execinfo module
Bugs: b/245972273
Test: None
Change-Id: I136926d5b82f62e11df716a26d0847a6bd83a419
2023-01-13 02:14:10 +00:00
Treehugger Robot
716ed9b931 Merge "librust_baremetal: Add memcpy_chk" 2023-01-12 16:26:17 +00:00
Junjie Hu
8655d1741f Add aliases for backtrace related options.
Using the long option names might not fit in the malloc debug option
property since properties have a 92 character limit.

This patch creates new aliases for the original options.

Bug: 264504531
Test: set new options pass
Test: Config unit tests pass.
Change-Id: Id985720f36a2bf0da7b35ff444c2c80eb1fb4363
2023-01-11 15:16:00 -08:00
Chih-hung Hsieh
42f97f5288 Merge "Disable clang-tidy for some malloc tests." 2023-01-11 04:38:25 +00:00
Treehugger Robot
5742addf96 Merge "Nullability check for inttypes module" 2023-01-11 02:38:35 +00:00
Chih-Hung Hsieh
7ab1c81f6b Disable clang-tidy for some malloc tests.
The clang-analyzer-unix.Malloc and other warnings in these
unit tests are either false positive or in
negative tests that can be ignored.

Bug: 259995529
Test: presubmits; make tidy-bionic-libc_subset
Change-Id: Iddabe613d21d3717ba34f9e4d5bb97436279649f
2023-01-10 16:57:44 -08:00
zijunzhao
6daedb7c41 Nullability check for inttypes module
Bugs: b/245972273
Test: None
Change-Id: Ibc6edd389a9f7cb4d2d5f625ba67163eeda98979
2023-01-11 00:32:16 +00:00
Florian Mayer
eae797db66 Merge "Plumb scudo_ring_buffer_size to debuggerd_process_info" 2023-01-10 21:23:33 +00:00
Greg Kaiser
2335213e04 Match argument order in cpp file
We swap the 2nd and 3rd arguments to the CallocEntry constructor
to match the order in the cpp file, and match the C calloc convention.

We also fix an invocation of this constructor.

Change-Id: Iebe16d82a74459e5e957c1d9e2cc1aebb15150d0
Test: TreeHugger
2023-01-09 21:14:18 +00:00
Chia-hung Duan
08af69ab7f Merge "Add the timestamps for each alloc data" 2023-01-08 01:23:56 +00:00
Treehugger Robot
57c8646f59 Merge "Nullability check for malloc module." 2023-01-07 01:28:42 +00:00
zijunzhao
979d39cb82 Nullability check for syslog module.
Bugs: b/245972273
Test: None
Change-Id: I630597ac2101e16f5566208019a9a54e78fe5667
2023-01-06 20:22:58 +00:00
Florian Mayer
347dc623ec Plumb scudo_ring_buffer_size to debuggerd_process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the buffer size at process startup time, and as such we will no
longer be able to call __scudo_get_ring_buffer_size in debuggerd.

Bug: 263287052
Change-Id: I18f166fc136ac8314d748eb80a806defcc25c9fd
2023-01-05 14:07:22 -08:00
Chia-hung Duan
f7e8b17dc5 Add the timestamps for each alloc data
With timestamps, we are able to tell the details of allocator
performance such as the average time for malloc() in different size
class, the potential contention time by examing the overlap between
operations, .etc.

Not all malloc et al. operations are recorded with timestamp. Only
operations relates to memory usage change will have them.

Test: All unit tests pass.

Change-Id: I5c2016246a6f10b221387001bb44778969bb26ae
2023-01-05 22:05:42 +00:00
Treehugger Robot
47fc44c73c Merge "Nullability check for time module." 2023-01-05 21:01:55 +00:00
Treehugger Robot
c22ef226a3 Merge "Merge librust_baremetal_defaults into its library" 2023-01-05 20:01:06 +00:00
zijunzhao
e620266d1c Nullability check for time module.
Bugs: b/245972273
Test: None
Change-Id: I65adc146f88bbd948f61d2f22bdec344faba09ae
2023-01-05 00:18:18 +00:00
Chih-hung Hsieh
2b76f88282 Merge "Disable clang-tidy for upstream files." 2023-01-04 01:22:03 +00:00
Chih-Hung Hsieh
e343db3f54 Disable clang-tidy for upstream files.
Bug: 264302877
Test: presubmit tests; make tidy-bionic_subset
Change-Id: I278201c62e70898103bf20ce8823106418c8fb05
2023-01-03 15:08:22 -08:00
zijunzhao
f043619125 Nullability check for langinfo module.
Bugs: b/245972273
Test: None
Change-Id: I92df36179d25ec668647f15848e5164eeb5d4d70
2023-01-03 19:52:35 +00:00
Pierre-Clément Tosi
eeb53ac80a librust_baremetal: No HAVE_ASSEMBLER___MEMCPY_CHK
Stop defining the unnecessary CPP macro.

Test: TH
Change-Id: Ided365bdd77854f3840ed865537ef43d7cdd00c3
2023-01-03 18:08:31 +00:00
Pierre-Clément Tosi
816176ccd6 librust_baremetal: Add strtol
Add strtol (required by libfdt), which only depends on libc functions
the library already provides or requires.

Bug: 232900974
Test: m pvmfw_bin # with aosp/2314779
Change-Id: I460571b64369c6bf45fef213252f305e978c694d
2023-01-03 18:07:26 +00:00
Pierre-Clément Tosi
199a62e39b librust_baremetal: Add memcpy_chk
Add __memcpy_chk (used by BoringSSL) and start documenting the
dependencies that the baremetal environment needs to provide to
successfully link the library.

Bug: 256148034
Bug: 256827715
Test: m pvmfw_bin && atest vmbase_example.integration_test
Change-Id: I0d61f4efc5cc26a95b74870be7cd7eebeeb0bd3a
2023-01-03 18:05:30 +00:00
Pierre-Clément Tosi
3af5799387 Merge librust_baremetal_defaults into its library
Test: m pvmfw_bin
Change-Id: I14e74019fc64865af615d033f508bfb0d71eef2f
2023-01-03 17:57:42 +00:00
Treehugger Robot
6f78f756a2 Merge "Replace __packed with __attribute__((__packed__)) in uapi headers" 2022-12-17 01:49:22 +00:00
Colin Cross
4ac332279d Replace __packed with __attribute__((__packed__)) in uapi headers
Linux uapi headers use __packed as an abbreviation for
__attribute__((__packed__)).  In the upstream kernel headers this
is defined in linux/compiler_attributes.h, but it is not defined
in the uapi headers.  Bionic defines it in sys/cdefs.h, which will
almost always provide the needed definition, but there are uapi
headers that use __packed and do not include any system headers
that would include sys/cdefs.h.  Musl's sys/cdefs.h does not
define __packed, which leads to linker errors when __packed is
treated as a variable name.

Replace __packed with __attribute__((__packed__)) when importing
uapi headers to break the dependency on sys/cdefs.h.

Test: m USE_HOST_MUSL=true on oriole-userdebug in internal master
Change-Id: I45f80f4e5aec868b80ce8eb9d757a3e08ae3e1a9
2022-12-16 11:51:40 -08:00
zijunzhao
1a49058e66 Nullability check for malloc module.
Bugs: b/245972273
Test: None
Change-Id: I33e164c23d5b7d09af003f3d85e02e676b78aa55
2022-12-15 21:47:53 +00:00
Treehugger Robot
65584f3264 Merge "Nullability check for libgen module." 2022-12-15 01:04:20 +00:00
Treehugger Robot
746ed77a29 Merge "Introduce minimal static libc for baremetal Rust" 2022-12-15 00:22:20 +00:00
Christopher Ferris
137ecdd059 Merge "Update to v6.1 kernel headers." 2022-12-14 17:44:45 +00:00
Greg Kaiser
3d6c94f771 Merge "Revert "Remove workarounds for the llvm sanitizers."" 2022-12-13 19:34:50 +00:00
Greg Kaiser
6f02710ad2 Revert "Remove workarounds for the llvm sanitizers."
This reverts commit fa0e022b06.

Reason for revert: Appears to be causing crash_dump crashes in Go and/or 32-bit

Bug: 262391724
Change-Id: I3964aa9d6c7005313e6bf95b7e87d6a2ab08b52d
Test: Local revert on wembley
2022-12-13 17:20:04 +00:00
Pierre-Clément Tosi
74a1458116 Introduce minimal static libc for baremetal Rust
LLVM/rustc compiling no_std code expects a few libc symbols to be
defined (memcpy, memset, memcmp). Previously, we used the arm64 library
directly; instead, make the dependency arch-agnostic by exporting it
from Bionic, making it easier to add more libc functions (that might not
be implemented by the optimized routines), as necessary.

Test: m pvmfw_bin && atest vmbase_example.integration_test
Change-Id: I1d2cc69a25bbb7eddc67357a028b7b79d4909e79
2022-12-13 14:17:50 +00:00
Ryan Prichard
d791a6501e Merge changes I7ba9cef9,Ia191be0b,I16ba3dc8
* changes:
  Expose unwinder APIs in NDK stubs for R and up.
  Use abi::__cxa_demangle declared in cxxabi.h
  __cxa_atexit_test: declare __cxa_atexit and __cxa_finalize
2022-12-13 00:53:40 +00:00
zijunzhao
ab17c07f1e Nullability check for libgen module.
Bugs: b/245972273
Test: None
Change-Id: I41c741701a5b4416a09c3c683a0817b219262c6d
2022-12-13 00:06:09 +00:00
Christopher Ferris
6cd53a5f6b Update to v6.1 kernel headers.
Kernel headers coming from:

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

Test: Bionic unit tests pass.
Change-Id: I9414fb5e698a9806b85eb09e37d763849f08a468
2022-12-12 23:39:16 +00:00
Elliott Hughes
62d8f1a41a Merge "Remove workarounds for the llvm sanitizers." 2022-12-12 22:48:16 +00:00
Elliott Hughes
d3627a444f Sync strptime.c with upstream.
We still have local differences, but this minimizes (and documents) them.

Bug: http://b/167569813
Test: treehugger
Change-Id: Ib90e6ccc5ec1224e7ee89224a51b87fc48c9931f
2022-12-12 20:56:12 +00:00
Elliott Hughes
1287fd978f Merge "Move some cruft from the build system to the source." 2022-12-12 16:05:29 +00:00
Ryan Prichard
fe504afea7 Expose unwinder APIs in NDK stubs for R and up.
These APIs are exposed in the on-device libc.so's .dynsym table from R
and up (e.g. _Unwind_xxx@@LIBC_R), but they were only available in the
APEX and LLNDK stubs. Expose the symbols from the NDK stubs too so that
the LLVM toolchain build can build a libc++.so that imports the
unwinder from libc.so. (The platform/APEX libc++.so will become a
toolchain prebuilt.)

Eventually this change will also allows apps to use the unwinder from
libc.so rather than linking libunwind.a statically.

Bug: http://b/175635923
Test: treehugger
Change-Id: I7ba9cef9a4727b49dd717e25a0321bf2889694de
2022-12-09 16:10:03 -08:00
Ryan Prichard
c2adad1815 Use abi::__cxa_demangle declared in cxxabi.h
Bug: http://b/175635923
Test: treehugger
Change-Id: Ia191be0b4861b011640edc703b55c13c88bce300
2022-12-09 16:10:00 -08:00
Elliott Hughes
8d9549e28a Move some cruft from the build system to the source.
It's more intention-revealing this way round anyway...

Test: treehugger
Change-Id: I561d8ac3003fa6b7f19fcf7110a6646c69bdd936
2022-12-09 19:58:00 +00:00
Elie Kheirallah
056549795c Add rlim64_t to libc/include/sys/resource
crosvm is using rlim64_t. Adding for portability.

Bug: 255594691
Test: m libc && m bionic
Change-Id: I752bfdaa23d900278fe7224306d785b0c9f67d3f
2022-12-08 23:32:11 +00:00
Elliott Hughes
c40ea825e7 Merge "Spring cleaning for the seccomp allowlist." 2022-12-05 15:53:28 +00:00
Elliott Hughes
fa0e022b06 Remove workarounds for the llvm sanitizers.
We shouldn't need to poke these holes in seccomp now we're building the
sanitizers correctly.

Bug: http://b/229989971
Test: cuttlefish still boots with nothing untoward in the log
Change-Id: I2f9a050a86e670f000f44ad266ffdf404f3a1d1a
2022-12-02 22:20:22 +00:00
zijunzhao
5a918d922b Nullability check for stdlib module.
Bugs: b/245972273
Test: None

Change-Id: Ib33a5359a924c21888f268158c4d7f824740dd55
2022-12-02 21:00:02 +00:00
Elliott Hughes
f9941705aa Spring cleaning for the seccomp allowlist.
Remove copy_file_range(2), preadv2(2), and pwritev2(2), all of which are
now in SYSCALLS.TXT.

Remove semtimedop_time64(2) since it doesn't make any sense to have an
exception for just the 64-bit-time_t-on-LP32 variant of a syscall we
don't even use --- this is the least likely variant of that syscall
to need an exception!

Also clean up the unnecessary foo:foo syntax (you only need the : if you
want the generated stub to have a different name, and here the names
were all identical _and_ the whole point of this file is to list
syscalls that we're not generating stubs for, this was doubly useless),
simplify the signatures to just the types (which is all we need), and
improve some of the commentary.

Test: treehugger
Change-Id: I691b5758a2165be9bbeafdd83f0c64d7eea987e5
2022-12-02 20:18:35 +00:00
Elliott Hughes
1e59e2a88d fcntl: remove some duplication, fix a bug.
Treehugger didn't test 32-bit (and neither, of course, had I), so we
didn't notice until the next day that I'd only added the new check to
the 64-bit codepath. Let's just unify the two, since there's only one
line of meaningful difference.

Bug: http://b/261092827
Test: treehugger
Change-Id: I5178257a76fe24a340b3659c85ad29ed0a7b8b50
2022-12-02 02:56:50 +00:00
Elliott Hughes
008aa172d4 Merge "Add some missing "Available since" documentation." 2022-12-01 16:21:58 +00:00
Elliott Hughes
dfe67d266c Tell people when they've messed up with fcntl(FD_SETFD).
This is a subtle bug that even experts struggle with.

Test: treehugger
Change-Id: If9cf16a1c32c836f5688bb3374cfd21d55125b17
2022-11-30 20:19:22 +00:00
Elliott Hughes
d4fd67ce69 Add some missing "Available since" documentation.
Also fix formatting of `errno` in one function.

Test: treehugger
Change-Id: Ibf362bcd36c901dab2a422afe09e0f78011315aa
2022-11-30 19:55:32 +00:00
Elliott Hughes
023e4e7840 Move to arm-optimized-routines memset().
This one's a bit simpler, because there is only one upstream memset()
implementation.

Test: treehugger
Change-Id: I2536d0eb72adaacfa6a0e40d2bd29fc833988c16
2022-11-17 19:28:06 +00:00
Elliott Hughes
7daf4596b7 Switch to the arm-optimized-routines memcpy() and memmove().
Outsource this to them, and choose the best of the two options available
based on the hardware we're running on.

Test: treehugger
Change-Id: I2fa7555c971b64a6decca132210e901ffa248efa
2022-11-17 00:38:49 +00:00
Treehugger Robot
d26d3c0b5c Merge "Implement __memset_chk as a copy & paste of __memcpy_chk." 2022-11-16 23:33:14 +00:00
Treehugger Robot
6c599e3a67 Merge "Move memcpy_base.S into memcpy.S." 2022-11-16 22:11:53 +00:00
Elliott Hughes
3cc366d3a2 Implement __memset_chk as a copy & paste of __memcpy_chk.
These two will stay behind when we move memcpy()/memmove()/memset() over
to arm-optimized-routines (which leaves fortify to us).

Test: treehugger
Change-Id: Ie683f71a5a141263ce3f4e8811df9eaf667584f4
2022-11-16 21:07:56 +00:00
Elliott Hughes
d5ac40cc9f Move memcpy_base.S into memcpy.S.
Just to make it clear that there's nothing interesting going on here ---
there's just one user, and the only symbol here is __memcpy().

Test: treehugger
Change-Id: I62d72c43c4c6d30442f05c1e08a0cb1a1ec42a8a
2022-11-16 18:50:54 +00:00
Elliott Hughes
0d4d276253 Remove assembler wmemmove().
The compiler turns our C wmemmove() into one shift instruction and a
branch, which is plenty for a function no-one uses anyway.

Why don't I just leave this alone, since we already have it? Because I'm
looking at finishing the project of "switch to arm-optimized-routines"
and getting rid of our assembler here, and Arm agrees that this isn't
worth having optimized assembler for in their optimized assembler
project, judging by its absence.

Test: treehugger
Change-Id: I985801241a8cbd7dbda51a447946affb1402effb
2022-11-16 18:44:56 +00:00
Treehugger Robot
9874c54c93 Merge "Nullability check for regex module." 2022-11-12 09:56:56 +00:00
Treehugger Robot
cf74c0c020 Merge "Simplify the malloc_debug unwind." 2022-11-11 22:05:24 +00:00
Elliott Hughes
ec9ff04075 Add a hack for a RISC-V bug.
I can't find this documented anywhere, other than people observing that
RISC-V appears to behave in this way. See the LLVM commit making a
similar change to similar code, for example: https://reviews.llvm.org/D87579.

Unsatisfying, but it works, and I suspect we're all too far down this
copy & paste hole to get back out now. See also psabi bug
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/18 for
more discussion.

Change-Id: I9e9d60bf859715895370861b2024deeb1d330577
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
2022-11-11 17:12:57 +00:00
Elliott Hughes
eeaf9edb0b Simplify the malloc_debug unwind.
It's hard to find the start of the previous instruction for riscv64
(given the C extension), and discussion with the ART folks cast doubt
on the comment's claim that we do this correctly for arm32 anyway.

So, rather than add complexity for riscv64, let's simplify this routine
for everyone. I suspect we could probably get away with just `--ip` for
all architectures, but since it's trivial to at least maintain plausible
alignment, I've stuck with the correct "at least" byte counts instead.

(See the discussion on
https://lists.riscv.org/g/sig-android/topic/detecting_16_bit_vs_32_bit/94813787
for more about riscv64 specifically.)

Test: treehugger
Change-Id: Ie43451d329470b3ece8779d11eb705d24d01c3d7
2022-11-10 21:35:03 +00:00
zijunzhao
7ececf1140 Nullability check for regex module.
Bugs: b/245972273
Test: None
Change-Id: Ie2c0f3dcbbe1dcbe04d4a6acfac445d556f0c38d
2022-11-10 20:32:47 +00:00
Elliott Hughes
ebe850e01c Merge "Remove strtoq() and strtouq()." 2022-11-10 19:42:02 +00:00
Treehugger Robot
e71efc5ca6 Merge "Use the same union in riscv64's ucontext." 2022-11-09 22:21:25 +00:00
Treehugger Robot
315373dcab Merge "Failures to parse SYSCALLS.TXT-like files should be errors." 2022-11-09 17:19:13 +00:00
Elliott Hughes
8e826775fb Use the same union in riscv64's ucontext.
We don't need this (any more than arm64 does), because riscv64 is too
new to have had a too-small sigset_t, but it's useful for source code
compatibility with code that needs to build on arm32/x86 too.

Test: treehugger
Change-Id: Ied5f64d9094bc7d31c059f82f9e4ffe9b8ca4061
2022-11-09 16:38:00 +00:00
Elliott Hughes
00211554a7 Remove strtoq() and strtouq().
These have been aliases for strtoll() and strtoull() since L, by
accident. We've never exposed them in the headers, and they're unused by
any apps. Let's fix the inconsistency between libc.so and its headers by
removing the aliases.

Bug: https://github.com/android/ndk/issues/1803
Test: treehugger
Change-Id: I87de7831c04b3e450a44e9f0386cacb73793e393
2022-11-09 16:15:05 +00:00
Elliott Hughes
ebd2f76c9b Merge "Sync with upstream NetBSD." 2022-11-09 16:03:31 +00:00
Elliott Hughes
1c1dfb82f4 Failures to parse SYSCALLS.TXT-like files should be errors.
Previously we'd output a diagnostic but just blindly carry on.

Test: ran locally without my previous fix
Change-Id: I99a2411eae5bd72d97b6a4335c699d1e44d7b55a
2022-11-08 17:13:59 +00:00
Elliott Hughes
c8bf923bf0 Fix a typo.
No, I don't know why this is a warning rather than an error. I'll fix
that.

Test: treehugger
Change-Id: Ib3cb50fc4817e3fd418d2d721bda3819b0683b7c
2022-11-08 02:52:29 +00:00
Elliott Hughes
88e4e60a75 Sync with upstream NetBSD.
Test: treehugger
Change-Id: Ia82ba4a0c00a47377240e5d9a85dc30deb5ce3b7
2022-11-08 02:51:48 +00:00
Christopher Ferris
09db6416bc Merge "Update to v6.0 kernel headers." 2022-11-03 01:20:02 +00:00
Elliott Hughes
6a1dc51679 riscv64: don't go via the PLT for setjmp.
I don't think we need or want to do this. Most other architectures
don't.

Test: bionic-unit-tests-static
Change-Id: I3ad31926909caf0a37e73ac6cbac1fecd02ea6de
2022-10-26 19:53:35 +00:00
Elliott Hughes
f4cace695e Punch a hole for renameat(2) for app compat.
This was allowed implicitly until we moved bionic over to renameat2(2)
because that's all riscv64 has. This restores the status quo for the
other architectures (while keeping everyone using renameat2(2) if they
go via bionic, for consistency).

Bug: http://b/254179267
Test: treehugger
Change-Id: Ib7ebfbf043e1be3eca4b64fdf04ee55d6eb31aed
2022-10-21 20:47:34 +00:00
Pat Tjin
00fde2aff6 Modify path for python clang support package
Due to commit 594844244237091347b62e8fbbc8a2851258db50 (update
stable to r468909b) the path for python3-clang support was moved from
   prebuilts/clang/host/linux-x86/clang-stable/lib64/python3/site-packages
to:
   prebuilts/clang/host/linux-x86/clang-stable/lib/python3/site-packages

Change the imports to point to the correct place.

Without the change:
  Traceback (most recent call last):
    File "bionic/libc/kernel/tools/./clean_header.py", line 72, in <module>
      import sys, cpp, kernel, glob, os, re, getopt
    File "bionic/libc/kernel/tools/cpp.py", line 19, in <module>
      import clang.cindex
  ModuleNotFoundError: No module named 'clang'

Bug: 254401594
Test: execute clean_headers.py
Signed-off-by: Pat Tjin <pattjin@google.com>
Change-Id: Ibf1423fbe78ee009366e26905c4a09e68ac8ff9b
2022-10-21 18:27:24 +00:00
Colin Cross
0f917240bd Merge "Add a zip package containing the crt*.o objects" 2022-10-21 17:43:15 +00:00
Colin Cross
290c495c24 Add a zip package containing the crt*.o objects
The ndk sysroot does not include the crt*.o objects, package them
separately for use in the llvm toolchain build.

Test: lunch aosp_riscv64-userdebug && m bionic_sysroot_crt_objects
Change-Id: I0bda12b7979a026441bb67387709ee94b3249b6b
2022-10-20 20:17:07 -07:00
Treehugger Robot
579088b354 Merge "Add riscv64 kernel headers to the ndk sysroot" 2022-10-21 02:34:59 +00:00
Colin Cross
bd26e0fd89 Add riscv64 kernel headers to the ndk sysroot
Add riscv64 kernel headers to the ndk sysroot for use by the LLVM
toolchain build.  They will not be shipped in the real NDK.

Test: lunch aosp_riscv64-userdebug && m ndk_sysroot
Change-Id: I804e66b56919b84fa5dc03d432ae673ea4f31615
2022-10-20 15:15:26 -07:00
Elliott Hughes
bd03a19252 Merge "Remove Commodore 64 support." 2022-10-19 21:21:16 +00:00
Elliott Hughes
473dcc59f3 Remove Commodore 64 support.
https://en.wikipedia.org/wiki/KERNAL

Test: treehugger
Change-Id: I42fc21daa051eca29e6bda7f29c81dd8f353c14e
2022-10-19 16:13:09 +00:00
Yu Liu
0b67417d77 Merge "Refactor the bp file to avoid arch variant in cc_genrule." 2022-10-19 15:27:08 +00:00
Yu Liu
938ec9b7e8 Refactor the bp file to avoid arch variant in cc_genrule.
The arch variant of genrule.out will be soon disallowed in soong.

Bug: 253645813
Test: Manually build.
Change-Id: I2d5daa67b4e10f4abddebc98775df18df485843f
2022-10-18 17:23:17 -07:00
Elliott Hughes
45a84869c4 riscv64: fix setjmp so we're actually using the right cookie!
Test: setjmp.setjmp_smoke
Change-Id: Ia0a160656b9e83cdec611ac196b1ae62f082ab6c
2022-10-18 23:04:12 +00:00
Elliott Hughes
c800a3bd02 riscv64: don't store both arguments in the same place on the stack.
All the pthread tests are, unsurprisingly, broken without this fix.

Test: treehugger
Change-Id: Ia4c6ac077f3bbd749201ae8d200ec99093f7f4bc
2022-10-18 20:01:58 +00:00
Treehugger Robot
8333532f3b Merge "Revert "Refactor the bp file to avoid arch variant in cc_genrule."" 2022-10-18 04:48:28 +00:00
Treehugger Robot
b15a64f722 Merge "riscv64 setjmp." 2022-10-18 04:09:55 +00:00
Yu Liu
3a57969a6f Revert "Refactor the bp file to avoid arch variant in cc_genrule."
This reverts commit ed2654cfdc.

Reason for revert: breaks aosp-master

Change-Id: I8236e3e31e208e8719df52f6b1488af919b37d94
2022-10-18 03:02:32 +00:00
Yu Liu
86ef94783b Merge "Refactor the bp file to avoid arch variant in cc_genrule." 2022-10-18 02:19:03 +00:00
Yu Liu
ed2654cfdc Refactor the bp file to avoid arch variant in cc_genrule.
The arch variant of genrule.out will be soon disallowed in soong.

Bug: 253645813
Test: Manually build.
Change-Id: Ia07d45195de8c22f18487aef34795279d2962c4c
2022-10-17 16:36:30 -07:00
Elliott Hughes
e1905ed629 riscv64 setjmp.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: m
Change-Id: I02cf117f67bda74516e4de8cd6f4c05efdb9a85b
2022-10-17 23:23:36 +00:00
Elliott Hughes
7a19624698 Add riscv64 crtbegin assembler.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: I712a9a93a2df208d763bc46175e00ff763b68146
2022-10-17 21:06:19 +00:00
Elliott Hughes
604ab0fe82 riscv64: enable the version scripts.
Test: treehugger
Change-Id: Idd7b3610bd3321d7e1a4e868cf5dbaf2980909ab
2022-10-17 21:06:10 +00:00
Elliott Hughes
6cef594171 Merge "riscv64: add bionic assembler and string functions." 2022-10-15 15:40:49 +00:00
Elliott Hughes
ebc19a9ccb riscv64: add bionic assembler and string functions.
Pull the portable C string functions from FreeBSD, and do fairly literal
translations of our existing .S files for the bionic-specific stuff.

Test: treehugger
Change-Id: Id42e5b8a51ed73155be020d74edd7011a2103574
2022-10-14 23:25:36 +00:00
Elliott Hughes
faac8e658c arm64: remove unnecessary duplication of constants in vfork.S.
Test: treehugger
Change-Id: I41fd22bad0581269c88f5b3bb499735ab6ecafd2
2022-10-14 21:36:58 +00:00
Elliott Hughes
4c2de1fccc Merge "riscv64 syscall stub and seccomp filter generation." 2022-10-14 14:36:29 +00:00
Elliott Hughes
704772bda0 riscv64 syscall stub and seccomp filter generation.
These are sufficiently intertwined that they need to be done together.
riscv64 is our first primary-only architecture, so that required some
changes. The .bp changes are to support this --- we need to only show
the python scripts the architectures they'll actually be using, rather
than showing them everything and ignoring some of the results.

riscv64 is also the first architecture that post-dates the kernel's
64-bit time work, so there's a bit of extra fiddling needed to handle
the __NR3264_ indirection in the uapi headers.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: local builds for x86-64 and riscv64
Change-Id: I74044744e80b312088f805c44fbd667c9bfcdc69
2022-10-13 23:41:53 +00:00
Colin Cross
91529b75cf Add REG_S0 to ucontext.h for riscv64
REG_S0 is needed by Clang's sanitizer runtimes:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp#L2218

Test: clang build
Change-Id: Id9a82e977dcbdddf5505495b59057cf4564c9e35
2022-10-13 13:27:18 -07:00
Elliott Hughes
c5e588ad37 Merge "riscv64 TLS support." 2022-10-12 00:35:37 +00:00
Treehugger Robot
6987120b30 Merge "riscv64: add "private/bionic_asm.h"." 2022-10-11 02:33:11 +00:00
Treehugger Robot
d5b5adfa87 Merge "riscv64: more <sys/ucontext.h>." 2022-10-11 02:15:10 +00:00
Jingwen Chen
7f50756d59 Merge "Use allowlists.go for all bp2build config and remove Android.bp prop." 2022-10-11 00:36:44 +00:00
Elliott Hughes
add0c48a4b riscv64: add "private/bionic_asm.h".
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Iaa7d5584dfd0ec6f0cf6d3d43ae6bdf2261b12f8
2022-10-11 00:04:34 +00:00
Elliott Hughes
287f48e6e5 riscv64: more <sys/ucontext.h>.
Actually, we don't want to reuse the kernel struct ucontext because its
uc_mcontext has the wrong type, which means the fields within that end
up with the wrong names. Add the call site that made that evident, and
update <sys/ucontext.h> appropriately.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: If1d079afef0d5953aa22d9b0e049cfb0119c7718
2022-10-11 00:01:35 +00:00
Elliott Hughes
43462707a1 riscv64 TLS support.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: I14efb4a03a3dc2ec736d7e47a3f8859c886eb9d6
2022-10-10 20:30:24 +00:00
Elliott Hughes
4043e5ea96 Add riscv64 <ucontext.h>.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Ieb7cb71cd735b6629d507efb0a5e35ee653e4d20
2022-10-10 20:15:51 +00:00
Elliott Hughes
5b2552a030 Merge "riscv64 <sys/user.h>." 2022-10-10 16:36:10 +00:00
Jingwen Chen
95ca177c58 Use allowlists.go for all bp2build config and remove Android.bp prop.
This was introduced when we didn't have allowlists.

Bug: 251197532
Test: presubmits
Change-Id: I83713dd9a0a059acda8e4565677d0c8c6b966749
2022-10-10 14:35:15 +00:00
Elliott Hughes
c6bddf4516 Merge "riscv64 <fenv.h>." 2022-10-08 03:03:13 +00:00
Elliott Hughes
e0b9474854 Merge "riscv64 __get_tls()." 2022-10-08 03:02:56 +00:00
Treehugger Robot
002b57c00e Merge "riscv64 BIONIC_STOP_UNWIND." 2022-10-07 23:15:25 +00:00
Elliott Hughes
fc009dd8a7 riscv64 __get_tls().
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Ie7616cef6d394ba457c30c58d15f696c9b6d3853
2022-10-07 21:33:57 +00:00
Elliott Hughes
203b0b7346 riscv64 BIONIC_STOP_UNWIND.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: I1b6723e9fb60de8f98a716ef388ec81a41df02d3
2022-10-07 21:33:08 +00:00
Elliott Hughes
4c6d66c472 riscv64 <fenv.h>.
Just the interface for now; implementation to come later.

Test: treehugger
Change-Id: Id1f0b158f708ff501b5e13fe92c6736e4507d7b6
2022-10-07 21:15:26 +00:00
Elliott Hughes
cf123811b7 riscv64 <sys/user.h>.
Empty, at least for now. The other libcs seem not to have invented types
here, so let's see whether there's really a call for them before we do.

Test: treehugger
Change-Id: Icbace2c02abc011388edc8e3e238bb64c640feb7
2022-10-07 20:49:07 +00:00
Elliott Hughes
48e5333dd0 Pull in the riscv64 uapi headers for riscv64 builds.
Test: treehugger
Change-Id: I0c41a1a5b9805057609c68a49f67e6e24d4a0572
2022-10-07 20:39:25 +00:00
Elliott Hughes
0f19b10b5d Switch to FreeBSD's elf_common.h.
In particular, it contains all the riscv64 definitions we need, and lets
us clear up a lot of our existing ELF headers.

The other two BSDs seem to have errors and/or gaps in their riscv64
constants.

Test: treehugger
Change-Id: I92e48ef56c52c271ff6ed341b82169aa91f11d98
2022-10-07 00:04:44 +00:00
Elliott Hughes
bba6ddff12 Kernel header scrubber: remove unused map entries.
I was going to add riscv64 and define __riscv_xlen to 64 here, but our
"preprocessor" in python can't simpify `MACRO_NAME == 123` expressions
anyway. Rather than add another empty map, remove the other unused maps
and explain why this functionality is still useful as long as the legacy
32-bit ABIs are still with us.

Test: treehugger
Change-Id: I553059942920e7d323a0ca8a6fd5f39bc2d35063
2022-10-06 20:40:44 +00:00
Elliott Hughes
76be72dde4 Add __tls_get_addr for riscv64.
We added this symbol somewhat inconsistently, with arm and x86-64 in one
release and arm64 in another. It doesn't really matter where we add
riscv64 (since there was no riscv64 at either of these now-historical
API levels), so arbitrarily go with the majority.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: I1ef1e0ebdbece728aaef52c08ee57cca1197cb95
2022-10-06 15:18:35 +00:00
Elliott Hughes
5394de7b05 Merge "riscv64's struct stat is the same as arm64's." 2022-10-06 14:41:03 +00:00
Elliott Hughes
5cc8a46419 riscv64's struct stat is the same as arm64's.
(And all other new architectures.)

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Iceb2dd16c738302624980179788c4a2e68b797ed
2022-10-06 00:26:18 +00:00
Christopher Ferris
7447a1ceea Update to v6.0 kernel headers.
Kernel headers coming from:

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

Test: Boots on coral.
Test: Bionic unit tests pass.
Change-Id: I282de83f23b432bef58214108a93700bdadddf0f
2022-10-05 16:58:32 -07:00
Elliott Hughes
82770d8bfe Merge "Call out the REL architectures and make RELA the default." 2022-10-05 21:42:04 +00:00
Elliott Hughes
6cfd1b59b0 Call out the REL architectures and make RELA the default.
That is: list the two legacy architectures rather than non-legacy ones!

Test: treehugger
Change-Id: I6545a27e740d83e0279b04f161cec179bb0253af
2022-10-05 21:41:48 +00:00
Treehugger Robot
5f16769da6 Merge "Add riscv64 to the map files." 2022-10-05 19:39:34 +00:00
Treehugger Robot
60bf36be00 Merge "Tell the version script generation script about risc-v." 2022-10-05 19:30:05 +00:00
Elliott Hughes
de1df210bb Remove a mips-specific hack.
Rather than add risc-v to this map, let's just remove the map!

Test: treehugger
Change-Id: I118c74c61af95a96f8e31ae6e422619ed86c6a3b
2022-10-05 00:05:05 +00:00
Elliott Hughes
df48d0f902 Add riscv64 to the map files.
The alternative would be to define an "lp64" shorthand like we have for
SYSCALLS.TXT, but since this functionality is only used by bionic and
old frameworks code to document historical oddities, it's unclear that
it's worth implementing. We shouldn't ever need architecture-specific
annotations again in future.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Id64b1746e7490b2d7ad3e4627e9908c28f8f23ba
2022-10-04 23:52:57 +00:00
Elliott Hughes
0a3442526b Tell the version script generation script about risc-v.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: If2c35381159433a6337f4d892ef5689236d0a739
2022-10-04 22:48:38 +00:00
Treehugger Robot
9ba92331dd Merge "Remove unused variable." 2022-10-04 22:08:36 +00:00
Elliott Hughes
dc810a3c13 Remove unused variable.
Looks like we're not using this any more, so rather than add risc-v,
let's just remove this list.

Test: treehugger
Change-Id: I24bb22235c55d48c7dcbae94514ce8dcd03521c3
2022-10-04 20:21:20 +00:00
Elliott Hughes
6660d6c00b Rewrite renameat().
risc-v doesn't have renameat(2), only renameat2(2). Similar to other
architectures, let's make sure everyone's on the same code path by
having all implementations of renameat() go via renameat2().

I've also moved the existing rename()-in-terms-of-renameat() to be in
terms of renameat2() to cut out the middleman!

Test: treehugger
Change-Id: Ibe5e69aca5b39ea014001540bcd4fd3003e665cb
2022-10-04 20:13:49 +00:00
Treehugger Robot
4d974e29d5 Merge "Clarify the docs for updating kernel headers." 2022-10-03 18:00:52 +00:00
Elliott Hughes
93fb6b9459 Clarify the docs for updating kernel headers.
When I followed these instructions for risc-v, I mistakenly thought
that the auto-download option was a convenience that would get the
currently-approved headers, not the absolute latest. Make it clearer in
the documentation that this is for experts only, not for production.

Test: N/A
Change-Id: Iedce8ca0403b83e13bbe339cf343f85a37e99334
2022-10-01 15:29:37 +00:00
Elliott Hughes
5e7f8f116d Initial import of the risc-v uapi headers.
From external/kernel-headers.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Id73a86c9df77825853004137f8b801b24bba93f9
2022-10-01 15:10:58 +00:00
Elliott Hughes
05ef5d46c9 Add riscv64 to the list of uapi architectures.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: bionic/libc/kernel/tools/generate_uapi_headers.sh
Change-Id: I926e1ceaab78b1bb9ae00cf39eb14005aae38e48
2022-09-30 21:37:57 +00:00
Elliott Hughes
ee41a35cc1 Extend the process_madvise() docs.
In particular, explain why we don't have process_mremove(), and why
adding this was probably a mistake (lest it be used as precedent for
similar bad decisions in future).

Also add the missing __INTRODUCED_IN().

Test: treehugger
Change-Id: Ic2d7ef32f6e288353b5be2bffd000ad2f501bf39
2022-09-27 19:27:10 +00:00
Elliott Hughes
305399264b Merge "Add __freadahead." 2022-09-27 18:47:34 +00:00
Benjamin Lerman
27a37e70a7 fdsan: fix overflow in FdTableImpl::at
Change-Id: Ia687eb52a9c5469225550316f884c229a2218724
2022-09-27 11:39:04 +02:00
Elliott Hughes
82be76b5a2 Add __freadahead.
At the time I added <stdio_ext.h>, I just added what was on the man
page (which matched glibc), not realizing that musl and glibc had
slightly different functionality in their headers.

The toybox maintainer came up with a legitimate use case for this, for
which there is no portable workaround, so I'm adding it here. I'm not
adding the other functions that are in musl but not glibc for lack of a
motivating use case.

Bug: http://lists.landley.net/htdig.cgi/toybox-landley.net/2022-April/020864.html
Test: treehugger
Change-Id: I073baa86ff0271064d4e2f20a584d38787ead6b0
2022-09-22 23:47:42 +00:00
Florian Mayer
f8d7761525 Merge "Give init visibility into bionic headers." 2022-09-14 01:22:45 +00:00
Florian Mayer
f5d70cef37 Give init visibility into bionic headers.
Change-Id: Ia17a7382c6e3c51dab3694030e55796852d8b411
2022-09-13 13:59:26 -07:00
Christopher Ferris
06993a6430 Write record allocs from interrupt handler.
There are many cases where there are no more allocations
when a dump of the record allocs might occur. Move the entries
being written to file in the interrupt handler.

Update the unit tests for this new functionality and add a new
unit test that verifies no allocations occur while the entries
are being written.

Fix the unit tests so that the record allocs files get deleted
properly.

Test: All unit tests pass.
Test: Ran 1000 iterations of unit tests to verify no flakes.
Change-Id: I20941596c1dda5a761522050dc155b06f3f3e735
2022-09-09 12:07:33 -07:00
Treehugger Robot
73306db45e Merge "Declare the headers of the ndk_library" 2022-09-09 01:28:04 +00:00
Florian Mayer
298bcecead Merge "Add android_mallopt to query MTE stack state" 2022-09-09 00:49:08 +00:00
Spandan Das
6feb2ccfe9 Declare the headers of the ndk_library
This creates a dependency edge between the ndk_library and its headers,
which should be a no-op in regular Soong builds. This dependency edge
will be used in the Multi-tree project to export the relevant .h files into a well
known location

Test: m nothing
Bug: 239044713
Change-Id: I3f38edfbb8ce6b47dd4e73de4e1e0ad7a371799c
2022-09-08 23:44:35 +00:00
Florian Mayer
cc61ad895e Add android_mallopt to query MTE stack state
Bug: 244364391
Change-Id: Ie6267201f0c2e293b27c71cd160a2311c9de8091
2022-09-07 23:38:42 +00:00
Treehugger Robot
2526b660fd Merge changes from topics "gwp-asan-headers", "native_handle_fdsan"
* changes:
  Open libasync_safe to any APEX
  Remove gwp_asan_headers from libc_defaults
2022-09-06 22:48:31 +00:00
Brian Duddie
e78ea1fc0c Open libasync_safe to any APEX
Permits usage of fdsan in libcutils.

Bug: 244214188
Test: build
Change-Id: I7ac5248c697853aec1210b16b79a84de9046d0d3
2022-09-02 22:43:56 +00:00
Mitch Phillips
b09a3ca076 Remove gwp_asan_headers from libc_defaults
This turns out to over-export GWP-ASan headers to apexes. This is
unnecessary, GWP-ASan headers should only be referenced by libc
internally and debuggerd.

Test: m
Bug: N/A
Change-Id: I04bb8ceb094e681366a4931185906e67ce420c17
2022-09-02 11:52:20 -07:00
Florian Mayer
d71bc4bc3a Fix comment to indicate android_mallopt is also available to APEXes.
Change-Id: Ic8ed578ab3323e6e1a80e05756202354b92fd512
2022-08-31 22:30:04 +00:00
Brian Duddie
5cfca6b832 Add fdsan owner type for native_handle_t
Bug: 244214188
Test: validated alongside sensor service change
Change-Id: Ia576b551012c50def8a8ebe82115ceac35070dcb
2022-08-29 21:29:45 +00:00
Elliott Hughes
963e24b93e setjmp.h: add the missing __returns_twice to sigsetjmp().
setjmp() and _setjmp() were already correct, but we'd missed
sigsetjmp(). Found while investigating a toybox timeout(1) failure on
macOS, which doesn't annotate _any_ of these functions.

Also add all the missing doc comments while I'm here.

Test: treehugger
Change-Id: I69dc2587d140916d172237173c2bd56547a4ed8a
2022-08-25 20:13:00 +00:00
Florian Mayer
af24941d48 Merge "[MTE] Never upgrade MTE mode for zygote." 2022-08-16 16:23:50 +00:00
Florian Mayer
14cbb7963a [MTE] Never upgrade MTE mode for zygote.
Bug: 169277947
Change-Id: I90e9f3d2084b0ef5d035b5ae3e5101e365038f26
2022-08-15 14:34:49 -07:00
Christopher Ferris
94d8e02d33 Merge "Adjust the calculation method of pc" 2022-08-13 00:53:05 +00:00
周至捷
4b84644ac1 Adjust the calculation method of pc
offset is required anytime
fix issue:
https://issuetracker.google.com/issues/238368984

Bug: 238569739

Signed-off-by: 周至捷 <zhouzhijie@xiaomi.com>
Change-Id: I0eeb2940235047b8e7980f5c8bce69c6904d4e9d
2022-08-12 22:34:21 +00:00
Treehugger Robot
d3c7700aa0 Merge "Exclude BUILD files from musl sysroot globs" 2022-08-12 21:14:52 +00:00
Colin Cross
1c0a7a09ff Exclude BUILD files from musl sysroot globs
Don't package the BUILD files into musl sysroots.

Test: build musl sysroot
Change-Id: I260a59a8c0cdd5b4249b657c8435c01fbb56eeb7
2022-08-12 11:49:24 -07:00
Elliott Hughes
f9fac36f15 Merge "Add C23's memset_explicit()." 2022-08-11 22:01:28 +00:00
Christopher Ferris
bf75d08b13 Merge "Update to v5.19 kernel headers." 2022-08-11 21:50:34 +00:00
Elliott Hughes
d1c3d4a454 Merge "Add %b and %B support to the scanf/wscanf and strto*/wcsto* families." 2022-08-11 21:22:23 +00:00
Elliott Hughes
1f462dec34 Add %b and %B support to the scanf/wscanf and strto*/wcsto* families.
Coming to C23 via WG14 N2630.

This one is a little interesting, because it actually changes existing
behavior. Previously "0b101" would be parsed as "0", "b", "101" by these
functions. I'm led to believe that glibc plans to actually have separate
versions of these functions for C23 and pre-C23, so callers can have the
behavior they (implicitly) specify by virtue of which -std= they compile
with. Android has never really done anything like that, and I'm pretty
sure app developers have more than enough to worry about with API levels
without having to deal with the cartesian product of API level and C
standard.

Therefore, my plan A is "if you're running on Android >= U, you get C23
behavior". My plan B in the (I think unlikely) event that that actually
causes trouble for anyone is "if you're _targeting_ Android >= U, you
get C23 behavior". I don't think we'd actually want to have two versions
of each of these functions under any circumstances --- that seems by far
the most confusing option.

Test: treehugger
Change-Id: I0bbb30315d3fabd306905ad1484361f5d8745935
2022-08-11 00:25:08 +00:00
Elliott Hughes
0d64243407 Add C23's memset_explicit().
https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm

Test: treehugger
Change-Id: Ia0cfc72bdf3c22eda6a4fc9adaa4c0ca0ff9a7c8
2022-08-10 23:36:16 +00:00
Christopher Ferris
80ae69d11e Update to v5.19 kernel headers.
Kernel headers coming from:

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

Test: Builds on coral.
Test: All bionic unit tests pass on a coral device.
Test: Able to log in to wembley system.
Change-Id: I6fa6f6edb59f2cef990a7ba96877d9f2d3974c62
2022-08-10 12:58:45 -07:00
Florian Mayer
ea7f84435d Merge "Allow init to upgrade MTE to sync." 2022-08-10 19:57:07 +00:00
Florian Mayer
408e1700f8 Allow init to upgrade MTE to sync.
Bug: 169277947
Test: see other change in topic
Change-Id: I9f5820ffaeb23a4f5539bdbe3db1b455e45d84d8
2022-08-10 10:11:08 -07:00
Christopher Ferris
3fc4e11607 Add support for removing structs that cross blocks.
The latest kernel has a struct that needs to be removed,
but the struct crosses blocks. Add support for removing a
struct that does cross blocks. This support is very primitive,
and will not parse any really complicated struct that uses
defines in complicated ways.

Combine the kernel_structs_to_remove and kernel_struct_replacements
structure into a single map. This allows marking a structure
to be removed as replaced with an #include <bits/STRUCT.h>.

The new support for the remove of structures is all in the
removeStructs function.

Raise an exception if the struct parsing does not work properly.

Add new unit tests for all of the new code.

In addition, fix the algorithm for deleting the uapi directory
before it gets updated. A new file BUILD was checking in that
directory, so delete everything in the directory except that
BUILD file.

Test: Unit tests pass.
Test: Running update_all.py results in the no unexpected changes.
Change-Id: I9a8cef0321beaf71d03b5b874327747a7edb6119
2022-08-09 17:49:31 -07:00
Christopher Ferris
e0cb4e1094 Fix old python2 test issue.
The map function returns a list in python2, but not in python3.
Force the test in cpp.py get_blocks() function to return a list.

Test: All cpp.py unit tests pass.
Change-Id: I1a63b92ac6cdb785830846fbd7e726eca7520e96
2022-08-05 12:59:05 -07:00
Elliott Hughes
cede011a2c Merge "Add %b and %B support to the printf/wprintf family." 2022-08-02 18:13:09 +00:00
Florian Mayer
4ff089f82a Merge "[MTE] Allow remote mode override for process." 2022-08-02 00:17:05 +00:00
Treehugger Robot
c7bf4d419c Merge "[MTE] use static buffer for per-process property name." 2022-08-01 23:51:07 +00:00
Elliott Hughes
b813a6a6be Add %b and %B support to the printf/wprintf family.
Coming to C23 via WG14 N2630, and already in glibc.

We're still missing clang support for %b and %B in format string checking,
but it's probably easier to fix this first. (Apparently GCC already has
support because of glibc.)

Test: treehugger
Change-Id: Ie8bfe4630d00c50e1d047d6756a7f799205356db
2022-08-01 22:18:40 +00:00
Florian Mayer
dee80d515f [MTE] Allow remote mode override for process.
Test: setprop persist.device_config.memory_safety_native.mode_override.process.mte_crash sync
Test: setprop persist.device_config.memory_safety_native.mode_override.process.mte_crash off
Change-Id: I5b167a30a56f56e3f292088f116f398afde65644
2022-08-01 15:17:46 -07:00
Florian Mayer
27914298f5 [MTE] use static buffer for per-process property name.
Change-Id: I3b0d0fdffe72aef7d66544fecac18f7a097ddbaf
2022-08-01 15:02:47 -07:00
Florian Mayer
85eb6fd243 [style] [MTE] remove unnecessary condition.
Change-Id: I186cc82d827c75a9a6e68d081ded2e9dba1dd168
2022-08-01 19:00:59 +00:00
Elliott Hughes
f305560b12 Always free after getline().
Noticed by "NRK": https://www.openwall.com/lists/musl/2022/07/29/5

We don't have this problem elsewhere in bionic because it's so rare to
call getline() without a loop, and the free() is always outside the loop
because that's a handy optimization.

Test: treehugger
Change-Id: Iff8845aa226d87357b38cf4a285fc1be3cac5659
2022-07-29 19:28:37 +00:00
Elliott Hughes
27b3ad2c78 Merge "Simplify the implementation of get_nproc()." 2022-07-29 18:19:29 +00:00
Elliott Hughes
6f4bb0771e Merge "fread: cope with >2GiB totals." 2022-07-29 16:16:27 +00:00
Elliott Hughes
be78fc90e6 fread: cope with >2GiB totals.
The FILE::_read function pointer takes an int rather than a size_t, so
we need to be careful to break large reads up for it.

fwrite() hasn't (yet) been optimized in this way, so it's immune for
now, but add the corresponding write test anyway.

Seeking already uses a off64_t function pointer where possible, so I
don't think there's anything more to be done there.

No other function pointers in FILE are relevant.

Bug: https://issuetracker.google.com/240139009
Test: treehugger
Change-Id: Ife2537e10f178bb0d980719592539f4b00b67031
2022-07-28 20:58:45 +00:00
Elliott Hughes
d771a7cde3 Simplify the implementation of get_nproc().
It came up on the musl mailing list that there's not actually any need
to iterate over the directory entries:

https://www.openwall.com/lists/musl/2022/07/27/1

This lets us reuse the code for "online" processors in the
implementation of "configured" processors. The question of whether
"configured" should correspond to Linux's "possible" or "present" isn't
obvious to me, but the distinction seems unlikely to matter on mobile
devices anyway, and that's a trivial change should it ever be needed.
Plus the motivating argument from the person who brought this up was
that callers asking for "configured" processors are probably asking for
an upper bound, which sounds convincing to me.

Test: treehugger
Change-Id: I0d4e13538dc6b09a6dba520d9ac24f436906f7c0
2022-07-28 17:52:46 +00:00
Elliott Hughes
bf76fc6e64 Merge "Tidy up the x86 atom/silvermont stuff similar to x86-64." 2022-07-25 19:59:03 +00:00
Treehugger Robot
2d072335a6 Merge "Handle null TM_ZONE in z case in strftime." 2022-07-25 18:29:54 +00:00
Elliott Hughes
ed777145e7 Tidy up the x86 atom/silvermont stuff similar to x86-64.
Get rid of the bad precedent of having the architecture variant in the
file name *and* directory name.

Test: treehugger
Change-Id: I78582c12b4390578c51d52d4dd86f57470129abf
2022-07-25 16:27:25 +00:00
Almaz Mingaleev
24bfd8eed7 Handle null TM_ZONE in z case in strftime.
For correct %z output tzcode requires tm struct to be modified by
mktime call or be output of localtime. But as TM_ZONE is null, we
are comparing against +0000.

See https://mm.icann.org/pipermail/tz/2022-July/031674.html

Europe/Lisbon test is added to confirm that current implementation
deviates from libc specification and uses more than just tm_isdst
to find out a time zone's offset.

Bug: 239128167

Test: adb shell /data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static
Test: adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static

Change-Id: Ic27775c840467c4e9ef55bc730a313709372314b
2022-07-25 16:39:12 +01:00
ahs
919fb7f2e0 avx2 implementation for memset.
This patch includes handwritten avx2
assembly for memset 64-bit. Uses
non-temporal stores for very large sizes.
Also includes dynamic dispatch for APIs
having multiple implementations.

Convincing benchmark improvements for sizes above 512 bytes, and
although the slight regression for small sizes is unfortunate, it's
probably small enough to be okay?

Before:

  BM_string_memset/8/0            3.06 ns         3.04 ns    222703428 bytes_per_second=2.45261G/s
  BM_string_memset/16/0           3.50 ns         3.47 ns    202569932 bytes_per_second=4.29686G/s
  BM_string_memset/32/0           3.50 ns         3.48 ns    200064955 bytes_per_second=8.57386G/s
  BM_string_memset/64/0           3.49 ns         3.46 ns    201928186 bytes_per_second=17.2184G/s
  BM_string_memset/512/0          14.8 ns         14.7 ns     47776178 bytes_per_second=32.3887G/s
  BM_string_memset/1024/0         27.3 ns         27.1 ns     25884933 bytes_per_second=35.2515G/s
  BM_string_memset/8192/0          203 ns          201 ns      3476903 bytes_per_second=37.9311G/s
  BM_string_memset/16384/0         402 ns          399 ns      1750471 bytes_per_second=38.2725G/s
  BM_string_memset/32768/0         932 ns          925 ns       755750 bytes_per_second=33.0071G/s
  BM_string_memset/65536/0        2038 ns         2014 ns       347060 bytes_per_second=30.3057G/s
  BM_string_memset/131072/0       4012 ns         3980 ns       175186 bytes_per_second=30.6682G/s

After:

  BM_string_memset/8/0            3.32 ns         3.23 ns    208939089 bytes_per_second=2.3051G/s
  BM_string_memset/16/0           4.07 ns         3.98 ns    173479615 bytes_per_second=3.74822G/s
  BM_string_memset/32/0           4.07 ns         3.95 ns    177208119 bytes_per_second=7.54344G/s
  BM_string_memset/64/0           4.09 ns         4.00 ns    174729144 bytes_per_second=14.8878G/s
  BM_string_memset/512/0          10.7 ns         10.4 ns     65922763 bytes_per_second=45.6611G/s
  BM_string_memset/1024/0         18.0 ns         17.6 ns     40489136 bytes_per_second=54.3166G/s
  BM_string_memset/8192/0          109 ns          106 ns      6577711 bytes_per_second=71.7667G/s
  BM_string_memset/16384/0         221 ns          210 ns      3343800 bytes_per_second=72.684G/s
  BM_string_memset/32768/0         655 ns          623 ns      1153501 bytes_per_second=48.9781G/s
  BM_string_memset/65536/0        1547 ns         1495 ns       461702 bytes_per_second=40.8154G/s
  BM_string_memset/131072/0       2991 ns         2924 ns       240189 bytes_per_second=41.7438G/s

This patch drops the wmemset() code because we don't even have a
microbenchmark for it, we have as many implementations checked in as we
have non-test call sites (!), so at this point it seems like we've spent
more time maintaining wmemset() than running it!

Test: bionic/tests/run-on-host.sh 64
Signed-off-by: ahs <amrita.h.s@intel.com>
Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-07-22 21:48:50 +00:00
Treehugger Robot
7c3f9cb63f Merge "Add the other known aliases for the recent Android releases." 2022-07-16 04:08:00 +00:00
Elliott Hughes
7b396aee5f Add the other known aliases for the recent Android releases.
Test: treehugger
Change-Id: Ic861cba14236a8e4cd60be340407a8c80cda6c8f
2022-07-15 17:04:50 -07:00
Yi Kong
7eeb11da01 Rewrite function definitions with identifier lists
This syntax is removed in C2x proposal N2432.

Test: presubmit
Change-Id: Ic1309841423143e48513dd8b67166b4fde2d67fb
2022-07-13 10:58:42 +08:00
Elliott Hughes
fbac9af484 Sync with upstream openbsd.
Note that this is only a partial update; some other files have changes
upstream that aren't here, but they're changes that seem to require a
bit more thought, whereas these seem easy (and the base64.c and fputws.c
C2x compatibility changes were the motivation to sync right now).

Test: treehugger
Change-Id: I2f86708e25bcb9e779ecb6f9643b769cd4f83240
2022-07-12 13:32:02 -07:00
MarkDacek
d88d7ea329 Rename deps in libc to account for name/src collision work.
Test: m
Bug: 198619163
Change-Id: Ic41f7c1611d69c0c0936b8f5869a3450f1542b5c
2022-07-06 17:26:20 +00:00
Colin Cross
cb8b43e1dd Merge "Switch to the more common idiom for scripts in genrules." 2022-07-01 02:57:12 +00:00
Elliott Hughes
291f98a66d Switch to the more common idiom for scripts in genrules.
Bug: http://b/198619163
Test: treehugger
Change-Id: I8a6e9e179aef45e1b0622a2e15f80f92041f9736
2022-06-30 23:35:11 +00:00
Almaz Mingaleev
ecca88329b Merge "Revert "Revert "Do not look for tzdata file in /data.""" 2022-06-30 16:17:05 +00:00
Almaz Mingaleev
da75bb637d Revert "Revert "Do not look for tzdata file in /data.""
This reverts commit 4e013233b8.

Issue was in unexpected returned fd and errno value combination.
See comments in bionic.cpp and time_test.cpp.

Bug: 236967833
Fix: 236967833

Test: atest CtsBionicTestCases
Test: atest toybox-tests

Change-Id: I51b3e1527ff16b2a6ea4d6fedf8102019f7fd896
2022-06-30 09:39:53 +01:00
Spandan Das
727ab31fd8 Merge "Declare libc's contributions to API surface(s) in Multi-tree" 2022-06-29 23:51:05 +00:00
Mitch Phillips
4c5e40b98a Merge "Add persistent GWP-ASan sysprops." 2022-06-29 20:56:56 +00:00
Spandan Das
3523e8e393 Declare libc's contributions to API surface(s) in Multi-tree
As part of go/multitree-design, build dependencies between API domains
must be via stable API surfaces. The contributions to the API surfaces
will be declared in BUILD files so that we can skip the
migration from Soong->Bazel entirely for this (go/multi-tree-api-export)

libc is one such component of the system API domain that contributes to
the public API surface. This CL declares libc's contributions (its
headers/.map.txt/other_metadata). These BUILD files were generated
manually by looking at existing Android.bp files.

Test: STANDALONE_BAZEL=1 tools/bazel cquery
//bionic/libc:libc_contributions --output=starlark
--starlark:expr="providers(target).get(\"//build/bazel/rules/apis:cc_api_contribution.bzl%CcApiContributionInfo\")"
2>/dev/null | less

Change-Id: If2a429b782651872fd6d8bf8c291439fdf838d85
2022-06-29 20:40:11 +00:00
Mitch Phillips
9634c36565 Add persistent GWP-ASan sysprops.
Adds persistent sysprops for test infra usage, and adds the tests for
the sysprops.

The test does some fancy flocking in order to restore any existing
GWP-ASan sysprop usage in the test cleanup.

Bug: 236738714
Test: atest bionic-unit-tests
Change-Id: I8956296d39c98ce8c7dd0a703b240530d8ad48db
2022-06-29 09:25:13 -07:00
Michael Wright
8cd2ebf80e Add Android U API level to NDK headers
Test: Build
Change-Id: Ic1e0d8b7e5abf07045944d2f610764709b45c923
2022-06-25 00:56:08 +00:00
Treehugger Robot
b566c53033 Merge "Revert "Do not look for tzdata file in /data."" 2022-06-23 19:02:19 +00:00
Almaz Mingaleev
4e013233b8 Revert "Do not look for tzdata file in /data."
This reverts commit e9a20895ea.

Reason for revert: b/236967833. Breaks toybox tests

Change-Id: Ia9832ff62b6d700673f41f0c1c013090a21fe5ec
2022-06-23 16:41:24 +00:00
Treehugger Robot
7ed88b6276 Merge "Do not look for tzdata file in /data." 2022-06-23 12:13:19 +00:00
Almaz Mingaleev
e9a20895ea Do not look for tzdata file in /data.
That was place where APK update mechanism placed tzdata file. Now
the mechanism is removed, so no need to look for tzdata there.

Bug: 148144561

Test: atest CtsBionicTestCases
Test: atest BionicTzdbConsistencyTest
Change-Id: I584400a75651cf24a25df74c7007fcd584838395
2022-06-15 10:02:44 +01:00
Ryan Prichard
bcb9715b63 Avoid using new/delete in locale.cpp
This file is included in libandroid_support.a, where using new/delete
breaks libc++ tests that assume that libc++ makes no extraneous
new/delete calls.

This CL changes newlocale/duplocale to return NULL on out-of-memory.
Previously, the behavior varied:
 - libc.so: aborted using async_safe_fatal
 - libandroid_support.a: throws std::bad_alloc

Bug: none
Test: std/input.output/filesystems/class.path/path.member/path.assign/move.pass.cpp
Test: libcxx/localization/locales/locale/locale.types/locale.facet/no_allocation.pass.cpp
Test: std/input.output/filesystems/class.path/path.member/path.construct/move.pass.cpp
Change-Id: I38c772f249f32322afb9402ebeeb4bb65a908b59
2022-06-13 17:39:32 -07:00
Christopher Ferris
a8cb33ff07 Merge "Update to v5.18 kernel headers." 2022-06-09 16:51:59 +00:00
Almaz Mingaleev
9465700983 Merge "Set TZDEFAULT to NULL." 2022-06-09 09:59:01 +00:00
Christopher Ferris
10a76e674d Update to v5.18 kernel headers.
Kernel headers coming from:

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

The file bionic/libc/kernel/uapi/linux/android/binder.h had a bug
in the original 5.18 kernel headers. This was fixed upstream, so
add a comment to the structure but leave the incorrect field the
same as the 5.17 kernel headers.

Bug: 234125620

Test: Builds.
Test: All bionic unit tests pass on a coral device.
Test: Able to log in to wembley system.
Change-Id: Ia72cafbe71fd894c599e15aa5334d7bbcbe74778
2022-06-08 13:31:52 -07:00
Almaz Mingaleev
0219fe82c6 Merge "Bump tzcode from 2016g to 2022a*." 2022-06-08 07:53:40 +00:00
Almaz Mingaleev
a52a0daf84 Set TZDEFAULT to NULL.
TZDEFAULT not applicable to bionic as there is no file per time
zone mapping.

Bug: 25413083

Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: CtsBionicTestCases
Change-Id: Ie489b5b2cda6c6f623f32e5413da77ec5eaa823f
2022-06-07 10:00:16 +01:00
Almaz Mingaleev
5411aff6bb Bump tzcode from 2016g to 2022a*.
Upstream has renamed tzsetlcl to tzset_unlocked. As bionic's
implementation of tzset_unlock differs from upstream, these changes were
skipped.

Also, upstream has removed constants (SECSPERMIN, etc) from tzfile.h. As
they are used in strptime.c, I've decided to leave them in tzfile.h and
to not bring them into strptime.c.

HAVE_TZNAME and USG_COMPAT flags semantics were updated, thus setting
their values to 2 in Android.bp file. See
1a27ec76bc

* 4742526b7e
and 0e8f0b06ac
were picked up, which are not part of 2022a.

Changes were applied using following commands:
  1) Checkout tzcode repo
  2) Prepare patches for all tzcode file using
    git diff 2016g 2021e -- <file-name> > <file-name-patch>
  3) Apply these patches to files in bionic using
    patch -p1 <file-name> <file-name-patch>

Bug: 25413083
Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: CtsBionicTestCases

Change-Id: I9aba4cbeab30171a32f94d20c8e4057804a4c01f
2022-06-07 09:59:16 +01:00
Elliott Hughes
900a9890e4 Mention O_CREAT and O_TMPFILE in both open(2) fortify messages.
Spotted while reading gbiv's forthcoming "how fortify works"
documentation.

Test: treehugger
Change-Id: I89827bc9afa8e445de8361e938075fabf73ac518
2022-06-06 23:50:34 +00:00
Treehugger Robot
4ebdeebef7 Merge "memtag_stack: vfork and longjmp support." 2022-05-27 23:12:43 +00:00
Treehugger Robot
6cfefe5842 Merge "Revert "Update to v5.18 kernel headers."" 2022-05-27 22:40:37 +00:00
Greg Kaiser
55b5639cca Revert "Update to v5.18 kernel headers."
Revert "Update to v5.18 kernel headers."

Revert submission 2106847-kernel_update

Reason for revert: b/234125620
Reverted Changes:
I5844ca1fc:Update to v5.18 kernel headers.
I5700813ee:Update to v5.18 kernel headers.
Bug: 234125620

Change-Id: I07a39aa9c01939455b5a2a9da5fc04be497ca399
2022-05-27 20:41:14 +00:00
Evgenii Stepanov
3031a7e45e memtag_stack: vfork and longjmp support.
With memtag_stack, each function is responsible for cleaning up
allocation tags for its stack frame. Allocation tags for anything below
SP must match the address tag in SP.

Both vfork and longjmp implement non-local control transfer which
abandons part of the stack without proper cleanup. Update allocation
tags:
* For longjmp, we know both source and destination values of SP.
* For vfork, save the value of SP before exit() or exec*() - the only
  valid ways of ending the child process according to POSIX - and reset
  tags from there to SP-in-parent.

This is not 100% solid and can be confused by a number of hopefully
uncommon conditions:
* Segmented stacks.
* Longjmp from sigaltstack into the main stack.
* Some kind of userspace thread implementation using longjmp (that's UB,
  longjmp can only return to the caller on the current stack).
* and other strange things.

This change adds a sanity limit on the size of the tag cleanup. Also,
this logic is only activated in the binaries that carry the
NT_MEMTAG_STACK note (set by -fsanitize=memtag-stack) which is meant as
a debugging configuration, is not compatible with pre-armv9 CPUs, and
should not be set on production code.

Bug: b/174878242
Test: fvp_mini with ToT LLVM (more test in a separate change)

Change-Id: Ibef8b2fc5a6ce85c8e562dead1019964d9f6b80b
2022-05-27 13:19:34 -07:00
Treehugger Robot
39de8b944e Merge "Basic support for MTE stack tagging." 2022-05-27 02:15:53 +00:00
Evgenii Stepanov
f9fa32acf3 Basic support for MTE stack tagging.
Map all stacks (primary, thread, and sigaltstack) as PROT_MTE when the
binary requests it through the ELF note.

For the reference, the note is produced by the following toolchain changes:
https://reviews.llvm.org/D118948
https://reviews.llvm.org/D119384
https://reviews.llvm.org/D119381

Bug: b/174878242
Test: fvp_mini with ToT LLVM (more tests in a separate change)

Change-Id: I04a4e21c966e7309b47b1f549a2919958d93a872
2022-05-26 16:18:53 -07:00
Christopher Ferris
5d3679612f Update to v5.18 kernel headers.
Kernel headers coming from:

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

Test: Builds.
Test: All bionic unit tests pass on a coral device.
Change-Id: I5700813eec0fb0db55bee4d75b129400b7a239bd
2022-05-25 14:30:25 -07:00
Christopher Ferris
08f98b6734 Merge "Add options to only backtrace specific sizes." 2022-05-19 16:32:29 +00:00
Christopher Ferris
a383648d3a Add options to only backtrace specific sizes.
Add backtrace_size for only backtracing a single size.
Add backtrace_min_size to set the minimum value of size to backtrace.
Add backtrace_max_size to set the maximum value of size to backtrace.

Documented the new options.

Test: New unit test pass.
Change-Id: I1a773737910cd4bc2af9546547b3a2740bbcb22b
2022-05-18 17:05:05 -07:00
Elliott Hughes
f2d59f93e6 Merge "Remove the KSM hack in mmap()." 2022-05-18 23:15:47 +00:00
Christopher Ferris
c7b31befbf Merge "Make the unit tests isolated." 2022-05-18 22:53:27 +00:00
Christopher Ferris
0d07dcc241 Make the unit tests isolated.
Modify the tests that require a single filename, to use a filename
that has the pid as part of the name. This allows multiple different
versions of the test to run on the same machine, and allows
each test to be run at the same time.

Test: Ran unit tests on device.
Test: Ran the unit tests 100 times, no failures.
Change-Id: Ia38483049e7b66bd3da824bcd484c03e46f85280
2022-05-17 17:25:38 -07:00
Florian Mayer
e54a0525e7 Remove unused function.
Change-Id: Iac7b16278868e1d5d267eb9637de6dbcb6bdacfb
2022-05-17 22:54:09 +00:00
Elliott Hughes
b3b0eb6f0e Remove the KSM hack in mmap().
We've been telling people not to use KSM since 2018.

Bug: http://b/115637122
Test: treehugger
Change-Id: Iaa4e0e31e449a74700b6ed47881b9625556f0982
2022-05-17 12:38:38 -07:00
Christopher Ferris
dfbc59ae51 Use new AndroidLocalUnwinder.
The new object incorporates all Android specific knowledge into
a single place and makes everything simpler.

Fixed a bug where if backtrace_full was enabled, the AddBacktrace
function would always set the size to the maximum number
of frames instead of the actual number of frames.

Added a new smoke system tests for backtrace_full.

Modified the smoke test to do a malloc/free, so it's really
a smoke test.

Bug: 232575330

Test: Unit tests pass on device.
Test: Verify the full backtrace actually produces valid backtraces.
Test: Run bionic-unit-tests with backtrace_full enabled.
Test: Run bionic-benchmarks --benchmark_filter=stdlib_malloc_free_decay1/512
Change-Id: I23128a73a8691007e1c7f69e0c99bb4dcd713db8
2022-05-16 15:37:21 -07:00
zijunzhao
c2e412e086 Add copy_file_range(2) syscall stub to bionic.
Test: treehugger
Bug: https://buganizer.corp.google.com/issues/227784687
Change-Id: I543306cd2234189401bf7c9d80d405eeb6e4d41d
2022-05-12 16:53:41 +00:00
Christopher Ferris
bcd8f15e27 Merge "Add option to force memunreachable check." 2022-05-11 23:28:21 +00:00
Christopher Ferris
b42e8b4dec Add option to force memunreachable check.
The new option is named check_unreachable_on_signal. It is meant
to duplicate dumpsys meminfo --unreachable <PID> for non-java
processes. When enabled, a user can send a signal to a process
which will trigger the unreachable check on the next allocation
call.

Added new unit tests.

Test: New unit tests pass.
Test: Enabled for the entire system, then dumped on the netd
Test: process and also system_server.
Change-Id: I73561b408a947a11ce21a211b065d59fcc39097b
2022-05-10 17:37:19 -07:00
Florian Mayer
3c0f0969b9 Remove unnecessary static variable.
Change-Id: I1e0049895fc493f5e8b728707a076d5ad022f8c1
2022-05-10 20:57:13 +00:00
Treehugger Robot
c66cb5ba6a Merge "add new Linux close_range() system call to bionic" 2022-05-06 22:25:26 +00:00
Maciej Żenczykowski
b65e105047 add new Linux close_range() system call to bionic
See:
  https://man7.org/linux/man-pages/man2/close_range.2.html

Note: 'man close_range' documents 'flags' as unsigned int,
while glibc unistd.h as just 'int'.  Picking 'int' to match glibc,
though it probably doesn't matter.

BYPASS_INCLUSIVE_LANGUAGE_REASON=man is a cli command
Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e2d1c8edc2ea28922d60f3ce3e534a784622cd1
2022-05-06 10:33:04 +00:00
Christopher Ferris
de9fe1e2de Merge "Mangle the pointers stored in PointerData." 2022-05-05 19:12:29 +00:00
Christopher Ferris
f78486f40e Mangle the pointers stored in PointerData.
The libmemunreachable library looks through memory to determine
if pointers are leaked. Unfortunately, the malloc debug code
stores the original pointer in data structures, so it looks like
pointers are still in use. The fix is to mangle the pointers
stored in memory so that it doesn't trick the library into thinking
they are live.

Test: All unit/system tests pass.
Test: Ran libmemunreachable and verified leaks show up.
Change-Id: Ic40a0a5ae73857cde936fd76895d88829686a643
2022-05-04 17:07:40 -07:00
Ryan Prichard
0e91012d42 Merge "legacy strtof inline: don't set errno for "inf"" 2022-05-04 22:47:08 +00:00
Elliott Hughes
082b9290d0 Merge "seccomp: allow stat() for ubsan." 2022-05-04 16:35:26 +00:00
Elliott Hughes
a0745cea5f seccomp: allow stat() for ubsan.
We've had complaints about ubsan issues for years, but never got to the
bottom of them, or saw them ourselves in testing. For some reason (still
not understood) we've started to see this ourselves in T and downstream
branches. So for now, let's just punch that extra hole.

Longer term, ubsan should stop needing any of this, so once
https://reviews.llvm.org/D124212 is in an LTS NDK, we should be able to
get rid of this _and_ the existing sanitizer-related holes.

Bug: https://github.com/android/ndk/issues/1298
Bug: http://b/229989971
Test: treehugger
Change-Id: Id42cb29c4e943c0080c0d34ce4e5d6d1b32da9e8
2022-04-29 15:48:08 -07:00
Ryan Prichard
88134649ee legacy strtof inline: don't set errno for "inf"
Bug: https://github.com/android/ndk/issues/415
Test: libc++'s std/strings/string.conversions/stof.pass.cpp
Change-Id: I2c6bab9e31fb1c916be991f72b04735b5df279c2
2022-04-28 23:17:33 -07:00
Maciej Żenczykowski
c9c0ebde3c allowlist new Linux close_range() system call, use it in posix_spawn()
Linux kernel's close_range() system call (currently) allows:
  close() unshare() fcntl(F_SETFD, FD_CLOEXEC)
to be performed on ranges of fds.

All 3 of these are already allowed by seccomp bpf:
as such this doesn't allow you to do anything you can't already do.

We can't add close_range() properly to bionic because we'd need to
fiddle about with ltp and it's too late to add new T API anyway,
so let's just make the direct syscall() call.

We'll add proper support in U.

See also:
  https://man7.org/linux/man-pages/man2/close_range.2.html

Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I85586d544fc23bed6aee59f00bdb79ee7a8150d1
2022-04-28 23:33:38 +00:00
Maciej Żenczykowski
520e2d3490 Merge "posix_spawn - implement support for POSIX_SPAWN_CLOEXEC_DEFAULT" 2022-04-26 22:45:51 +00:00
Christopher Ferris
01ca48f10e Merge "Set VIDEO_MAX_FRAME value back to 64." 2022-04-22 01:56:17 +00:00
Mitch Phillips
3865c8f942 Merge "[GWP-ASan] Provide runtime configuration through an env var + sysprop." 2022-04-21 18:12:43 +00:00
Christopher Ferris
9dfa2e55ed Set VIDEO_MAX_FRAME value back to 64.
This value was changed from 64 to 32, but it really should not
have gone down. So fixing back to 64 manually, and then the
next kernel header update should remove the comment but leave
the value unchanged.

Bug: 228783882

Test: Compiles.
Change-Id: I2d81d7bc76fcaa905dce0abb094d61d02c481a5e
2022-04-21 10:42:09 -07:00
Maciej Żenczykowski
262b873dea posix_spawn - implement support for POSIX_SPAWN_CLOEXEC_DEFAULT
This new posix_spawn attribute flag marks all file descriptors
(except stdin/out/err) as close-on-exec before executing any user
registered file actions (posix_spawn_file_actions_addopen/adddup2).

Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If458100d6a253a9b0348d4e93a9a610225f89615
2022-04-21 07:09:55 -07:00
Dan Albert
3e25f8272f Merge "Disable strict abigail checking pending asm fix." 2022-04-20 19:19:07 +00:00
Mitch Phillips
e6997d52de [GWP-ASan] Provide runtime configuration through an env var + sysprop.
This patch introduces GWP-ASan system properties and environment
variables to control the internal sampling rates of GWP-ASan. This can
be used for:

 1. "Torture testing" the system, i.e. running it under an extremely
    high sampling rate under GWP-ASan.
 2. Increasing sampling remotely to allow further crash report
    collection of rare issues.

There are three sets of system properites:
 1. libc.debug.gwp_asan.*.system_default: Default values for native
    executables and system apps.
 2. libc.debug.gwp_asan.*.app_default: Default values for non-system
    apps, and
 3. libc.debug.gwp_asan.*.<basename/app_name>: Default values for an
    individual app or native process.

There are three variables that can be changed:
 1. The allocation sampling rate (default: 2500) - using the environment
    variable GWP_ASAN_SAMPLE_RATE or the libc.debug.gwp_asan.sample_rate.*
    system property.
 2. The process sampling rate (default: 128 for system apps/processes, 1
    for opted-in apps) - using the environment variable
    GWP_ASAN_PROCESS_SAMPLING or the libc.debug.gwp_asan.process_sampling.*
    system property,
 3. The number of slots available (default: 32) - using the environment
    variable GWP_ASAN_MAX_ALLOCS or the libc.debug.gwp_asan.max_allocs.*
    system property.

If not specified, #3 will be calculated as a ratio of the default
|2500 SampleRate : 32 slots|. So, a sample rate of "1250" (i.e. twice as
frequent sampling) will result in a doubling of the max_allocs to "64".

Bug: 219651032
Test: atest bionic-unit-tests
Change-Id: Idb40a2a4d074e01ce3c4e635ad639a91a32d570f
2022-04-20 11:26:00 -07:00
Florian Mayer
750dcd326e Use SKIP_WITH_HWASAN macro from libbase.
Change-Id: I83681d2191bf4184e52d84d1107d61065927bb24
2022-04-15 16:14:56 -07:00
Florian Mayer
dca7229b06 Skip verify_leak_allocation_limit under HWASan.
Bug: 227801493
Change-Id: I85630fe11b42d8d45ce63f279bb0fbcc635f8afb
2022-04-14 16:21:12 +00:00
Christopher Ferris
8cfc318a87 Merge "In android_set_abort_message, check for nullptr." 2022-04-12 23:33:59 +00:00
Christopher Ferris
bbf9cd86ca In android_set_abort_message, check for nullptr.
If a process is failing due to out of memory, some code calls
android_set_abort_message with a nullptr. Specifically, the libc++
library std::terminate can call do this. In this case, put a
null in the abort message.

Test: Call with nullptr and verify the code does not crash.
Test: Modified crasher to set an abort message and set a null abort
Test: message. Ran both, verified the abort message displays in
Test: first case, and doesn't display in the second case.
Change-Id: Ia9250f47e4537853ce93bbb20b35915a78caa502
2022-04-12 13:46:48 -07:00
Treehugger Robot
a3accda0c7 Merge "[GWP-ASan] Fix bugs in realloc()." 2022-04-12 20:17:14 +00:00
Mitch Phillips
c70311c296 [GWP-ASan] Fix bugs in realloc().
Two edge cases were found in aosp/2038947:
 1. realloc(p, 0) == free() and returns nullptr. Previously, we just
    returned a new pointer.
 2. If the malloc() part of realloc() fails (e.g. when the size of the
    allocation is 1 << 56), then the old memory shouldn't be destroyed.

Bug: N/A
Test: Covered using atest bionic-unit-tests using aosp/2038947.
Change-Id: Ibafc752787129922a1e0323ffa14221d6a14f108
2022-04-11 13:36:39 -07:00
Treehugger Robot
f252b7c465 Merge "Make libasync_safe available in com.android.virt" 2022-04-07 13:25:45 +00:00
Florian Mayer
0aa87b82e5 Skip mallinfo / malloc_info tests on HWASan.
Those aren't implemented.

Test: passes on forrest.
Change-Id: I1a00f5e8ff1aba8f0e25ce589281ed3bfa9d0a5c
2022-04-06 22:03:19 +00:00
Shikha Panwar
307254c616 Make libasync_safe available in com.android.virt
This is required because virtualization_service use
libtombstoned_client_rust which has transitive dependency on
libasync_safe

Test: atest MicrodroidHostTestCases
Bug: 202153827
Change-Id: I9e670d02995f9ed9e67791aaecb300b6bfdbdb03
2022-04-06 21:00:13 +00:00
Florian Mayer
24f276211d Skip other_malloc_functions on HWASan.
Bug: 227801493
Change-Id: I98b0c2d1a9dc450b97d2de5c02c68bcfd38088bf
2022-04-06 00:55:53 +00:00
Dan Albert
2d8d2a0064 Disable strict abigail checking pending asm fix.
Test: m ndk
Bug: http://b/190554910
Change-Id: Ideb0c6d8ac5428c2ebe211393929f1d5c891dfba
2022-03-29 15:59:00 -07:00
Treehugger Robot
2b64e4000d Merge "Avoid usage of LONG_BIT in signal headers." 2022-03-24 21:10:41 +00:00
Peter Collingbourne
08b968b282 Avoid usage of LONG_BIT in signal headers.
Clang has its own limits.h which is ahead of ours on the inclusion
path. This header uses include_next to include our header, but only
in hosted mode. This means that in freestanding mode we don't get our
limits.h macro definitions, including LONG_BIT. This ends up causing
our signal.h to produce errors when included in freestanding mode on
32-bit platforms.

Fix the errors by replacing usage of LONG_BIT with (8 * sizeof(long))
in the signal headers.

Change-Id: I18ec7b6876d5f862beae09f0c011128eef97c869
2022-03-24 11:11:11 -07:00
Christopher Ferris
1ed5534657 Update to v5.17 kernel headers.
Kernel headers coming from:

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

Test: Boots on a flame and all bionic unit tests pass.
Change-Id: I7057d7308241f3acfa600597d287994c39ababbc
2022-03-22 16:48:40 -07:00
Elliott Hughes
93f3017e03 Merge "Revert "Disable pointer authentication in app processes."" 2022-03-14 21:09:31 +00:00
Elliott Hughes
7309177235 Revert "Disable pointer authentication in app processes."
Revert submission 1954983-master-I3030c47be9d02a27505bd4775c1982a20755758c

Reason for revert: PAC has shipped with S, and we're going with app compat outreach rather than regressing security.
Reverted Changes:
I3030c47be:Disable pointer authentication in app processes.
I3030c47be:Disable pointer authentication in app processes.

Change-Id: I8761f08ddbd9077ff98b1a9a0c323de968792778
2022-03-10 18:01:04 +00:00
Colin Cross
471bef4d34 Merge "Use single module for libclang_rt.builtins-exported" 2022-03-08 06:51:43 +00:00
Christopher Ferris
459eecb28b Update for LocalUnwinder object removal.
Modify libfdtrack to use the normal Unwinder object. In addition,
update the libfdtrack so that it doesn't record frames in
libfdtrack.so rather than skipping frames it thinks will be in
the library.

Modify the malloc debug code to use the normal Unwinder object.

Bug: 120606663

Test: All unit tests pass.
Change-Id: I3c9612dd10e62389e6219e68045ee87f7b2625f5
2022-03-03 15:23:25 -08:00
Christopher Ferris
39837afad7 Merge "Add documentation about Android 12 bug." 2022-03-03 01:06:25 +00:00
Christopher Ferris
8cbba80e66 Add documentation about Android 12 bug.
The wrap.<APP> property was broken in Android 12, so provide documentation
about how to workaround it.

Test: NA
Change-Id: I98fdc5801997492442802e1295fb6969f9190e1c
2022-03-02 14:37:34 -08:00
Christopher Ferris
d9b8d13a3a Remove dead subdirs directive.
I removed the bionic/scudo directory a while ago, but I must have
missed removing the subdirs from the Android.bp file.

Test: Builds.
Change-Id: I3e2a1f42b91273a566e587e923c7c3889a71ed17
2022-03-02 21:16:37 +00:00
Colin Cross
335e27b740 Use single module for libclang_rt.builtins-exported
The clang prebuilts now provide a single module with per-architecture
variants instead of a module per architecture.

Bug: 220019988
Test: m checkbuild
Ignore-AOSP-First: topic contains vendor projects
Change-Id: I079f36f94b13e06d59a16cf665b65db76084021a
Merged-In: I079f36f94b13e06d59a16cf665b65db76084021a
2022-03-01 11:36:55 -08:00
Colin Cross
ad33d02faa Add bionic NOTICE file to musl sysroot
Add the bionic NOTICE file to cover the headers included in the
musl sysroot.

Bug: 190084016
Test: examine libc_musl_sysroot.zip
Change-Id: I2b5e1b89e997ac370983e5959a83f09cdcc240e8
2022-02-25 18:27:04 -08:00
Pirama Arumuga Nainar
07cdd57d53 Remove clang version check around diagnose_as_builtin
Bug: http://b/197147102

versioner in aosp/1997532 is built with clang-r445002 and understands
the new attribute.

Test: mmma bionic
Change-Id: Ia3e3c3840e6013446d2679587b72011aff8c50eb
2022-02-23 17:51:55 +00:00
Elliott Hughes
34da4b5842 Merge "posix_spawn: always clear O_CLOEXEC for dup'ed fds." 2022-02-18 00:24:12 +00:00
zijunzhao
75c36fe0c2 Add %m and %#x support for async_safe logging
Bugs: None
Test: None
Change-Id: I889015b89b85e222e26f8aa20e35d46a86a0cb7c
2022-02-17 07:23:58 +00:00
Elliott Hughes
62d49fd8e1 posix_spawn: always clear O_CLOEXEC for dup'ed fds.
dup2(2) is a no-op if the new and old fds are equal, but it's pretty
clear that any useful caller in the posix_spawn(3) context wants us to
clear O_CLOEXEC even if we don't actually "move" the fd.

Bug: https://www.austingroupbugs.net/view.php?id=411
Test: treehugger
Change-Id: I5ce1a1f9216df5afd295cc9e35b84527873e9541
2022-02-16 14:39:07 -08:00
Ryan Savitski
d4aa14d9dd profiling: override dumpability while opening /proc/self/mem,maps
For the perf profiling signal handler to succeed in opening
/proc/self/mem, the process needs to be marked as dumpable in posix
terms. This patch addresses a scenario since Android S where the process
is considered profileable, but is not dumpable on "user" builds. The
solution is to mark the process as dumpable while opening the procfs
descriptors, restoring the original value afterwards. This is the same
approach as the heapprofd heap profiler, which performs the override
within the loaded client library [1].

The particular scenario being addressed is:
* user build
* app does not explicitly opt into being profiled by shell
* app does not explicitly opt out of all profiling
In this case, the app is considered profileable by the platform (but NOT
shell). Therefore ActivityThread marks the process as profileable [2],
but the zygote keeps the process as undumpable as it considers the
profileability from the shell domain [3]. We could change the logic in
the zygote to leave such processes in the dumpable state, but the
override within the signal handler is considered to be more contained as
the dumpability is only needed temporarily.

This override would also apply for any non-dumpable native services that
are signalled for profiling, which is also desireable for profiling
coverage.

This change does not elide any of the existing profileability
checks by the signal handler's preamble and the profiler itself.

[1]
https://cs.android.com/android/platform/superproject/+/master:external/perfetto/src/profiling/memory/client.cc;l=184;drc=78cd82ba31233ce810618e07d349fd34efdb861d
[2]
https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/ActivityThread.java;l=6610;drc=de9cf3392d7872c2bee69b65a614e77bb166b26e
[3]
https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/jni/com_android_internal_os_Zygote.cpp;l=1680;drc=master

Tested: clock app on barbet-user succeeds in opening the procfs
descriptors within the signal handler.
Tested: systemwide profiling on sargo-userdebug works as before.
Bug: 196810669
BYPASS_INCLUSIVE_LANGUAGE_REASON=referencing the name of a cmdline utility
Change-Id: Id621d4312418ff0736c97065e9ee577ff67f40da
2022-02-11 16:31:24 +00:00
Mitch Phillips
9425b16978 [MTE] Relax ELF note.
Currently, the ELF note parsing in the loader is not permissive. This
patch relaxes the restrictions on the bits of the ELF note that could be
extended in the future.

This may allow more MTE options in apexes. If we add some extra metadata
bit (say, in bit 5) in the future, and then build MTE into every apex,
we don't want it to crash on Android 13 devices (we'd much rather it
just be a no-op).

Remove the (unused anywhere) NT_MEMTAG_DEFAULT and call it
NT_MEMTAG_NONE.

And finally, make the tests work on bionic-unit-tests-static. We
previously didn't deploy the test binaries, so add them as a data
dependency.

Bug: N/A
Test: atest bionic-unit-tests-static
Change-Id: I13530faad55c719c6eb848297f8ce378e18afbfc
2022-02-08 13:17:18 -08:00
Treehugger Robot
c81de9373a Merge "Avoid duplicate genrule locations" 2022-02-08 19:36:40 +00:00
Treehugger Robot
2be3e92943 Merge "[MTE] add sysprop to set mte state globally" 2022-02-08 16:47:32 +00:00
Colin Cross
aeef9f04d4 Avoid duplicate genrule locations
The bp2build build is failing with:
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:execinfo/include/execinfo.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/android/uapi/linux/compiler.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:b64/include/bionic/b64.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/uapi/linux/capability.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'
ERROR: /buildbot/src/android/master/out/soong/workspace/bionic/libc/BUILD.bazel:3187:8: Label '//bionic/libc:kernel/android/scsi/scsi/scsi.h' is duplicated in the 'srcs' attribute of rule 'libc_musl_sysroot_bionic_headers'

Rewrite the genrule to avoid referring to the same header twice by
using the NOTICE file as a known location in the bionic/libc directory.

Bug: 190084016
Bug: 218405924
Test: libc_musl_sysroot.zip has same contents
Change-Id: Id1a0484a3ed623bcc03b015d02eef19bbb31c06a
2022-02-07 21:08:41 -08:00
Treehugger Robot
b60ce71254 Merge changes from topics "musl_execinfo", "musl_mallinfo", "musl_sysroot"
* changes:
  Disable fortify tests for musl
  Export kernel uapi, execinfo and b64 headers to musl sysroot
  Export bionic's resolv base64 functions to musl
  Export bionic's execinfo functions to musl
  Enable mallinfo tests for musl
  Fix bionic benchmarks and header tests for musl
2022-02-08 01:32:59 +00:00
Mitch Phillips
93400371f7 [NFCI] Change Android's NT_TYPE to NT_ANDROID_TYPE.
Normally, platform-specific note types in the toolchain are prefixed
with the platform name. Because we're exposing the NT_TYPE_MEMTAG and
synthesizing the note in the toolchain in an upcoming patch
(https://reviews.llvm.org/D118948), it's been requested that we change
the name to include the platform prefix.

While NT_TYPE_IDENT and NT_TYPE_KUSER aren't known about or synthesized
by the toolchain, update those references as well for consistency.

Bug: N/A
Test: Build Android
Change-Id: I7742e4917ae275d59d7984991664ea48028053a1
2022-02-07 13:49:20 -08:00
Florian Mayer
dde3176a75 [MTE] add sysprop to set mte state globally
this can be used to run CTS w/ maximum MTE coverage on normal builds.

Change-Id: I527b8549f30fd4bd9511d94ca142ea08b72d1a78
2022-02-07 19:28:10 +00:00
Colin Cross
9d4a56e490 Export kernel uapi, execinfo and b64 headers to musl sysroot
The musl sysroot needs kernel uapi headers, export them as a zip
file.  Also include the execinfo and b64 headers for libexecinfo
and libb64 that are embedded in musl libc.

Bug: 190084016
Test: m USE_HOST_MUSL=true libc_musl_sysroot
Change-Id: Ie862934f6dabd3fc6cbb9f5be01e21549bce51c2
2022-02-03 16:25:38 -08:00
Colin Cross
9da85fa4a0 Export bionic's resolv base64 functions to musl
Musl doesn't provide the resolv b64_* functions, but adb uses them.
Export them from bionic.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I37837e6179a15754d4cbd89e67649df9dea9d9f1
2022-02-03 16:25:26 -08:00
Colin Cross
2a9843fe63 Export bionic's execinfo functions to musl
Musl doesn't provide the execinfo function.  Export the from bionic.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I0361b84b0160d419cd857f5bb1314a58d0a69234
2022-02-03 16:25:21 -08:00
Christopher Ferris
442544d7b4 Merge "Fix possible nullptr dereference." 2022-02-04 00:22:00 +00:00
Pirama Arumuga Nainar
db71defb66 Annotate fortify functions with diagnose_as_builtin
Bug: http://b/197147102
Bug: http://b/214080353

With https://reviews.llvm.org/D77491, clang got stricter when issuing
diagnostics regarding builtin functions.
https://reviews.llvm.org/D112024 adds a diagnose_as_builtin attribute
which lets it diagnose builtins even though their signature is slightly
different.  This patch adds diagnose_as_builtin attribute as needed.

Versioner is built with an older clang so it doesn't recognize this
attribute.  So this is added with a preprocessor check on clang
versions.  We can remove the version check once versioner gets updated
shortly after the compiler update.

Test: mmma bionic/tests with clang-r445002
Change-Id: I3d0d63ecdbea0cffe97eb5110e2d9f2a7595a38e
2022-02-03 11:53:52 -08:00
Christopher Ferris
d49ad1e39b Fix possible nullptr dereference.
Test: Unit tests pass.
Change-Id: I046c6e1665de4d941362e2f65605609e77731c97
2022-02-02 17:56:48 -08:00
Florian Mayer
6c1c3422a2 Fix HWASan crashes in heapprofd initialization.
Test: atest perfetto_integrationtests on HWASan build

Bug: 210588740
Change-Id: Iddaa4a7d0dedee541f97bbf0a13958de023bdf59
2022-02-01 17:10:32 +00:00
Treehugger Robot
650233457a Merge "Silence -Wnon-power-of-two-alignment for a test" 2022-01-29 01:04:50 +00:00
Pirama Arumuga Nainar
44dd9facb2 Silence -Wnon-power-of-two-alignment for a test
Bug: http://b/214080353

The wrong alignment to aligned_alloc() is deliberate.  Silence the
warning around the test.

Test: build with clang-r445002
Change-Id: I73bad7775423c908c2bbe1c550e8ce5aeede129d
2022-01-28 13:27:07 -08:00
Daniele Di Proietto
f7e721cdc9 Merge "Fix recursive deadlock inside bionic_systrace" 2022-01-26 23:12:27 +00:00
Daniele Di Proietto
f5f04b19fe Fix recursive deadlock inside bionic_systrace
The first time should_trace() returns true, bionic_trace_begin() calls
open() on trace_marker.

The problem is that open() can call bionic_trace_begin(). We've observed
this happening, for example when:

* fdtrack is enabled. dlopen("libfdtrack.so") can be used to enable
  fdtrack on a process.
* ThreadA is busy unwinding inside fdtrack and is holding an fdtrack
  internal mutex.
* ThreadB calls bionic_trace_begin() for the first time since the
  property "debug.atrace.tags.enableflags" contains ATRACE_TAG_BIONIC.
* ThreadB calls open("/sys/kernel/tracing/trace_marker"). Since fdtrack
  is enabled, ThreadB tries to do unwinding as well.
* ThreadB, inside fdtrack's unwinding tries to grab the same mutex that
  ThreadA is holding.
* Mutex contention is reported using bionic_systrace, therefore
  bionic_trace_begin() is called again on ThreadB.
* ThreadB tries to grab g_lock in bionin_systrace.cpp, but that's
  already held by ThreadB itself, earlier on the stack. Therefore
  ThreadB is stuck.

I managed to reproduce the above scenario by manually pausing ThreadA
inside unwinding with a debugger and letting ThreadB hitting
bionic_trace_begin() for the first time.

We could avoid using g_lock while calling open() (either by releasing
g_lock and reacquiring it later, or by using atomics), but
bionic_trace_begin() would try to call open() again. In my tests, open()
does not call bionic_trace_begin() a third time, because fdtrack has
reentrancy protection, but there might be another code path inside open
that calls bionic_trace_begin again (it could be racy or only happen in
certain configurations).

This commit fixes the problem by implementing reentrancy protection in
bionic_systrace.

Sample callstack from ThreadA deadlocked before the fix:
```
  * frame #0: 0x0000007436db077c libc.so`syscall at syscall.S:41
    frame #1: 0x0000007436db0ba0 libc.so`bionic_trace_begin(char const*) [inlined] __futex(ftx=0x000000743737a548, op=<unavailable>, value=2, timeout=0x0000000000000000, bitset=-1) at bionic_futex.h:45:16
    frame #2: 0x0000007436db0b8c libc.so`bionic_trace_begin(char const*) [inlined] __futex_wait_ex(ftx=0x000000743737a548, value=2) at bionic_futex.h:66:10
    frame #3: 0x0000007436db0b78 libc.so`bionic_trace_begin(char const*) [inlined] Lock::lock(this=0x000000743737a548) at bionic_lock.h:67:7
    frame #4: 0x0000007436db0b74 libc.so`bionic_trace_begin(char const*) [inlined] should_trace() at bionic_systrace.cpp:38:10
    frame #5: 0x0000007436db0b74 libc.so`bionic_trace_begin(message="Contending for pthread mutex") at bionic_systrace.cpp:59:8
    frame #6: 0x0000007436e193e4 libc.so`NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*) [inlined] NonPI::NormalMutexLock(mutex=0x0000007296cae9f0, shared=0, use_realtime_clock=false, abs_timeout_or_null=0x0000000000000000) at pthread_mutex.cpp:592:17
    frame #7: 0x0000007436e193c8 libc.so`NonPI::MutexLockWithTimeout(mutex=0x0000007296cae9f0, use_realtime_clock=false, abs_timeout_or_null=0x0000000000000000) at pthread_mutex.cpp:719:16
    frame #8: 0x0000007436e1912c libc.so`::pthread_mutex_lock(mutex_interface=<unavailable>) at pthread_mutex.cpp:839:12 [artificial]
    frame #9: 0x00000071a4e5b290 libfdtrack.so`std::__1::mutex::lock() [inlined] std::__1::__libcpp_mutex_lock(__m=<unavailable>) at __threading_support:256:10
    frame #10: 0x00000071a4e5b28c libfdtrack.so`std::__1::mutex::lock(this=<unavailable>) at mutex.cpp:31:14
    frame #11: 0x00000071a4e32634 libfdtrack.so`unwindstack::Elf::Step(unsigned long, unwindstack::Regs*, unwindstack::Memory*, bool*, bool*) [inlined] std::__1::lock_guard<std::__1::mutex>::lock_guard(__m=0x0000007296cae9f0) at __mutex_base:104:27
    frame #12: 0x00000071a4e32618 libfdtrack.so`unwindstack::Elf::Step(this=0x0000007296cae9c0, rel_pc=66116, regs=0x0000007266ca0470, process_memory=0x0000007246caa130, finished=0x0000007ff910efb4, is_signal_frame=0x0000007ff910efb0) at Elf.cpp:206:31
    frame #13: 0x00000071a4e2b3b0 libfdtrack.so`unwindstack::LocalUnwinder::Unwind(this=0x00000071a4ea1528, frame_info=<unavailable>, max_frames=34) at LocalUnwinder.cpp:102:22
    frame #14: 0x00000071a4e2a3ec libfdtrack.so`fd_hook(event=<unavailable>) at fdtrack.cpp:119:18
    frame #15: 0x0000007436dbf684 libc.so`::__open_2(pathname=<unavailable>, flags=<unavailable>) at open.cpp:72:10
    frame #16: 0x0000007436db0a04 libc.so`bionic_trace_begin(char const*) [inlined] open(pathname=<unavailable>, flags=524289) at fcntl.h:63:12
    frame #17: 0x0000007436db09f0 libc.so`bionic_trace_begin(char const*) [inlined] get_trace_marker_fd() at bionic_systrace.cpp:49:25
    frame #18: 0x0000007436db09c0 libc.so`bionic_trace_begin(message="pthread_create") at bionic_systrace.cpp:63:25
```

Bug: 213642769
Change-Id: I10d331859045cb4a8609b007f5c6cf2577ff44df
2022-01-25 20:50:12 +00:00
Peter Collingbourne
ccae7efeed Merge "Disable pointer authentication in app processes." 2022-01-24 21:17:30 +00:00
Peter Collingbourne
bf52e88596 Disable pointer authentication in app processes.
Unfortunately we have discovered that some applications in the wild
are using PAC instructions incorrectly. To keep those applications
working on PAC enabled devices, disable PAC in application processes
for now.

Bug: 212660282
Change-Id: I3030c47be9d02a27505bd4775c1982a20755758c
2022-01-19 13:35:54 -08:00
Treehugger Robot
5396787062 Merge "Fix copy pasta in guard macro for weak symbols." 2022-01-12 22:19:11 +00:00
Christopher Ferris
a479261feb Update to v5.16 kernel headers.
Kernel headers coming from:

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

Test: Builds and bionic unit tests pass.
Change-Id: I2522c4f2a0efb9f8a193e1f2d65868e478217502
2022-01-10 13:51:15 -08:00
Dan Albert
e4106253e7 Fix copy pasta in guard macro for weak symbols.
This was pretty broken. I think anything using this was being given
always-available annotations for everything but 32-bit x86? Treehugger
should complain loudly if this was actually impacting anything though.
I suspect not since the only user of this mode is mainline which
doesn't target far back enough to have arch-specific introduction
guards.

Test: treehugger
Bug: None
Change-Id: I64e96a89d83e64512e661e88915c48a091198992
2022-01-07 16:06:54 -08:00
Dan Albert
952da92670 Remove availability definitions for mbs APIs.
Definitions for these are provided in libandroid_support for API
levels that do not expose this in the stubs. For the rare cases where
libandroid_support is not being used this will result in a lower
quality diagnostic (undefined reference instead of "not available
until API 21"), but other fixes would also have that behavior because
the libandroid_support headers are *always* available, even if
libandroid_support won't be linked.

Test: Reverted xfailed tests for #1108 and reran tests with this
Bug: https://github.com/android/ndk/issues/1108
Change-Id: I371f5b9d7caeef8dc7c80f2f6d11280ecba119c9
2022-01-07 14:38:29 -08:00
Elliott Hughes
e2c784f159 Merge "c32rtomb/mbrtoc32: remove dead code." 2021-12-16 23:52:55 +00:00
Elliott Hughes
31fbc1469f sched.h: add doc comments.
Test: treehugger
Change-Id: I9a6dd40bb26a5966dd32dbdf573cddc874bcb508
2021-12-15 13:56:39 -08:00
Elliott Hughes
ad1658ecfe c32rtomb/mbrtoc32: remove dead code.
When we added the fast path for the common case of ASCII, we forgot to
remove the now-dead code that handled the 1-byte case later in these
functions. This was obvious from the code coverage data.

Note that the 16-bit variants are unaffected because they're implemented
as calls to the 32-bit variants with extra range checks/surrogate
handling surrounding the call.

Test: treehugger
Change-Id: Ibd40f823519acb9aae8037bdeb3f9c5e36b9d9a6
2021-12-15 13:41:20 -08:00
Christopher Ferris
8248e62fa9 Add mallinfo2 call.
Bug: 208293616

Test: New unit tests pass.
Change-Id: I619219b7322e2dd1c82b9c8a171dfbfe7eac6706
2021-12-13 14:26:17 -08:00
Elliott Hughes
ad12582726 Merge "strftime: format small positive integers ourselves." 2021-12-07 20:30:53 +00:00
Elliott Hughes
e4d5efe231 strftime: format small positive integers ourselves.
A decent chunk of the logcat profile is spent formatting the timestamps
for each line, and most of that time was going to snprintf(3). We should
find all the places that could benefit from a lighter-weight "format an
integer" and share something between them, but this is easy for now.

Before:

-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
BM_time_strftime        781 ns          775 ns       893102

After:

-----------------------------------------------------------
Benchmark                 Time             CPU   Iterations
-----------------------------------------------------------
BM_time_strftime        149 ns          147 ns      4750782

Much of the remaining time is in tzset() which seems unfortunate.

Test: treehugger
Change-Id: Ie0f7ee462ff1b1abea6f87d4a9a996d768e51056
2021-12-06 14:55:00 -08:00
Elliott Hughes
bb802661af Merge "Use -fno-builtin for libc and libm." 2021-12-03 15:55:35 +00:00
Elliott Hughes
a13d0660fe Use -fno-builtin for libc and libm.
clang was getting in the way of a strftime(3) optimization, and smaller
hammers weren't working, and this seems like the right choice for libc
anyway? If we have code that can usefully be optimized, we should do it
in the source. In general, though, no libc/libm author should be
ignorant of memset(3) or memcpy(3), and would have used it themselves if
it made sense. (And the compiler isn't using profiling data or anything;
it's just always assuming it should use the functions, and doesn't
consider whether the cost of the calls can be amortized or not.)

Test: treehugger
Change-Id: Ia7e22623e47bfbfcfe46c1af0d95ef7e8669c0f6
2021-12-02 14:42:16 -08:00
Alessio Balsini
5afe3f8a6a Allow bpf() syscall
The implementation of FUSE BPF requires the FUSE daemon to access BPF
functionalities, i.e., to get the fd of a pinned BPF prog and to update
maps.
In Android the FUSE daemon is part of MediaProvider which, belonging to
the apps domain, can only access the subset of syscalls allowed by
seccomp, of which bpf() is currently blocked.

This patch removes this limitation by adding the bpf() syscall to the
allowed seccomp syscalls.

Allowing the bpf() syscall is safe as its usage is still gated by
selinux and regular apps are not allowed to use it.

Bug: 202785178
Test: m
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I5887e8d22906c386307e54d3131c679fee0d9f26
2021-12-01 21:32:08 +00:00