Commit graph

43186 commits

Author SHA1 Message Date
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
Ryan Prichard
e6a4943dfa Merge "Revamp the elftls_dl.dtv_resize test" into main 2024-03-04 23:54:57 +00:00
Elliott Hughes
364fc76047 Consistently use 'op' in argument names.
This matches changes being made to regularize the man page terminology.

Change-Id: If949cf81a0a0a06f24a4a742e8bf45c53dbd0da1
2024-03-04 23:48:00 +00:00
Elliott Hughes
8257268d04 _Fork(): clarify what not running pthread_atfork() handlers means in practice.
Change-Id: I0546069bbef730ffc23b3cea90fe7280d905d885
2024-03-04 22:24:01 +00:00
Android Build Coastguard Worker
745f14243e Snap for 11520864 from 86c4274601 to 24Q2-release
Change-Id: I8dcf1b7c5d798beb5cb218092fcbeb46640c18be
2024-03-02 02:01:02 +00:00
Ryan Prichard
98731dc343 Revamp the elftls_dl.dtv_resize test
Split the test out into a separate executable to reduce the number of
ELF modules in the DTV, so that the test can more easily observe the
behavior of loading a module that requires doubling the DTV size. We
want to see the DTV expand from 5 entries (8 words w/header) to
13 entries (16 words w/header).

Make the test work with an initial number of ELF TLS modules between
2 and 4.

Bug: http://b/175635923
Test: bionic-unit-tests
Change-Id: I1e91b4462987a5c80e13838669c359053f5a62f6
2024-03-01 00:22:39 -08:00
Treehugger Robot
86c4274601 Merge "Correct the nullability annotation in posix_spawnattr_init()" into main am: 2c0e9a58ea am: b4d8542a84
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983453

Change-Id: Ife16f42b6fa80a42486f11647dfb51e87faed461
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-01 04:08:41 +00:00
Treehugger Robot
b4d8542a84 Merge "Correct the nullability annotation in posix_spawnattr_init()" into main am: 2c0e9a58ea
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983453

Change-Id: Ib3fd19948abcb9f10e6ed4e4e2a9a16835c91c9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-01 03:26:47 +00:00
Treehugger Robot
2c0e9a58ea Merge "Correct the nullability annotation in posix_spawnattr_init()" into main 2024-03-01 02:40:32 +00:00
Elliott Hughes
102ba4182d Merge "Add _Fork()." into main am: a216b269ef am: 335380e79a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2976351

Change-Id: I85962ff0cdcd88f849059668de7ad9e26318ddb7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-03-01 00:11:07 +00:00
Android Build Coastguard Worker
b5cf284375 Snap for 11517367 from eb5526ce4d to 24Q2-release
Change-Id: I3c9369b273c1d7002a34145b4261c565d5789d4f
2024-03-01 00:01:18 +00:00
Elliott Hughes
335380e79a Merge "Add _Fork()." into main am: a216b269ef
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2976351

Change-Id: I3292deb2184c7f88b39e2ee9d817775031bfbfb7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29 23:29:07 +00:00
zijunzhao
148476d91c Correct the nullability annotation in posix_spawnattr_init()
The input __attr should be allowed to point to null.

Bugs: b/245972273
Test: adb shell
Change-Id: Id433d220e7c074ca68e2541371491975b33928ed
2024-02-29 22:55:00 +00:00
Elliott Hughes
a216b269ef Merge "Add _Fork()." into main 2024-02-29 22:25:45 +00:00
Elliott Hughes
2411fff9f2 Add _Fork().
POSIX issue 8 function, already in musl/glibc (but not iOS/macOS).

Bug: https://austingroupbugs.net/view.php?id=62
Test: treehugger
Change-Id: Id51611afdab92dff36a540b7d8737fc0e31f3d36
2024-02-29 20:50:58 +00:00
Treehugger Robot
eb5526ce4d Merge "Remove unnecessary includes" into main am: 9218876df0 am: 91a073d442
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983496

Change-Id: I7e50e72d0be09d1e49c9a29711a68d581a0c8a9a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29 17:19:29 +00:00
Treehugger Robot
91a073d442 Merge "Remove unnecessary includes" into main am: 9218876df0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2983496

Change-Id: I5d0ed4bbda78c7989cf44c2fd0d5feb58b3319d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-29 16:38:03 +00:00
Treehugger Robot
9218876df0 Merge "Remove unnecessary includes" into main 2024-02-29 15:57:14 +00:00
Florian Mayer
5f177e3746 Remove unnecessary includes
Test: debuggerd_test, CtsCrashDetailHostTestCases
Change-Id: Iceb0458d953f23aff13576a45c2f6a616c40c1a5
2024-02-28 17:28:54 -08:00
Android Build Coastguard Worker
10defcba7d Snap for 11510485 from 824fa8065c to 24Q2-release
Change-Id: Icd93529aa7fb6ece6494d358ec8ab84ae450972d
2024-02-29 00:01:18 +00:00
Steven Moreland
0a645ac4d3 Merge "Add ..DEPRECATED_PAGE_SIZE macro" into main am: 2215ad406b am: d29e333562
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2978135

Change-Id: I95fe9fe6ba6dafb57828acb98e980787b9126ef1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 23:11:05 +00:00
Steven Moreland
d29e333562 Merge "Add ..DEPRECATED_PAGE_SIZE macro" into main am: 2215ad406b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2978135

Change-Id: I436e26aa5e3587f5977854c4fdb720e0199a4b8d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 22:04:18 +00:00
Steven Moreland
2215ad406b Merge "Add ..DEPRECATED_PAGE_SIZE macro" into main 2024-02-28 21:34:56 +00:00
Steven Moreland
f6e9904fa9 Add ..DEPRECATED_PAGE_SIZE macro
When 'no page size' is turned on (especially if it is turned
on by default in some environments), we need a way to turn
it off, thus restoring the old behavior.

Bug: 312546062
Change-Id: I411cff621246b6ba40e70bb51234f3886ba9527a
Test: N/A
2024-02-28 21:34:42 +00:00
Kalesh Singh
824fa8065c Merge changes from topic "reland_bionic_vma_fixes" into main am: f9c297d344 am: c5b4880d0a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966884

Change-Id: Idab9845138b4ac32639d37717ad9e66ee05893cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 17:45:55 +00:00
Kalesh Singh
c5b4880d0a Merge changes from topic "reland_bionic_vma_fixes" into main am: f9c297d344
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966884

Change-Id: I5462276ccc3fb1c0b695c8bba2fb7544a84583bf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 17:02:48 +00:00
Kalesh Singh
f9c297d344 Merge changes from topic "reland_bionic_vma_fixes" into main
* changes:
  RELAND: bionic: loader: Extend GNU_RELRO protection
  RELAND: bionic: loader: Extend LOAD segment VMAs
2024-02-28 16:20:08 +00:00
Treehugger Robot
8ac73a51e1 Merge "CtsBionicAppTestCases has moved to presubmit." into main am: a094f172b8 am: 56f01ac9a0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2980612

Change-Id: I2269c5c862fac4a4c07872cc019f8ccc1e238a5e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 03:45:38 +00:00
Treehugger Robot
56f01ac9a0 Merge "CtsBionicAppTestCases has moved to presubmit." into main am: a094f172b8
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2980612

Change-Id: I493170b4ebb03df182f60de2d926c4747224f012
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-28 03:04:39 +00:00
Treehugger Robot
a094f172b8 Merge "CtsBionicAppTestCases has moved to presubmit." into main 2024-02-28 02:27:22 +00:00
Android Build Coastguard Worker
3003a40bf7 Snap for 11504324 from 4c67453909 to 24Q2-release
Change-Id: Ieb2dd917b54e57ebd467c33818d0e0c524f4226d
2024-02-28 00:01:17 +00:00
Elliott Hughes
c50a69cc85 Merge "Add CtsBionicAppTestCases to TEST_MAPPING." into main am: 15be223fcc am: 956ff6eeb4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2974191

Change-Id: Icc14e1c9373739b12ad0fb0b848b751d5cde7fff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 23:49:07 +00:00
Elliott Hughes
956ff6eeb4 Merge "Add CtsBionicAppTestCases to TEST_MAPPING." into main am: 15be223fcc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2974191

Change-Id: I6cc4e6bfd0cbae44941dae48e401c38fce17203e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 23:06:13 +00:00
Elliott Hughes
575eb3438a CtsBionicAppTestCases has moved to presubmit.
Change-Id: I305bfe2724609c18abfd52c21fd8e3ae4edc1aea
2024-02-27 22:19:01 +00:00
Elliott Hughes
15be223fcc Merge "Add CtsBionicAppTestCases to TEST_MAPPING." into main 2024-02-27 22:09:34 +00:00
Treehugger Robot
4c67453909 Merge "__bionic_get_shell_path(): explanatory comment." into main am: c3a6b446c4 am: 0500d85da2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2978812

Change-Id: I23cbfa2705ab2ae0639981c9b1595c08da94cef1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 20:33:06 +00:00
Treehugger Robot
0500d85da2 Merge "__bionic_get_shell_path(): explanatory comment." into main am: c3a6b446c4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2978812

Change-Id: I4e4c1c7090e46bfc67bfe02f8ee3b63947675ead
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-27 19:51:17 +00:00
Treehugger Robot
c3a6b446c4 Merge "__bionic_get_shell_path(): explanatory comment." into main 2024-02-27 19:14:19 +00:00
Kalesh Singh
41b8863cd7 RELAND: bionic: loader: Extend GNU_RELRO protection
If the LOAD segment VMAs are extended to prevent creating additional
VMAs, the the protection extent of the GNU_RELRO segment must also
be updated to match. Otherwise, the partial mprotect will reintroduce
an additional VMA due to the split protections.

Update the GNU_RELRO protection range when the ELF was loaded by the
bionic loader. Be careful not to attempt any fix up for ELFs not loaded
by us (e.g. ELF loaded by the kernel) since these don't have the
extended VMA fix to begin with.

Consider a system with 4KB page size and the ELF files with 64K
alignment. e.g:

$ readelf -Wl /system/lib64/bootstrap/libc.so | grep 'Type\|LOAD'

Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x0441a8 0x0441a8 R   0x10000
LOAD           0x0441b0 0x00000000000541b0 0x00000000000541b0 0x091860 0x091860 R E 0x10000
LOAD           0x0d5a10 0x00000000000f5a10 0x00000000000f5a10 0x003d40 0x003d40 RW  0x10000
LOAD           0x0d9760 0x0000000000109760 0x0000000000109760 0x0005c0 0x459844 RW  0x10000

Before this patch:

$ cat /proc/1/maps | grep -A1 libc.so

7f468f069000-7f468f0bd000 r--p 00000000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f0bd000-7f468f15e000 r-xp 00044000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f15e000-7f468f163000 r--p 000d5000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f163000-7f468f172000 rw-p 000da000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f172000-7f468f173000 rw-p 000d9000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f173000-7f468f5c4000 rw-p 00000000 00:00 0                          [anon:.bss]

1 extra RW VMA at offset 0x000da000 (3 RW mappings in total)

After this patch:

$ cat /proc/1/maps | grep -A1 libc.so

7f5a50225000-7f5a50279000 r--p 00000000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f5a50279000-7f5a5031a000 r-xp 00044000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f5a5031a000-7f5a5032e000 r--p 000d5000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f5a5032e000-7f5a5032f000 rw-p 000d9000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f5a5032f000-7f5a50780000 rw-p 00000000 00:00 0                          [anon:.bss]

Removed RW VMA at offset 0x000da000 (2 RW mappings in total)

Bug: 316403210
Bug: 300367402
Bug: 307803052
Bug: 312550202
Test: atest -c linker-unit-tests
Test: atest -c bionic-unit-tests
Change-Id: I9cd04574190ef4c727308363a8cb1120c36e53e0
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-27 07:19:07 +00:00
Kalesh Singh
944164c5e2 RELAND: bionic: loader: Extend LOAD segment VMAs
When the page_size < p_align of the ELF load segment, the loader
will end up creating extra PROT_NONE gap VMA mappings between the
LOAD segments. This problem is exacerbated by Android's zygote
model, where the number of loaded .so's can lead to ~30MB increase
in vm_area_struct unreclaimable slab memory.

Extend the LOAD segment VMA's to cover the range between the
segment's end and the start of the next segment, being careful
to avoid touching regions of the extended mapping where the offset
would overrun the size of the file. This avoids the loader
creating an additional gap VMA for each LOAD segment.

Consider a system with 4KB page size and the ELF files with 64K
alignment. e.g:

$ readelf -Wl /system/lib64/bootstrap/libc.so | grep 'Type\|LOAD'

Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x0441a8 0x0441a8 R   0x10000
LOAD           0x0441b0 0x00000000000541b0 0x00000000000541b0 0x091860 0x091860 R E 0x10000
LOAD           0x0d5a10 0x00000000000f5a10 0x00000000000f5a10 0x003d40 0x003d40 RW  0x10000
LOAD           0x0d9760 0x0000000000109760 0x0000000000109760 0x0005c0 0x459844 RW  0x10000

Before this patch:

$ cat /proc/1/maps | grep -A1 libc.so

7fa1d4a90000-7fa1d4ad5000 r--p 00000000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7fa1d4ad5000-7fa1d4ae4000 ---p 00000000 00:00 0
7fa1d4ae4000-7fa1d4b76000 r-xp 00044000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7fa1d4b76000-7fa1d4b85000 ---p 00000000 00:00 0
7fa1d4b85000-7fa1d4b8a000 r--p 000d5000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7fa1d4b8a000-7fa1d4b99000 ---p 00000000 00:00 0
7fa1d4b99000-7fa1d4b9a000 rw-p 000d9000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7fa1d4b9a000-7fa1d4feb000 rw-p 00000000 00:00 0                          [anon:.bss]

3 additional PROT_NONE (---p) VMAs for gap mappings.

After this patch:

$ cat /proc/1/maps | grep -A1 libc.so

7f468f069000-7f468f0bd000 r--p 00000000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f0bd000-7f468f15e000 r-xp 00044000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f15e000-7f468f163000 r--p 000d5000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f163000-7f468f172000 rw-p 000da000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f172000-7f468f173000 rw-p 000d9000 fe:09 20635520                   /system/lib64/bootstrap/libc.so
7f468f173000-7f468f5c4000 rw-p 00000000 00:00 0                          [anon:.bss]

No additional gap VMAs. However notice there is an extra RW VMA at
offset 0x000da000. This is caused by the RO protection of the
GNU_RELRO segment, which causes the extended RW VMA to split.
The GNU_RELRO protection extension is handled in the subsequent
patch in this series.

Bug: 316403210
Bug: 300367402
Bug: 307803052
Bug: 312550202
Test: atest -c linker-unit-tests
Test: atest -c bionic-unit-tests
Change-Id: I7150ed22af0723cc0b2d326c046e4e4a8b56ad09
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-27 06:13:11 +00:00
Elliott Hughes
529e624e2d __bionic_get_shell_path(): explanatory comment.
Change-Id: If7cb9ff4a3c13b80bb27da119bfb4c38137798a7
2024-02-26 23:08:06 +00:00
Ryan Prichard
ee22b445b8 Merge "cxa_demangle_test: expand accepted outputs" into main am: a5ac8de33f am: 18f7e80351
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2976251

Change-Id: Ibc946a863a7e52230ad4a3e3b6bca91533ebf0d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 22:22:01 +00:00
Elliott Hughes
db30ae0a17 Merge "Improve android_set_abort_message() documentation." into main am: dcfc4a1ccc am: 7617af2274
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2975871

Change-Id: Ief5829b7d24b774f8a64902d5a0fc0ed26e9d699
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 22:21:41 +00:00
Ryan Prichard
18f7e80351 Merge "cxa_demangle_test: expand accepted outputs" into main am: a5ac8de33f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2976251

Change-Id: Id27c8c3a4e1c4a56348fe2f8d63337c5a41c8597
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 21:40:22 +00:00
Elliott Hughes
7617af2274 Merge "Improve android_set_abort_message() documentation." into main am: dcfc4a1ccc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2975871

Change-Id: I11be30ab4fa04875304fbfb74b88edf819613c85
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-26 21:40:04 +00:00
Ryan Prichard
a5ac8de33f Merge "cxa_demangle_test: expand accepted outputs" into main 2024-02-26 21:34:17 +00:00
Elliott Hughes
e14c76c8c7 Add CtsBionicAppTestCases to TEST_MAPPING.
I can't believe we haven't been running this in presubmit.

I still can't explain how http://b/326189243 wasn't caught in presubmit,
but this can't hurt...

Test: treehugger
Change-Id: Ib74df38da8909bd20f9cb0cbaddff5119afb8d83
2024-02-26 21:11:51 +00:00