Commit graph

41381 commits

Author SHA1 Message Date
Juan Yescas
b40f7b911d bionic: Do not use PAGE_SIZE to define PTHREAD_STACK_MIN
There is no need to use PAGE_SIZE to define the value of
PTHREAD_STACK_MIN.

Bug: 312546062
Bug: 313941999
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic-trunk-userdebug
      m
Change-Id: If3c3fe39f50592df58634d1c164e87dcd0aebad0
2023-12-05 16:03:33 -08:00
Elliott Hughes
28ea9363b6 Merge "Avoid multiple definitions of struct tcphdr." into main am: 001fabaa90
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2850373

Change-Id: I131d7a89cd8a50869f3c3c4595b0c7e5cc280e5e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-05 23:36:34 +00:00
Elliott Hughes
5850f6f3be Use the canonical idiom for sockaddr_storage.
This works out a bit silly/ugly because the bits/ header file has the
wrong name, so I've also changed the map from kernel struct to boolean
to be a map from kernel struct to filename. That not only fixes this,
it's a bit more readable too. (Just yesterday, when I had no real reason
to change it, I was asking myself "why is this a boolean?"!)

Bug: http://b/236042740
Test: treehugger
Change-Id: I3eee25b493ea97d46cc5dc5fde07f7c5e77d2a46
2023-12-05 23:13:01 +00:00
Elliott Hughes
001fabaa90 Merge "Avoid multiple definitions of struct tcphdr." into main 2023-12-05 23:09:32 +00:00
wuhaitao3
12f8ec4004 Closing the stream when the function returns
Test: build
Signed-off-by: wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>
Change-Id: I85a7935d911bf19c85c51a4c52a43e2efed34929
2023-12-05 03:29:10 +00:00
Florian Mayer
af06759667 Plumb scudo_stack_depot_size to debuggerd_process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

We already did the equivalent change for the ring buffer size in
https://r.android.com/q/topic:%22scudo_ring_buffer_size%22

Bug: 309446692
Change-Id: Icdcf4cd0a3a486d1ea07a8c616cae776730e1047
2023-12-04 16:49:35 -08:00
Treehugger Robot
03a3e97269 Merge "Re-enable LTO for libdl" into main am: 3c37d122eb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2853887

Change-Id: Id5a7d55d81bde0ada09bd582dece762d0fdb6419
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-30 16:41:00 +00:00
Treehugger Robot
3c37d122eb Merge "Re-enable LTO for libdl" into main 2023-11-30 15:55:05 +00:00
Yi Kong
9a8e6b80b1 Re-enable LTO for libdl
The build breakage is now fixed by the current stable Clang, workaround
is no longer needed.

Test: presubmit
Bug: 169004486
Change-Id: Id8df8efeb9f4183921cbf75f1c51b1507bff1eb0
2023-11-30 11:55:09 +09:00
Treehugger Robot
d70237c706 Merge "Remove fs_config_generator.py symlink" into main am: 042e4c50d1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2850374

Change-Id: I3e266af90c05f6d0a5d12bd6ddf117d6b5faeb7f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 19:53:28 +00:00
Elliott Hughes
222f4ca434 Merge "Avoid multiple definitions of sigaction." into main am: 3906f3bc83
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849972

Change-Id: Ia5a12021f333b6ef142a53511b2340eadb3862fc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 19:52:41 +00:00
Treehugger Robot
042e4c50d1 Merge "Remove fs_config_generator.py symlink" into main 2023-11-29 19:32:36 +00:00
Elliott Hughes
3906f3bc83 Merge "Avoid multiple definitions of sigaction." into main 2023-11-29 19:03:26 +00:00
Yi Kong
aeaf785726 Merge "Re-enable LTO for linker" into main am: 90088cc142
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849254

Change-Id: Iffecf5f9e11482d1b95e0f52561cb4cfe4973af9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 17:55:14 +00:00
Yi Kong
90088cc142 Merge "Re-enable LTO for linker" into main 2023-11-29 16:31:04 +00:00
Christopher Ferris
2a8df78b1b Merge "Add support for signal dumping log stats." into main am: 74ab77df47
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2848756

Change-Id: I508cc5ef729df7ca0920b273aa3e772b6ce066d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 04:22:21 +00:00
Christopher Ferris
74ab77df47 Merge "Add support for signal dumping log stats." into main 2023-11-29 02:56:59 +00:00
Cole Faust
b1a0a9da1d Remove fs_config_generator.py symlink
Symlinks were previously able to escape the genrule sandbox, but
after aosp/2850015 they can't.

Instead of a symlink, just use the fs_config_generator soong module.

Bug: 307824623
Test: generated_android_ids
Change-Id: Ifcd9eb06c46181903ff57713132940939d5facf6
2023-11-28 17:51:16 -08:00
Yi Kong
260625942f Re-enable LTO for linker
The build breakage is now fixed by the current stable Clang, workaround
is no longer needed.

Test: presubmit
Change-Id: Ice2863844ff886f503d50fa7a006cde78d16492d
2023-11-29 00:51:15 +00:00
Elliott Hughes
b4a9b17a55 Avoid multiple definitions of struct tcphdr.
No-one's hit this in practice, that I know of, but there are very few
instances of this old workaround for kernel/userspace mismatches still
present, and (as part of the much harder and less effective `struct
sigaction` cleanup), we should just remove them.

Bug: http://b/236042740
Test: treehugger
Change-Id: I6c71d4353044cf57cfa8a9796a4c3d6a4d51cd86
2023-11-28 15:41:54 -08:00
Treehugger Robot
6d76963490 Merge "Stop the kernel header scrubber from duplicating includes." into main am: 4195a49880
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849971

Change-Id: Id5f0cc8c72596e7db3d9d57891a011a8a23f1eee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 23:29:47 +00:00
Treehugger Robot
4195a49880 Merge "Stop the kernel header scrubber from duplicating includes." into main 2023-11-28 23:03:37 +00:00
Elliott Hughes
df53b16fca Avoid multiple definitions of sigaction.
Before this change, we have the kernel's sigaction in the uapi headers,
and our own sigaction in <bits/signal_types.h> and we rely on callers
making sure to use `#define` to move the kernel type out of the way if
they include a uapi header directly. This is obviously error-prone and
undesireable, and not what we usually do now.

What we _usually_ do now is use the header scrubber's ability to replace
a struct definition with a `#include <bits/STRUCT.h>`, but that doesn't
work here because struct sigaction relies on a lot of other types,
some of which also come from uapi headers.

So instead use our second best trick, which is to "move the kernel struct
out of the way" at header scrubbing time instead. This means that someone
who does `#include <linux/signal.h>` or `#include <asm/signal.h>` won't
get `struct sigaction` (they'll only have `struct __kernel_sigaction`
instead), but it does mean that they can't get two incompatible
definitions if they include a uapi header both directly and indirectly.

So although this doesn't do what I'd set out to do, it's still an
improvement in some cases, and it's our preferred idiom in most cases
anyway. (I'll come back once this is in to tidy up the two other kernel
structs where we're still using the deprecated "rename out of the way
using #define" trick, but this change is already hairy enough, and
there's a possibility it will break code that didn't care that it was
getting the kernel `struct sigaction` rather than the userspace one.)

Bug: http://b/236042740
Test: treehugger
Change-Id: Icff50e330c09c587e8f77ba0fb7cffffd9c3b708
2023-11-28 14:20:43 -08:00
Elliott Hughes
844e8fc324 Stop the kernel header scrubber from duplicating includes.
We'll probably never hit this (because the case I hit it with, struct
sigaction, isn't amenable to the "replace with #include <bits/STRUCT.h>"
trick), but in case we do, and because a set expresses our intent better
than a list, keep the list^Wset of generated includes in a set.

Bug: http://b/236042740
Test: treehugger
Change-Id: I21f5c08515eab1b28e6a36fc00149b6bc7740b7e
2023-11-28 14:01:46 -08:00
Christopher Ferris
5610d5a3a4 Add support for signal dumping log stats.
Adding the new option log_allocator_stats_on_signal that will call
mallopt(M_LOG_STATS, 0), when a signal is sent to a process.

This call does not happen in the signal handler, but a variable
is set to trigger the mallopt call. The next time any allocation
call occurs, the mallopt call will be made.

Also, includes new unit tests for the new config option.

Test: All unit tests pass.
Test: Enabling the new feature and stop/start and sending the signal to
Test: a process and observing the log contains the memory stats.
Test: Did the above for a scudo and jemalloc based device.
Change-Id: Idcf6fca74036efb065b9c4cc037aaf9bcf0f139e
2023-11-28 13:29:42 -08:00
Mitch Phillips
8b020893e5 Merge "Disable MTE globals tests under HWASan" into main am: 7f221352e5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2850627

Change-Id: I82ea4db246c26381872ab298f1f361a3b95422b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 20:54:41 +00:00
Mitch Phillips
7f221352e5 Merge "Disable MTE globals tests under HWASan" into main 2023-11-28 20:20:20 +00:00
Treehugger Robot
4c7788d4fc Merge "async_safe_log.cpp: remove unused #includes." into main am: ffbe696bb6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849965

Change-Id: I8f5964bcb2feed410c4a1f603237bd7f18fba245
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 18:48:34 +00:00
Mitch Phillips
f71ee5adb7 Disable MTE globals tests under HWASan
Bug: 313613493
Change-Id: Ie15852edc486944a1242dd7741a81e404bdb893f
Test: atest bionic-unit-tests under HWASan
2023-11-28 18:03:28 +00:00
Treehugger Robot
ffbe696bb6 Merge "async_safe_log.cpp: remove unused #includes." into main 2023-11-28 18:01:42 +00:00
Elliott Hughes
3f98012768 async_safe_log.cpp: remove unused #includes.
Test: treehugger
Change-Id: I044e58e9ab1163c94e9d4912b4d2412cffd3d4ad
2023-11-28 15:16:47 +00:00
Mitch Phillips
dd504fc03a Merge changes I2fc4fc9d,Id7b1a925 into main am: 456ce1e7ce
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2709995

Change-Id: Idbd9274dd084fcfde47360c8ab2eb630991228d9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 10:09:15 +00:00
Mitch Phillips
456ce1e7ce Merge changes I2fc4fc9d,Id7b1a925 into main
* changes:
  Add a memtag-globals test to bionic
  Linker support for MTE globals.
2023-11-28 09:31:57 +00:00
Treehugger Robot
9c3b74d1ac Merge "riscv64: correct comparison logic of have_fast_v" into main am: 0b4dfb9ba3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2844983

Change-Id: I31e51317b261a82b192cc521eae7d14691544d8c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 00:09:57 +00:00
Treehugger Robot
0b4dfb9ba3 Merge "riscv64: correct comparison logic of have_fast_v" into main 2023-11-27 22:52:28 +00:00
Kenny Gong
066f4b778b riscv64: correct comparison logic of have_fast_v
Change-Id: I47fdc0900a8edf878e99a57d6f06ff6e12ca74f2
Signed-off-by: Kenny Gong <kenny.gong@intel.com>
2023-11-23 11:14:45 +08:00
Mitch Phillips
057c8ddd71 Add a memtag-globals test to bionic
This test comes in two flavours: a prebuilt, and one from source (which is used
to generate the prebuilt). For now, the in-tree prebuilt compiler isn't
new enough to actually build binaries with proper MTE globals support,
so I've provided prebuilts using a tip-of-tree compiler. Thus, the MTE
globals support in the linker can be experimented on, tested, and
(hopefully) submitted while not being blocked on the toolchain roll.

You can see the binaries have MTE globals by grabbing a tip-of-tree
compiler, and running 'llvm-readelf --memtag <bin>'.

Bug: N/A
Test: atest bionic-unit-tests --test-filter=*Memtag*
Change-Id: I2fc4fc9d1c6ddd16c2204dd728d4ebe463928522
2023-11-20 15:53:14 +01:00
Mitch Phillips
e8139f585a Linker support for MTE globals.
This patch adds the necessary bionic code for the linker to protect
global data using MTE.

The implementation is described in the MemtagABI addendum to the
AArch64 ELF ABI:
https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst

In summary, this patch includes:

1. When MTE globals is requested, the linker maps writable SHF_ALLOC
   sections as anonymous pages with PROT_MTE (copying the file contents
   into the anonymous mapping), rather than using a file-backed private
   mapping. This is required as file-based mappings are not necessarily
   backed by the kernel with tag-capable memory. For sections already
   mapped by the kernel when the linker is invoked via. PT_INTERP, we
   unmap the contents, remap a PROT_MTE+anonymous mapping in its place,
   and re-load the file contents from disk.

2. When MTE globals is requested, the linker tags areas of global memory
   (as defined in SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC) with random tags,
   but ensuring that adjacent globals are never tagged using the same
   memory tag (to provide detemrinistic overflow detection).

3. Changes to RELATIVE, ABS64, and GLOB_DAT relocations to load and
   store tags in the right places. This ensures that the address tags are
   materialized into the GOT entries as well. These changes are a
   functional no-op to existing binaries and/or non-MTE capable hardware.

Bug: N/A
Test: atest bionic-unit-tests CtsBionicTestCases --test-filter=*Memtag*

Change-Id: Id7b1a925339b14949d5a8f607dd86928624bda0e
2023-11-20 15:53:06 +01:00
Prashanth Swaminathan
453fbd0e9a Merge "string/memory functions: avoid qemu bugs/performance issues." into main am: c20bf013a1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2806377

Change-Id: I9a70563b39564b75bf952ae8e78339ebb7d42e52
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-17 18:12:56 +00:00
Prashanth Swaminathan
c20bf013a1 Merge "string/memory functions: avoid qemu bugs/performance issues." into main 2023-11-17 17:47:20 +00:00
Elliott Hughes
b620ed5206 Merge "libc_init_static.cpp: drop gold support." into main am: 63dce74ca0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2836070

Change-Id: I92ae7e48c6dd5b61f2b7e4e10d95ee8dbad032ee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-17 17:07:50 +00:00
Elliott Hughes
63dce74ca0 Merge "libc_init_static.cpp: drop gold support." into main 2023-11-17 16:38:09 +00:00
Elliott Hughes
d65368e7d7 libc_init_static.cpp: drop gold support.
The NDK no longer includes gold, so static binaries built by the NDK no
longer need to support gold.

Test: bionic static unit tests
Change-Id: Idddcb9eb18921acfc1ae2a3c755592a5ab30290a
2023-11-16 17:31:09 -08:00
Elliott Hughes
aefe999d92 string/memory functions: avoid qemu bugs/performance issues.
Use V on real hardware, but GC on qemu.

Change-Id: I419546d94555540e14a14dcc52bd99413cbbcfa1
2023-11-15 15:49:57 -08:00
Hans Boehm
d78eaf67b3 Merge "Better obstruct optimization for ordering test" into main am: 87ce3a2dc5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2828516

Change-Id: I05688531b7e511ae60f04b646a73f222fc4c2571
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-15 06:34:36 +00:00
Hans Boehm
87ce3a2dc5 Merge "Better obstruct optimization for ordering test" into main 2023-11-15 05:59:20 +00:00
Treehugger Robot
ec6677350c Merge "Move ; in NDK declaration" into main am: c6034e4228
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2830814

Change-Id: I7d14f0627c687dbb0f5141c34009fedc87f8cd07
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-15 00:49:19 +00:00
Treehugger Robot
c6034e4228 Merge "Move ; in NDK declaration" into main 2023-11-15 00:26:40 +00:00
Nate Myren
4b94522c14 Move ; in NDK declaration
per comment on aosp/2796861, it should be at the end of the line

Bug: 291814949
Test: presubmit
Change-Id: Ib104d6764791b7a2507e371d955cbd8e69e3ccdc
2023-11-14 15:28:57 -08:00
Hans Boehm
71eb46fc00 Better obstruct optimization for ordering test
... to make sure that stores to the same locations are harder to
eliminate.

Also ensure that reader gets a chance to run by sleeping if necessary.

Bug: 308744279
Test: atest stdatomic
Test: Check that we don't usually sleep.
Change-Id: Iddab2a109525f96e065ac8331f227baa08dd8e22
2023-11-14 14:11:25 -08:00