Commit graph

42761 commits

Author SHA1 Message Date
Elliott Hughes
a8b8cd7be9 Merge "Remove workaround for a fixed bug." into main 2024-03-18 16:04:06 +00:00
Elliott Hughes
7b95053aa0 Remove workaround for a fixed bug.
We're still copy & pasting this workaround about, but the bug was supposedly fixed years ago!

Bug: http://b/34945607
Bug: http://b/33942619
Bug: http://b/34195559
Change-Id: Icf3d184d2ddb447dff7dacccea1dc903da816505
2024-03-16 00:22:00 +00:00
Treehugger Robot
5067ef29d4 Merge "Flush all the streams if CHECK() fails." into main 2024-03-15 21:04:53 +00:00
Elliott Hughes
dc0510ec17 Flush all the streams if CHECK() fails.
It's usually more helpful to see all the output so far.

If we're worried about fflush() failing because of the state we're in, we shouldn't be using stdio at all!

If this _does_ become a problem, we should probably switch to using the internal functions: `__assert2` for bionic, `__assert_fail` for musl/glibc, and `__assert_rtn` for macOS.

Unfortunately although `__assert2` and `__assert_fail` take the same arguments, they're in a different order, so we can't simply add a symbol alias to make that difference go away, and it's not clear that there's enough value to adding an otherwise unused symbol.

Change-Id: I653183737ab6368890bbd9d0e2f37fc5cb2e1dec
2024-03-15 15:23:12 +00:00
Ryan Prichard
3abc30d6a6 Merge "Make tests/libs/CHECK.h work on the host" into main 2024-03-14 23:15:19 +00:00
Ryan Prichard
68eb690f86 Merge changes Idb061b98,I93c17ca6 into main
* changes:
  ldd: skip relocation processing, TLS modules, CFI
  Guard against linker[64] having a PT_TLS segment
2024-03-14 22:58:51 +00:00
Ryan Prichard
32bb3673c1 ldd: skip relocation processing, TLS modules, CFI
This avoids a diagnostic on arm32/arm64 when running ldd on a shared
library with a PT_TLS segment:

executable's TLS segment is underaligned: alignment is 8, needs to be at least 64 for ARM64 Bionic

Bug: http://b/328822319
Test: ldd /system/lib64/libc.so
Change-Id: Idb061b980333ba3b5b3f44b52becf041d76ea0b7
2024-03-14 14:01:04 -07:00
Ryan Prichard
b4937462f5 Guard against linker[64] having a PT_TLS segment
The loader doesn't currently support using TLS within itself.
Previously, if a TLS segment was accidentally linked into the loader,
then the loader's `soinfo_tls* tls_` field would be initialized with a
valid TlsSegment, but the loader soinfo wouldn't be registered with
linker_tls.cpp, so the module ID would be 0. (The first valid module ID
is 1.)

The result was architecture-dependent. On x86, everything worked until
the first TLS access, which segfaulted. On arm64, relocating TLSDESC
hit a CHECK() failure on the invalid module ID.

Make the loader more robust:
 * Abort in the loader if it detects that it has a TLS segment.
 * For R_GENERIC_TLS_DTPMOD, verify that a module ID is valid before
   writing it.

Bug: none
Test: manually add a thread_local variable to the loader
Test: bionic-unit-tests
Change-Id: I93c17ca65df4af2d46288957a0e483b0e2b13862
2024-03-14 13:25:16 -07:00
Kalesh Singh
4fbcbbd522 Merge changes Ib76b022f,I98882edd,I575d626b into main
* changes:
  bionic: loader: Only zero the last partial page in RW segments
  Reapply "RELAND: bionic: loader: Extend GNU_RELRO protection"
  Reapply "RELAND: bionic: loader: Extend LOAD segment VMAs"
2024-03-14 20:22:26 +00:00
Elliott Hughes
63df96b7fb Merge "crt*.o cleanup." into main 2024-03-14 18:37:18 +00:00
Christopher Ferris
41cc7be55a Merge "Minor benchmark fixes." into main 2024-03-14 03:38:20 +00:00
Treehugger Robot
f3a8ae87fd Merge "Ignore bionic versioning in vendor modules" into main 2024-03-14 03:35:13 +00:00
Ryan Prichard
e4912ac995 Make tests/libs/CHECK.h work on the host
The `__assert2` function is not provided by glibc, in particular.

Bug: none
Test: manual
Change-Id: I72c428fd0794aceec2bfaf37638be0ff6a02f289
2024-03-13 18:31:15 -07:00
Elliott Hughes
8af71663c0 Merge "Fix orthography of GetTestLibRoot()." into main 2024-03-14 00:11:05 +00:00
Christopher Ferris
b2bb21da8d Minor benchmark fixes.
Change the AT_All_XXX to AT_ALL_XXX.

Change the name of the from_prot and to_prot parameters to be more
descriptive.

Add a few extra large page sizes. Without this, it jumps from a
relatively small size to an extreme large size and nothing in
between.

Clang-format modified the args_shorthand initialization.

Test: Ran benchmarks on device.
Change-Id: I5105788cbf05793fcb4d86c26037ec435635631e
2024-03-13 16:59:44 -07:00
Elliott Hughes
6a30b71b07 crt*.o cleanup.
Say .S instead of .c in a comment, and don't add an include directory we don't need.

Change-Id: I4cfc39904a4ad67a2aadb6691c527f7e38d9c4c7
2024-03-13 23:41:32 +00:00
Kalesh Singh
1d3ba112ab bionic: loader: Only zero the last partial page in RW segments
Only zero the partial page at the end of the segment. There may be
entire pages beyond first page boundary after the segment -- due to
segment padding (VMA extension); but these are not expected to be
touched (faulted).

Do not attempt to zero the extended region past the first partial page,
since doing so may:
  1) Result in a SIGBUS, as the region is not backed by the underlying
     file.
  2) Break the COW backing, faulting in new anon pages for a region
     that will not be used.

Bug: 327600007
Bug: 328797737
Test: Dexcom G7 app
Test: atest -c linker-unit-tests
Test: bootup/idle/system-processes-memory-direct
Change-Id: Ib76b022f94bfc4a4b7eaca2c155af81478741b91
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-03-13 13:40:28 -07:00
Kalesh Singh
702d9b0bad Reapply "RELAND: bionic: loader: Extend GNU_RELRO protection"
This reverts commit 26de64896c.

Bug: 328797737
Test: Dexcom G7 app
Change-Id: I98882edd17f0ea5432ab254482ab9508bfaf4f56
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-03-13 13:38:44 -07:00
Kalesh Singh
4084b555b2 Reapply "RELAND: bionic: loader: Extend LOAD segment VMAs"
This reverts commit 7a04fedc78.

Test: Dexcom G7 app
Bug: 328797737
Change-Id: I575d626b1313d1c66bf25f29c43a9a101024a4f8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-03-13 13:37:30 -07:00
Florian Mayer
60573deb72 Merge "Move memtag_stack out of libc_globals" into main 2024-03-13 17:54:37 +00:00
Elliott Hughes
eb75833834 Merge "Add missing documentation to <dlfcn.h>." into main 2024-03-13 14:48:50 +00:00
Justin Yun
ced630225a Ignore bionic versioning in vendor modules
Vendor modules do not follow bionic versioning but define their own
versioning for LLNDK. Ignore the __INTRODUCED_IN annotation for
vendor modules.

Bug: 302113279
Test: build trunk-staging and next configurations
Change-Id: I04646b524d17f7ae47f0f96cb98f221f3e821629
2024-03-13 21:02:58 +09:00
Elliott Hughes
eb4cf41766 Add missing documentation to <dlfcn.h>.
All the dude wanted was to mention that dlclose() can cause problems with thread locals...

Change-Id: Iea23c49b6b2d6d93b85b2aa0ab1183e68cf39695
2024-03-12 23:45:00 +00:00
Elliott Hughes
8d8138aad1 Fix orthography of GetTestLibRoot().
Change-Id: Ib052329b3ebced12a7e2d75b3628b33c7043e0d8
2024-03-12 22:37:13 +00:00
Florian Mayer
73750dc38e Move memtag_stack out of libc_globals
We cannot use a WriteProtected because we are accessing it in a
multithreaded context.

Test: atest memtag_stack_dlopen_test w/ MTE
Test: atest bionic-unit-tests w/ MTE
Test: atest bionic-unit-tests on _fullmte
Bug: 328256432
Change-Id: I39faa75f97fd5b3fb755a46e88346c17c0e9a8e2
2024-03-12 12:42:23 -07:00
Florian Mayer
5cc10a9a0d Merge "Make memtag_handle_longjmp precise" into main 2024-03-12 18:12:46 +00:00
Treehugger Robot
80e624632c Merge "Adding missing mm tests in syscall.xml" into main 2024-03-12 03:16:59 +00:00
Carlos Galo
4a98366070 Adding missing mm tests in syscall.xml
Bug: 327496587
Test: local build and run
Change-Id: I914fe3b6665acadb3f2c87333f85f5ff0374f678
Signed-off-by: Carlos Galo <carlosgalo@google.com>
2024-03-11 13:55:46 -07:00
Treehugger Robot
5ab3daa560 Merge changes Iec225109,I988e9495 into main
* changes:
  Add mprotect syscall benchmark
  Rename mmap benchmarks to mm benchmark
2024-03-09 05:01:03 +00:00
Carlos Galo
f86d29cc49 Add mprotect syscall benchmark
Specific parameters were chosen based on the frequency of their use in
Android.

Bug: 327496587
Test: local build and run
Change-Id: Iec225109f62e1e9cde133863d3cee8103172a6c8
Signed-off-by: Carlos Galo <carlosgalo@google.com>
2024-03-08 22:02:11 +00:00
Treehugger Robot
fd9824d0b1 Merge changes from topic "revert-2966884-NAVMRGEYJW" into main
* changes:
  Revert "RELAND: bionic: loader: Extend LOAD segment VMAs"
  Revert "RELAND: bionic: loader: Extend GNU_RELRO protection"
2024-03-08 03:41:08 +00:00
Elliott Hughes
7b6de468dd Merge "Make our <ctype.h> benchmarks less useless." into main 2024-03-08 01:04:22 +00:00
Kalesh Singh
7a04fedc78 Revert "RELAND: bionic: loader: Extend LOAD segment VMAs"
Revert submission 2966884

Reason for revert: b/328266487

Reverted changes: /q/submissionid:2966884

Bug: 328266487
Change-Id: I45a2c5888eefab36c069f992de00ec8c87105288
2024-03-07 13:32:34 -08:00
Kalesh Singh
26de64896c Revert "RELAND: bionic: loader: Extend GNU_RELRO protection"
Revert submission 2966884

Reason for revert: b/328266487

Reverted changes: /q/submissionid:2966884

Bug: 328266487
Change-Id: I3e61443302bf7fd8f58c843c9d7dc3c747897959
2024-03-07 13:32:23 -08:00
Xin Li
0ed1d35333 Merge "Merge Android 14 QPR2 to AOSP main" into main 2024-03-07 06:41:06 +00:00
Elliott Hughes
457dee1a33 Make our <ctype.h> benchmarks less useless.
Apparently we hadn't looked at the disassembly of these benchmarks since
implementing the various <ctype.h> functions inline, because they've all
been optimized away to literal loads of 0 or 1.

Obviously, this is not helpful when trying to judge further
optimizations.

Test: objdump and ran the benchmarks (on both arm64 and arm32)
Change-Id: Id66c4f7f4c92d9eee8937d31546158eda62ef3ba
2024-03-06 18:22:36 -08:00
Florian Mayer
0e1412e08e Make memtag_handle_longjmp precise
We would get the SP inside of memtag_handle_longjmp, which could prevent
us from detecting the case where a longjmp is going into a function that
had already returned. This changes makes the behaviour more predictable.

Change-Id: I75bf931c8f4129a2f38001156b7bbe0b54a726ee
2024-03-06 16:46:45 -08:00
Xin Li
14a7ebe3d2 Merge Android 14 QPR2 to AOSP main
Bug: 319669529
Merged-In: Ie84b92a2839ad09f5f73f1cce173df5a14e3e237
Change-Id: I855cd3db74a2b8ae33a09da35b7bcd067a435306
2024-03-06 09:29:44 -08:00
Carlos Galo
fb7dd9dd85 Rename mmap benchmarks to mm benchmark
This file no longer covers only mmap benchmarking, but also additional
memory related syscalls. Adjusting the name of this file to reflect the
broader utilization.

Bug: 327496587
Test: local build and run
Change-Id: I988e949589f9731fb1d85f489cd46ae64bf0a74c
Signed-off-by: Carlos Galo <carlosgalo@google.com>
2024-03-06 07:49:15 +00:00
Elliott Hughes
7c37e12827 Merge "Clarify the timespec argument to clock_nanosleep()." into main am: 70ecb746f3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2987070

Change-Id: Ie84b92a2839ad09f5f73f1cce173df5a14e3e237
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-05 15:44:19 +00:00
Elliott Hughes
c2ce647e2a Merge "Consistently use 'op' in argument names." into main am: 47f8ab80cc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2987969

Change-Id: Id162bd1a19777501ea982996f3689a22142e18e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-05 15:44:07 +00:00
Elliott Hughes
786484d808 Merge "_Fork(): clarify what not running pthread_atfork() handlers means in practice." into main am: 69bc81615b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2987030

Change-Id: Ic3bcc3ec2addc60edf75d612eb4c5bd35f902040
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-05 15:43:53 +00:00
Treehugger Robot
321ad5b869 Merge "Remove an unused include" into main am: 9d98e04aa9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2988089

Change-Id: Ibaeddef163e41c2fce7431fa5c7a6312c009d8aa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-05 15:43:38 +00:00
Elliott Hughes
70ecb746f3 Merge "Clarify the timespec argument to clock_nanosleep()." into main 2024-03-05 15:25:46 +00:00
Elliott Hughes
47f8ab80cc Merge "Consistently use 'op' in argument names." into main 2024-03-05 15:25:18 +00:00
Elliott Hughes
69bc81615b Merge "_Fork(): clarify what not running pthread_atfork() handlers means in practice." into main 2024-03-05 15:20:29 +00:00
Treehugger Robot
9d98e04aa9 Merge "Remove an unused include" into main 2024-03-05 15:07:03 +00:00
Ryan Prichard
cda3150674 Remove an unused include
Bug: none
Test: bionic-unit-tests
Change-Id: I738c24c82b5c4af5db275ba6566a5ba6f7d538ac
2024-03-04 17:29:41 -08:00
Ryan Prichard
0ba2cc0796 Merge "Revamp the elftls_dl.dtv_resize test" into main am: e6a4943dfa
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983767

Change-Id: I78ddfe29db66d1ce781f70b72a318c84f75980d3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-05 00:42:55 +00:00
Elliott Hughes
8dc9c1cad3 Clarify the timespec argument to clock_nanosleep().
Pointed out during review of a similar change to the man page.

Change-Id: I78f87bc4ff9fed773ca6f477e79f4a3fd507e056
2024-03-05 00:17:22 +00:00