Commit graph

43339 commits

Author SHA1 Message Date
Mitch Phillips
ebc2ac934f Rename GWP-ASan android_mallopt() arguments
The previous names were difficult to decipher. Now, let's change this
all to be more clear as it's actually one android_mallopt() call
depending on where it's called from, rather than the intended behaviour.

Also updated the comments so it's clear what happened across different
versions of Android.

Test: atest bionic-unit-tests CtsGwpAsanTestCases
Bug: N/a
Change-Id: I0582cab0b74aa09f4af54f9fbe5ba22697f82082
2024-05-03 13:20:45 +02:00
Jiyong Park
35a280d818 Export capability.h as a filegroup
... so that it can be used by fs_config_[dirs|files] genrules.
Previously, the fs_config_* were created by Android.mk and capability.h
was referenced directly from there. Since Soong doesn't allow that,
let's export the file explicitly.

Bug: 337993745
Test: m
Change-Id: I2777a4dbe6b977bc64c5f6defe748fa7993e578e
2024-05-03 16:53:39 +09:00
Ryan Prichard
0bac1cb8b9 Revert^2 "Switch the loader to a noexcept version of libc++"
This CL reverts commit 698ca39c9e.

Bug: 332594828
Test: treehugger
Change-Id: I4b107e4bdd3b3bef25f531fcaa58d2ae8b8270f9
2024-05-03 01:18:17 +00:00
Treehugger Robot
acc737457f Merge "Update the _FORTIFY_SOURCE documentation." into main am: b1f23829ee am: 074d6d5904
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3072723

Change-Id: Iae66aa938ce8f8f6bb0c57af49a40ee114686f61
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:46:06 +00:00
Treehugger Robot
26805ed03c Merge "Add deprecation message for __sF." into main am: a97a4754a3 am: c897f66c3b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3073023

Change-Id: Iee6c3bd78a6cbc9d3884d20ef6229f0acbb3b1b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:45:56 +00:00
Treehugger Robot
0ec69dc084 Merge "Allow deprecation messages." into main am: 000745aa37 am: 4793fa0261
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3070007

Change-Id: I0653fc0b2f817372dfdd0956d3752e911feb427f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:44:56 +00:00
Treehugger Robot
074d6d5904 Merge "Update the _FORTIFY_SOURCE documentation." into main am: b1f23829ee
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3072723

Change-Id: I397fd9ead97e14ab07e312252a63218968e020c1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:31:33 +00:00
Treehugger Robot
b1f23829ee Merge "Update the _FORTIFY_SOURCE documentation." into main 2024-05-02 22:27:12 +00:00
Treehugger Robot
c897f66c3b Merge "Add deprecation message for __sF." into main am: a97a4754a3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3073023

Change-Id: I624755c215e574f7fbe12946aeeaa11fe404a91d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:23:52 +00:00
Treehugger Robot
a97a4754a3 Merge "Add deprecation message for __sF." into main 2024-05-02 22:19:13 +00:00
Treehugger Robot
4793fa0261 Merge "Allow deprecation messages." into main am: 000745aa37
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3070007

Change-Id: I0b07b582da71328c40ea59074e9ffddef482360d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 22:17:55 +00:00
Treehugger Robot
000745aa37 Merge "Allow deprecation messages." into main 2024-05-02 21:53:15 +00:00
Kalesh Singh
acef2292e8 Merge changes from topic "pgsize_compat_loader" into main am: 403ea86b2e am: 472cb3a522
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3006239

Change-Id: Ia57a59bc7b4e9575112d7f47ce7bdbd3542c6545
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 20:09:14 +00:00
Kalesh Singh
05bdc26235 loader: Only extend segments if kernel supports page size migration am: c5c1d19ebb am: e560bde675
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3035335

Change-Id: Idfaf0120284506acf7fdd43af42cf66494606466
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 20:09:11 +00:00
Kalesh Singh
f06662906d bionic: loader: Don't extend LOAD segments for p_aligns > 64KiB am: e1e747984f am: 5c82c3d47d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3035334

Change-Id: I53a90d76b8cd8396fa557162b21f366fbf355681
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 20:09:08 +00:00
Dan Albert
cc86c74362 Add deprecation message for __sF.
Bug: None
Test: treehugger
Change-Id: I9dd9e77ad024c2ea292f021bb2709378f755c1d8
2024-05-02 20:05:29 +00:00
Dan Albert
398e1aa030 Allow deprecation messages.
I'll land another patch that makes this required once I've fixed up
all the callers.

Bug: https://github.com/android/ndk/issues/2014
Test: treehugger
Change-Id: I62b9fdd3174f37d33f01c27f7f4e9134f6d9df6e
2024-05-02 20:05:28 +00:00
Kalesh Singh
472cb3a522 Merge changes from topic "pgsize_compat_loader" into main am: 403ea86b2e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3006239

Change-Id: I87ae5645545a7a116be0fae34814ea93eafaed54
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 19:54:54 +00:00
Kalesh Singh
e560bde675 loader: Only extend segments if kernel supports page size migration am: c5c1d19ebb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3035335

Change-Id: Ie2eec54ba3c7307ae138787cf7f12a7e7992e941
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 19:54:51 +00:00
Kalesh Singh
5c82c3d47d bionic: loader: Don't extend LOAD segments for p_aligns > 64KiB am: e1e747984f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3035334

Change-Id: Ie39a7a611d2698db3561e8cbd85549be87cc4086
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 19:54:48 +00:00
Kalesh Singh
403ea86b2e Merge changes from topic "pgsize_compat_loader" into main
* changes:
  bionic: loader: Drop readahead padding pages
  loader: Only extend segments if kernel supports page size migration
  bionic: loader: Don't extend LOAD segments for p_aligns > 64KiB
2024-05-02 19:38:08 +00:00
Elliott Hughes
10a7e2799d Update the _FORTIFY_SOURCE documentation.
Change-Id: Icc73673b792dbc1a20ed70561a461e1fc47b2d6b
2024-05-02 19:13:37 +00:00
Treehugger Robot
37e064f062 Merge "Remove historical cruft." into main am: 4981a83859 am: b10c2dcaf2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3071102

Change-Id: I9015f102ad6f8e93f396fb14e01c71b0d52ee3ff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 18:42:56 +00:00
Treehugger Robot
c2df373993 Merge "__system_property_add: log specifics about failures." into main am: 728980c691 am: 8fe81d38fb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3069162

Change-Id: Id0e22946b74acf96ba55a217c85d968fbe883162
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 18:42:02 +00:00
Treehugger Robot
b10c2dcaf2 Merge "Remove historical cruft." into main am: 4981a83859
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3071102

Change-Id: Ieb3ff0e397e65618178adc5b170b186bc70e59b7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 18:21:01 +00:00
Treehugger Robot
8fe81d38fb Merge "__system_property_add: log specifics about failures." into main am: 728980c691
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3069162

Change-Id: I09f9c94daaa2c1624c99afe415a21d4bfcc16ba0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-02 18:19:26 +00:00
Treehugger Robot
4981a83859 Merge "Remove historical cruft." into main 2024-05-02 18:13:47 +00:00
Kalesh Singh
5134762efa bionic: loader: Drop readahead padding pages
These are padding pages are only needed to layout the ELF to be
compatible with max-page-size. They are zero-filled (holes) and
can be dropped from the page cache.

The madvise() here is a special case that also serves to hint to the
kernel what part of the segment is padding.

For example the kernel then shows these padding regions as PROT_NONE
VMAs (labeled [page size compat]) in /proc/*/maps.

Note: This doesn't use backing vm_area_structs, so doesn't consume
additional slab memory.

Before:

❯ cf-adb shell cat /proc/1/maps | grep -A1 'libbase.so$'
7f8d13600000-7f8d13614000 r--p 00000000 fe:09 21909460    /system/lib64/libbase.so
7f8d13614000-7f8d13638000 r-xp 00014000 fe:09 21909460    /system/lib64/libbase.so
7f8d13638000-7f8d1363c000 r--p 00038000 fe:09 21909460    /system/lib64/libbase.so
7f8d1363c000-7f8d1363d000 rw-p 0003c000 fe:09 21909460    /system/lib64/libbase.so

Segments appear extended in /proc/<pid>/maps

After:

❯ cf-adb shell cat /proc/1/maps | grep -A1 'libbase.so$'
7f3650043000-7f3650054000 r--p 00000000 fe:09 21906900    /system/lib64/libbase.so
7f3650054000-7f3650057000 ---p 00000000 00:00 0           [page size compat]
7f3650057000-7f3650079000 r-xp 00014000 fe:09 21906900    /system/lib64/libbase.so
7f3650079000-7f365007b000 ---p 00000000 00:00 0           [page size compat]
7f365007b000-7f365007c000 r--p 00038000 fe:09 21906900    /system/lib64/libbase.so
7f365007c000-7f365007f000 ---p 00000000 00:00 0           [page size compat]
7f365007f000-7f3650080000 rw-p 0003c000 fe:09 21906900    /system/lib64/libbase.so

Segments maintain PROT_NONE gaps ("[page size compat]") for app
compatiblity but these are not backed by actual slab VMA memory.

Bug: 330117029
Bug: 327600007
Bug: 330767927
Bug: 328266487
Bug: 329803029
Test: Manual - Launch Free Fire Chaos app
Change-Id: Ic50540e247b4294eb08f8cf70e74bd2bf6606684
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-05-02 11:06:53 -07:00
Kalesh Singh
c5c1d19ebb loader: Only extend segments if kernel supports page size migration
It has been found that some existing apps have implicit dependencies on
the address ranges in /proc/*/maps. Since segment extension changes the
range of the LOAD segment VMAs some of these apps crash, either by
SIGBUS or in yet unidentified ways.

Only perform the segment extension optimization if the kernel has the
necessary mitigations to ensure app compatibility.

Bug: 330117029
Bug: 327600007
Bug: 330767927
Bug: 328266487
Bug: 329803029
Test: Manual - Launch Free Fire Chaos app
Change-Id: I5b03b22c4a468f6646750a00942cc2d57f43d0de
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-05-02 11:06:51 -07:00
Treehugger Robot
728980c691 Merge "__system_property_add: log specifics about failures." into main 2024-05-02 18:03:48 +00:00
Kalesh Singh
e1e747984f bionic: loader: Don't extend LOAD segments for p_aligns > 64KiB
Loader segment extension was introduced to fix kernel slab memory
regressions in page-agnostic Android. This reression was due to required
VMAs for the gap VMAs that exist when the elf-max-page-size >
runtime-page-size.

This issue already existed for some libraries like libart.so and
libhwui.so which use 2mB alignment to make use of THPs (transparent huge
pages).

Later it was found that this optimization could break in-field apps due
to dependencies and the address ranges in /proc/*/[s]maps.

To avoid breaking the in-field apps, the kernel can work around the
compatibility issues if made aware of where the padding regions exist.
However, the kernel can only represent padding for p_align up to 64KiB.
This is because the kernel uses 4 available bits in the vm_area_struct
to represent padding extent; and so cannot enable mitigations to avoid
breaking app compatibility for p_aligns > 64KiB.

For ELFs with p_align > 64KiB, don't do segment extension, to avoid issues
with app compatibility -- these ELFs already exist with gap mappings
and are not part of the page size transition VMA slab regression.

Bug: 330117029
Bug: 327600007
Bug: 330767927
Bug: 328266487
Bug: 329803029
Test: Manual - Launch Free Fire Chaos app
Change-Id: Id4dcced4632dce67adab6348816f85847ce1de58
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-05-02 09:26:10 -07:00
Elliott Hughes
622b6aeeef __system_property_add: log specifics about failures.
Failure to add a property should be rare, so log the specific
failure to aid in debugging.

Bug: http://b/322714325
Change-Id: I9461428f16d7d04d5aceb910a5cf1c928cfe9da2
2024-05-01 23:46:45 +00:00
Elliott Hughes
a8cd731c2b Remove historical cruft.
We're definitely on a new enough clang now...

Change-Id: I7ec4ad0e78872edbde05a31574dd78f219bb115c
2024-05-01 22:43:31 +00:00
Christopher Ferris
b54250572d Change malloc_not_svelte to malloc_low_memory.
The malloc_not_svelte product variable has been removed and is
replaced by malloc_low_memory. This switches the sense of the

Test: Verified scudo config is used by default.
Test: Verified Android GO config uses the jemalloc low memory config.
Test: Verified that the default config on oriole produces the exact same
Test: libc.so with and without this change.
Change-Id: I48085fa6c2dcf5c61f847ef1f15c38653d1f7214
2024-05-01 15:33:45 -07:00
Treehugger Robot
a5569944be Merge "16k: bionic: Replace hardcoded page size with getpagesize()" into main am: 4d9af810fd am: 939d7ae914
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3069105

Change-Id: I7bf6c803a8e47071cbac75203376241024eab6f4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-01 17:02:26 +00:00
Treehugger Robot
939d7ae914 Merge "16k: bionic: Replace hardcoded page size with getpagesize()" into main am: 4d9af810fd
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3069105

Change-Id: I01cba7ceeeebb31d85db6659a9271a31eeedd882
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-05-01 16:37:02 +00:00
Treehugger Robot
4d9af810fd Merge "16k: bionic: Replace hardcoded page size with getpagesize()" into main 2024-05-01 16:14:52 +00:00
Vilas Bhat
297e7dd30f 16k: bionic: Replace hardcoded page size with getpagesize()
The optional block size for the /proc filesystem is set to page size.
The tests must reflect the same.

Bug: 315510913
Change-Id: Ifccf833829b4ea4ff9c7d375208124cdc43af04a
2024-05-01 01:14:56 +00:00
Florian Mayer
c1bd1dda3a Merge "Make "remapping stacks as PROT_MTE" debug log" into main am: fb48ddc964 am: bed8016955
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3065926

Change-Id: I22e39dc68b9b0f2d0573f79364519494ac9b5c29
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-30 20:21:11 +00:00
Florian Mayer
bed8016955 Merge "Make "remapping stacks as PROT_MTE" debug log" into main am: fb48ddc964
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3065926

Change-Id: If04171c1eb019f672dfcce2024289c26a1abdd5b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-30 19:38:11 +00:00
Florian Mayer
fb48ddc964 Merge "Make "remapping stacks as PROT_MTE" debug log" into main 2024-04-30 19:18:36 +00:00
Florian Mayer
05c16e7f54 Make "remapping stacks as PROT_MTE" debug log
This was spamming logcat

Change-Id: I3255b583d594a91faae8680aaef94d793c3c26a9
2024-04-30 18:13:14 +00:00
Elliott Hughes
2cb084bb81 Merge "Upstream sync." into main am: f390fbca3e am: a8f36d705a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3066063

Change-Id: Ib7d57b4c51285d355a282e9cb148dff8c30c8b84
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-30 16:18:41 +00:00
Elliott Hughes
a8f36d705a Merge "Upstream sync." into main am: f390fbca3e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3066063

Change-Id: I027621db6f0b8dfb0ea18af439a127ea98f9cfb3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-30 15:59:59 +00:00
Elliott Hughes
f390fbca3e Merge "Upstream sync." into main 2024-04-30 15:29:31 +00:00
Elliott Hughes
81c54c72b3 Upstream sync.
Also clean up some obsolete cruft from openbsd-compat.h...

Test: treehugger
Change-Id: I9eae0f8304e701d032045617427289002d234cd8
2024-04-29 23:41:39 +00:00
Treehugger Robot
ae321426de Merge "[scudo] -1 is also valid for M_DECAY_TIME" into main am: cdbc7c75f5 am: 4beac394ce
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3047793

Change-Id: I648f406214e8237c5bea5e9183c608acdb02e9c6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-29 20:44:03 +00:00
Treehugger Robot
4beac394ce Merge "[scudo] -1 is also valid for M_DECAY_TIME" into main am: cdbc7c75f5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3047793

Change-Id: I99499c7b8ff09c7143fe213fa06106115a22f3f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-04-29 20:25:07 +00:00
Treehugger Robot
cdbc7c75f5 Merge "[scudo] -1 is also valid for M_DECAY_TIME" into main 2024-04-29 20:07:46 +00:00
Chia-hung Duan
6abb406e0a [scudo] -1 is also valid for M_DECAY_TIME
Test: Run tests
Change-Id: I044ef84bf0ec97c0f8cb8d3a2340b82218d85efc
2024-04-26 15:24:24 -07:00