Commit graph

42537 commits

Author SHA1 Message Date
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
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
Elliott Hughes
dcfc4a1ccc Merge "Improve android_set_abort_message() documentation." into main 2024-02-26 20:57:05 +00:00
Ryan Prichard
1a5e871374 cxa_demangle_test: expand accepted outputs
After updating libc++, the demangled output's float literal ends with
'L' and the <template-args> ends with a '>'. However, the input is
invalid, so the demangler probably should return nullptr.

Bug: http://b/175635923
Test: bionic-unit-tests
Change-Id: I8440118e4f5791a3464e15d6f9d2f5f3d006e54d
2024-02-23 20:00:35 -08:00
Elliott Hughes
94c93d659b Improve android_set_abort_message() documentation.
Change-Id: Iee01fcfc39356f3daeb0676acc0dc0dd17675e68
2024-02-23 17:41:55 +00:00
Treehugger Robot
de24241803 Merge "Mention ApplicationExitInfo in docs" into main am: 6835b71819
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2974831

Change-Id: Ib3abeeaa14f06650721fac0504ca23431fad2c42
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-23 05:29:51 +00:00
Treehugger Robot
6835b71819 Merge "Mention ApplicationExitInfo in docs" into main 2024-02-23 04:58:59 +00:00
Florian Mayer
63df50e101 Mention ApplicationExitInfo in docs
Bug: 155462331
Change-Id: I2a60dc1ca5a117bd47631dc7faba8446b4518761
2024-02-23 01:34:22 +00:00
Treehugger Robot
cd3e175377 Merge "Add CtsBionicAppTestCases to postsubmit" into main am: f2c9e97c45
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2974193

Change-Id: If8247d4684a69dfcfd5f7699315930ca343fd804
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 22:09:29 +00:00
Treehugger Robot
f2c9e97c45 Merge "Add CtsBionicAppTestCases to postsubmit" into main 2024-02-22 21:25:32 +00:00
Elliott Hughes
f4968f0556 Add CtsBionicAppTestCases to postsubmit
We can't add CtsBionicAppTestCases to presubmit (my actual goal here)
until it's been in postsubmit.

Test: treehugger
Change-Id: Iff872b99cfcaf6c92f98e37ade782ad3ae55cd8b
2024-02-22 18:31:12 +00:00
Elliott Hughes
00fa3f3083 Merge "Clean up the <netinet/ether.h> implementation." into main am: 9a7da857a7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966403

Change-Id: I21579d147afd2f4cac41654ae627c9a190da2917
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 16:08:38 +00:00
Elliott Hughes
b904f6d982 Merge "Stop trying to be clever with sysconf(_SC_NGROUPS_MAX)." into main am: 85164759f7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2972452

Change-Id: Id5b120f60171bc23be25a561356bb14769c5e01f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 16:08:28 +00:00
Elliott Hughes
0514c95667 Merge "Clarify _PC_REC_INCR_XFER_SIZE and _PC_REC_MAX_XFER_SIZE." into main am: ea8be9ff96
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2971213

Change-Id: I7774d4c92da81545b7c0a758107e19c48089cd9e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 16:08:17 +00:00
Elliott Hughes
9a7da857a7 Merge "Clean up the <netinet/ether.h> implementation." into main 2024-02-22 15:35:36 +00:00
Elliott Hughes
85164759f7 Merge "Stop trying to be clever with sysconf(_SC_NGROUPS_MAX)." into main 2024-02-22 15:35:23 +00:00
Elliott Hughes
ea8be9ff96 Merge "Clarify _PC_REC_INCR_XFER_SIZE and _PC_REC_MAX_XFER_SIZE." into main 2024-02-22 15:34:28 +00:00
Jooyung Han
caeb54a332 Merge "use /system/bin/sh for all" into main am: 79434542bc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2969412

Change-Id: I229fe068b9a9d2a3c571d1f33c77536af0f6e8ba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 06:40:57 +00:00
Jooyung Han
79434542bc Merge "use /system/bin/sh for all" into main 2024-02-22 05:59:22 +00:00
Elliott Hughes
e0188acf0a Merge "Fix copyright headers on new tests." into main am: e2600ea491
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2971214

Change-Id: I1cb7e15b0e52c27b856152579b2491e6e7c2bc0f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-22 01:04:43 +00:00
Elliott Hughes
e2600ea491 Merge "Fix copyright headers on new tests." into main 2024-02-22 00:20:17 +00:00
Automerger Merge Worker
463a3ca89a Merge "Merge "grp_pwd_test: Hack around "trunk stable"." into android14-tests-dev am: 40f12b4aa6" into main am: bf0dcc4367
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957235

Change-Id: I8ad0e1e6333208e571d83b650106c613ae68a2ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-21 23:40:53 +00:00
Automerger Merge Worker
bf0dcc4367 Merge "Merge "grp_pwd_test: Hack around "trunk stable"." into android14-tests-dev am: 40f12b4aa6" into main 2024-02-21 23:00:36 +00:00
Elliott Hughes
f31c52d54c Merge "grp_pwd_test: Hack around "trunk stable"." into android14-tests-dev am: 40f12b4aa6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957235

Change-Id: I22b5c2a3da1182aa249bda93044caf00ffca9657
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-21 23:00:31 +00:00
Elliott Hughes
40f12b4aa6 Merge "grp_pwd_test: Hack around "trunk stable"." into android14-tests-dev 2024-02-21 22:23:41 +00:00
Elliott Hughes
dd756ae82d Stop trying to be clever with sysconf(_SC_NGROUPS_MAX).
The test failed the first time someone ran it as a non-root user.
Definitely not worth changing sepolicy for this, and even if we did,
that wouldn't work for static binaries (to the extent that we care).

Bug: http://b/326189243
Test: treehugger
Change-Id: I02441ce7f69ac477b0223565ac490046cee12579
2024-02-21 20:44:07 +00:00
Elliott Hughes
49e0b3d571 Fix copyright headers on new tests.
The upload hook doesn't spot changes in tests/, so fix that too!

Test: repo upload .
Change-Id: If8ae0463e53063b7f584642b5e993658bbc8df32
2024-02-21 19:54:59 +00:00
Elliott Hughes
ae0d0c9e76 Clarify _PC_REC_INCR_XFER_SIZE and _PC_REC_MAX_XFER_SIZE.
The -1 from pathconf()/fpathconf() with these isn't the "I don't know
what you're talking about" -1/EINVAL, but the "I understand the
question, but don't have an answer for you --- you'll have to try it and
see" -1.

Bug: http://b/326245682
Test: treehugger
Change-Id: I67be277f3ffd9b5a355787ae7ffc4a31e32b0128
2024-02-21 19:18:09 +00:00
Treehugger Robot
a45b70fcb7 Merge "Add another link to the benchmark docs." into main am: c46ec1990d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2971791

Change-Id: Idd9157758af6d55185d7b20ab3285b56aa497d32
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-21 17:58:18 +00:00
Treehugger Robot
c46ec1990d Merge "Add another link to the benchmark docs." into main 2024-02-21 17:17:14 +00:00
Elliott Hughes
e6d6efdb67 Add another link to the benchmark docs.
There is one at the top of the main readme, but multiple people have
failed to find that, so add another link in the part of the doc they are
looking at instead...

Test: treehugger
Change-Id: I953f95a6cfcea079110923d58b60a4f7ff9b8ed2
2024-02-21 15:52:10 +00:00
Treehugger Robot
2f8ccc57a1 Merge changes from topics "crashapi2", "crashapi3" into main am: 30c7aad06d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2961904

Change-Id: I36d33a95fbd92f2fee23c4f50061e1b7e0aadabc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-21 08:30:41 +00:00
Florian Mayer
4bd5112e33 Allow to re-use the same crash_detail. am: e2aefc46e7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962622

Change-Id: I5f886e0a3f609f06f0679a6d71103a83841a64e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-21 08:30:35 +00:00
Treehugger Robot
30c7aad06d Merge changes from topics "crashapi2", "crashapi3" into main
* changes:
  header and android_crash_detail prefix for crash_detail API
  Allow to re-use the same crash_detail.
2024-02-21 07:42:42 +00:00
Jooyung Han
35bdfa040f use /system/bin/sh for all
Since Treble, /vendor components has been using /vendor/bin/sh. But this
gets complicated with APEXes, /odm, apps, etc. We now switch back to
/system/bin/sh for all domains. In practice, this should be okay because
/system/bin/sh is almost stable.

Bug: 324142245
Test: system("readlink /proc/$$/exe") in vendor components
Change-Id: Id830aa8281e7cbda1f15474174c38d8e28dc358b
2024-02-21 16:02:22 +09:00
Florian Mayer
ca4749af30 header and android_crash_detail prefix for crash_detail API
Bug: 155462331
Change-Id: Ib1c0ac76d2bd036a6b802b0997d9de8be61dfd2b
2024-02-20 23:41:38 +00:00
Florian Mayer
ce81e05947 Merge "Reland^2 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: ca6861e8ad
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966402

Change-Id: If7b9af86bdb351223ccef47376aa8326e9dca7e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-17 00:24:50 +00:00
Elliott Hughes
140e4d35c0 grp_pwd_test: Hack around "trunk stable".
The 2024Q builds don't have their own branches like QPR builds used to,
and there's no API bump until V proper, so the same CTS build needs to
cope with both last year's Android release _and_ the one that doesn't
have an API level yet. So poke holes in the uid test to support these
mismatches.

This runs the risk of allowing accidental misuse in U of the very uids
that will definitely be used in V, so check that _if_ the uids do exist,
they have the names we're expecting them to have. That should make
accidents easier to spot?

Bug: http://b/322256445
Test: treehugger
Change-Id: I3b24b8fafe20012df70c73589b40dba5a10e50e9
2024-02-17 00:14:55 +00:00
Florian Mayer
ca6861e8ad Merge "Reland^2 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main 2024-02-16 23:43:18 +00:00
Elliott Hughes
bb009466b6 Merge "Clean up and explain libs_utils.h^WCHECK.h." into main am: 1529990938
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966822

Change-Id: I33b321578760c3dcf0c10ddf704386508fa2938d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 16:27:01 +00:00
Elliott Hughes
1529990938 Merge "Clean up and explain libs_utils.h^WCHECK.h." into main 2024-02-16 15:55:42 +00:00
Jernej Virag
2b11b65adc Merge "Revert "use /system/bin/sh for new vendor partition"" into main am: 44890f9e52
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2967125

Change-Id: I9c32037ef8076875c4c72dbd6cf47fab41e9ffa2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 10:49:56 +00:00
Jernej Virag
44890f9e52 Merge "Revert "use /system/bin/sh for new vendor partition"" into main 2024-02-16 10:13:22 +00:00
Joonhun Shin
780e8eac5a Revert "use /system/bin/sh for new vendor partition"
Revert submission 2964802-sh_path

Reason for revert: <b/325569171>

Reverted changes: /q/submissionid:2964802-sh_path

Change-Id: Ie050cf1f402bbf599a00633a8c2a911334ae848b
2024-02-16 09:22:47 +00:00