Commit graph

40496 commits

Author SHA1 Message Date
Elliott Hughes
bb261225e0 Merge "Use the canonical idiom for sockaddr_storage." into main 2023-12-08 14:43:32 +00:00
Juan Yescas
93e0616836 Merge "16k: Set PTHREAD_STACK_MIN to 16384/8192 for 64-bit/32-bit archs" into main 2023-12-08 04:09:08 +00:00
Juan Yescas
c065a2731a 16k: Set PTHREAD_STACK_MIN to 16384/8192 for 64-bit/32-bit archs
Set PTHREAD_STACK_MIN will be set to:

- 16384 for 64-bit arch
- 8192 for 32-bit arch

Bug: 315174209
Test: Built and start the targets
      - aosp_cf_arm64_phone_pgagnostic
      - aosp_cf_x86_64_phone
Change-Id: I8bb20a3433e615f9f80a0d52051f2e1635d4301a
2023-12-07 16:07:08 -08:00
Juan Yescas
26cfc21243 Merge "16k: Fix linker_utils_test to support 4kb and 16kb page sizes" into main 2023-12-08 00:03:04 +00:00
Juan Yescas
21621b012f 16k: Fix linker_utils_test to support 4kb and 16kb page sizes
Add support for 16kb page sizes in the test cases: page_start
and page_offset.

Bug: 315174209
Test: atest -c linker-unit-tests
Change-Id: Ibaae493a0930f3f2df390a6af6c8a988a682fe52
2023-12-08 00:01:04 +00:00
Treehugger Robot
73d0d3520a Merge "Revert^2 "generate_notice.py: don't check for strings we don't use any more."" into main 2023-12-07 19:12:28 +00:00
Elliott Hughes
a7fcc1be3f Revert^2 "generate_notice.py: don't check for strings we don't use any more."
This reverts commit ef867550ac.

Reason for revert: a change to a python script run as a commit hook cannot cause a golang crash during builds.

Change-Id: Id63d4ea370e36f890a140b9e1bc69482e3610c42
2023-12-07 15:45:50 +00:00
Bob Yang
afd4f41337 Merge "Revert "generate_notice.py: don't check for strings we don't use any more."" into main 2023-12-07 08:14:22 +00:00
Bob Yang
ef867550ac Revert "generate_notice.py: don't check for strings we don't use any more."
This reverts commit adb8af2668.

Reason for revert: DroidMonitor: Potential culprit for Bug 315240955 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

BUG: 315240955
BUG: 315240463
Change-Id: I9f7297c6ca48728a91f7f4640ac19f901effb3cc
2023-12-07 07:12:02 +00:00
Evgenii Stepanov
73a867a203 Merge changes from topic "revert-2709995-VVPYYBKIHY" into main
* changes:
  Revert "Linker support for MTE globals."
  Revert "Add a memtag-globals test to bionic"
2023-12-07 01:36:49 +00:00
Treehugger Robot
aa56f2a2e1 Merge "generate_notice.py: don't check for strings we don't use any more." into main 2023-12-06 22:06:07 +00:00
Treehugger Robot
12c86dabf9 Merge "Extend MemtagNoteTest." into main 2023-12-06 21:44:45 +00:00
Elliott Hughes
adb8af2668 generate_notice.py: don't check for strings we don't use any more.
Test: `repo upload .`
Change-Id: Idba382c22fb562ca9ba5b9bbdfd3800279b04c25
2023-12-06 13:19:53 -08:00
Evgenii Stepanov
d957e96b58 Extend MemtagNoteTest.
Calling free() during system property init results in premature
allocator initialization. This has been fixed with a Scudo change in
https://r.android.com/2853684. This patch extends MemtagNoteTest to
verify that there are no stray PROT_MTE mappings when MTE is not
enabled in the binary.

Test: adb shell setprop arm64.memtag.bootctl memtag
      adb reboot
      bionic-unit-tests --gtest_filter=MemtagNoteTest.SEGV/*
Bug: 309698651
Change-Id: I6c7733d8799537d898c97b00d494ce6591cf44d9
2023-12-06 12:53:34 -08:00
Juan Yescas
b49314108d Merge "bionic: Do not use PAGE_SIZE to define PTHREAD_STACK_MIN" into main 2023-12-06 19:58:01 +00:00
Treehugger Robot
cd9814461f Merge "Revert "Disable MTE globals tests under HWASan"" into main 2023-12-06 19:46:44 +00:00
Evgenii Stepanov
6bbb75aa77 Revert "Linker support for MTE globals."
Revert submission 2709995

Reason for revert: linker crash in soinfo::apply_relr_reloc

Reverted changes: /q/submissionid:2709995

Bug: 314038442
Change-Id: I2c6ad7f46fb1174f009253602ad08ceb36aa7d71
2023-12-06 19:01:46 +00:00
Evgenii Stepanov
d0f4bd5939 Revert "Add a memtag-globals test to bionic"
Revert submission 2709995

Reason for revert: linker crash in soinfo::apply_relr_reloc

Reverted changes: /q/submissionid:2709995

Bug: 314038442
Change-Id: I416bff00ed3d530b3b6257362b2119c358e1d152
2023-12-06 19:01:17 +00:00
Evgenii Stepanov
b9cccdb357 Revert "Disable MTE globals tests under HWASan"
This reverts commit f71ee5adb7.

Reason for revert: linker crash in soinfo::apply_relr_reloc

Bug: 314038442
Change-Id: Ib2415519e37d6b2acb30f50afa6c45391e2a4b70
2023-12-06 18:58:10 +00:00
Elliott Hughes
75539ab928 Merge "riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers." into main 2023-12-06 17:57:53 +00:00
Elliott Hughes
20738af50e Merge "arm32 __bionic_call_ifunc_resolver: let the compiler handle initialization." into main 2023-12-06 16:18:01 +00:00
Elliott Hughes
4d06786ea8 arm32 __bionic_call_ifunc_resolver: let the compiler handle initialization.
I don't think we need this, and we're not doing it for the equivalent
code in riscv64. So either we do need it, and this will help us find out
quicker and make the corresponding riscv64 change, or we don't need it,
and this is a free cleanup.

Test: treehugger
Change-Id: Ie97492ea8bb4d1bc69f926980d9d4db798884285
2023-12-06 00:39:17 +00:00
Elliott Hughes
561e804ffb riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers.
This way, callees don't need to worry about whether or not their
reference to __riscv_hwprobe() has been resolved before their ifunc
resolver is called.

This matches the current glibc proposal from rivos.

Test: treehugger
Change-Id: I0d5244aa837d0d1f0e6bd7d22091dfedb8a55bdb
2023-12-05 16:31:59 -08:00
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
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
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
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
90088cc142 Merge "Re-enable LTO for linker" into main 2023-11-29 16:31:04 +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
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
7f221352e5 Merge "Disable MTE globals tests under HWASan" into main 2023-11-28 20:20:20 +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
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
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
c20bf013a1 Merge "string/memory functions: avoid qemu bugs/performance issues." into main 2023-11-17 17:47:20 +00:00
Elliott Hughes
63dce74ca0 Merge "libc_init_static.cpp: drop gold support." into main 2023-11-17 16:38:09 +00:00