Commit graph

42587 commits

Author SHA1 Message Date
Jooyung Han
a97819cf51 Merge "use /system/bin/sh for new vendor partition" into main am: 1a1d7a189e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2963307

Change-Id: I4baedf7bf55cf727b4e192885e64d2f8d3e24ad1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 07:58:34 +00:00
Jooyung Han
1a1d7a189e Merge "use /system/bin/sh for new vendor partition" into main 2024-02-16 06:56:45 +00:00
Florian Mayer
e65e1939a1 Reland^2 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"
Also enable stack MTE if main binary links in a library that needs it.

Otherwise the following is possible:

1. a binary doesn't require stack MTE, but links in libraries that use
   stg on the stack
2. that binary later dlopens a library that requires stack MTE, and our
   logic in dlopen remaps the stacks with MTE
3. the libraries from step 1 now have tagged pointers with missing tags
   in memory, so things go wrong

This reverts commit f53e91cc81.

Reason for revert: Fixed problem detected in b/324568991

Test: atest memtag_stack_dlopen_test with MTE enabled
Test: check crash is gone on fullmte build
Change-Id: I4a93f6814a19683c3ea5fe1e6d455df5459d31e1
2024-02-15 17:47:19 -08:00
Elliott Hughes
3ed6e722e3 Clean up the <netinet/ether.h> implementation.
Test: treehugger
Change-Id: Ifd8bf344583b74737a05b80e30373ab7bef94f8d
2024-02-16 01:23:46 +00:00
Elliott Hughes
611019b5a4 Clean up and explain libs_utils.h^WCHECK.h.
Test: treehugger
Change-Id: I73d6ed21520a0c2659826d1c01479917ed9b388d
2024-02-15 17:08:28 -08:00
Jooyung Han
c03b656a94 use /system/bin/sh for new vendor partition
For devices with ro.board.api_level >= 202404, use /system/bin/sh for
all domains include /vendor and other partitions.

Bug: 324142245
Test: system("readlink /proc/$$/exe") in vendor components
Change-Id: Ifa4f38e542377ce1482516fba4f0001c09c5a869
2024-02-16 00:25:33 +00:00
Elliott Hughes
886193648e Merge "Simplify our trivial initgroups(), and add a test." into main am: 76cab44ab1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2961910

Change-Id: I9482bd663857e9a522d871123cfdc5fecc44e911
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-15 23:34:11 +00:00
Elliott Hughes
76cab44ab1 Merge "Simplify our trivial initgroups(), and add a test." into main 2024-02-15 23:04:02 +00:00
Treehugger Robot
7530f81bbf Merge "dlopen tests: silence warnings." into main am: 87843127b5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962679

Change-Id: I214d7470ed785a8f924d562a0858a78908ce04dd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-15 07:52:57 +00:00
Treehugger Robot
87843127b5 Merge "dlopen tests: silence warnings." into main 2024-02-15 04:50:36 +00:00
Elliott Hughes
6a45884851 Simplify our trivial initgroups(), and add a test.
initgroups() is just a call to getgrouplist() followed by a call to
setgroups(). The tricky part is memory allocation. OpenBSD allocates an
NGROUPS_MAX-sized array of gid_t on the stack. FreeBSD allocates a
sysconf(_SC_NGROUPS_MAX)-sized array of gid_t on the heap. bionic had a
mix where it would try a 2-element stack array but fall back to a heap
allocation, which sounds reasonable if you want to avoid a 256KiB
(64Ki*4 bytes) allocation on either stack or heap. But that constant 2?
That's weird in two ways... It's really small (musl has an NGROUPS_MAX
of 32 unlike the Linux kernel's 64Ki, but 32 is still a lot larger than
2), but at the same time it's too big --- bionic's getgrouplist() always
returns a single element.

So although the FreeBSD "what the hell, let's just allocate 256KiB on
the heap" implementation would have been fine, there's really no point,
and anyone who's trying to understand initgroups() on Android really
needs to read getgroupslist() anyway, so let's just have the most
trivial implementation -- a single-element array -- and let's have it
right next to getgroupslist() in the same file as all the other <grp.h>
functions.

Also add a trivial smoke test. You mostly won't have permission to do
anything interesting with initgroups(), and it's basically unused save
for privilege dropping tcpdump and strace, but we may as well make an
effort. (I tested tcpdump before and after too.)

Test: treehugger
Change-Id: I67fe02e309ed1dbefc490c01733738363ca606be
2024-02-14 17:19:14 -08:00
Treehugger Robot
37bea4ec73 Merge "Revert^3 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: 469568b94a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957057

Change-Id: Iaa45c5c3038467fbbeaab93d51e96dd11707c6bb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-15 00:22:54 +00:00
Treehugger Robot
469568b94a Merge "Revert^3 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main 2024-02-14 23:48:49 +00:00
Elliott Hughes
976f598cf3 Merge "Fix sysconf(_SC_NGROUPS_MAX)." into main am: b28adb35bd
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962906

Change-Id: Id7759b3ebaee591c886c680bd4b14db08654bbb1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 21:38:18 +00:00
Elliott Hughes
6995b4ae5c Merge "Move three legacy .c files to .cpp." into main am: 5a1f29e6cf
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962068

Change-Id: Iba01335f37b4f7abbbdd248143fe9b5c315b35f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 21:37:55 +00:00
Elliott Hughes
3f7be222ed dlopen tests: silence warnings.
A workaround for an earlier bug was causing set-but-not-used warnings.

Test: treehugger
Change-Id: I00ad83377560c0ea7aaa7c17c62a1cfb02023c16
2024-02-14 21:34:02 +00:00
Elliott Hughes
b28adb35bd Merge "Fix sysconf(_SC_NGROUPS_MAX)." into main 2024-02-14 21:17:29 +00:00
Elliott Hughes
5a1f29e6cf Merge "Move three legacy .c files to .cpp." into main 2024-02-14 20:55:50 +00:00
Florian Mayer
f53e91cc81 Revert^3 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"
This reverts commit a453c2df74.

Reason for revert: b/324568991

Bug: 324568991
Change-Id: Ia6250ebe51c505bd4b77af2b4ff4e95c8b370acd
2024-02-14 18:50:42 +00:00
Lev Rumyantsev
114830dc83 Merge "Remove unused define" into main am: eca232d514
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2963522

Change-Id: If40a6f3f5bf5c278654e0d8faa243a83303bb068
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 17:41:36 +00:00
Florian Mayer
ff5de237b4 Merge "Add API to allow apps to attach extra information to tombstones." into main am: 50f4d83960
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955867

Change-Id: I7c8fa3892054dc4c069583c5bce8bbc674c61ab5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 17:40:42 +00:00
Lev Rumyantsev
eca232d514 Merge "Remove unused define" into main 2024-02-14 17:35:29 +00:00
Florian Mayer
50f4d83960 Merge "Add API to allow apps to attach extra information to tombstones." into main 2024-02-14 17:06:07 +00:00
Treehugger Robot
f32740277e Merge "bionic: ReadPadSegmentNote: Fix print format warnings" into main am: ec49465334
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2963403

Change-Id: I26e1d9cbf4a5ef9c413cb8041c1e75f2b40c96be
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 16:16:12 +00:00
Treehugger Robot
ec49465334 Merge "bionic: ReadPadSegmentNote: Fix print format warnings" into main 2024-02-14 15:44:43 +00:00
Zheng Pan
09e06f0349 Merge changes from topic "revert-2803156-loader_crt_pad_segment-HJBTSCOMQA" into main am: 7e0598bd61
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962067

Change-Id: I98196721bbd8c793fb368c00d70a607ec0ceda04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 04:40:33 +00:00
Zheng Pan
7e0598bd61 Merge changes from topic "revert-2803156-loader_crt_pad_segment-HJBTSCOMQA" into main
* changes:
  Revert "bionic: loader: Extend LOAD segment VMAs"
  Revert "bionic: loader: Extend GNU_RELRO protection"
2024-02-14 03:52:43 +00:00
Lev Rumyantsev
69e72105bb Remove unused define
Change-Id: I1442c127d7f92059a02eecac24951297155853d7
2024-02-14 03:35:17 +00:00
Kalesh Singh
32b6d8c90f bionic: ReadPadSegmentNote: Fix print format warnings
Test: m; // No warnings
Bug: N/A
Change-Id: I88c56fe6069ddb07c83a2e799b42af4f20e83165
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-13 18:37:23 -08:00
Elliott Hughes
b3877437cd Fix sysconf(_SC_NGROUPS_MAX).
The previous implementation wasn't wrong (it returned the "maximum
maximum"), but we can return the actual runtime value from the kernel.

Noticed while looking at initgroups().

Test: treehugger
Change-Id: I891fe4ff29bd82ee05d9e05ed8299d32c21abd7f
2024-02-13 16:48:30 -08:00
Elliott Hughes
17e4068bda Move three legacy .c files to .cpp.
Test: treehugger
Change-Id: Ic22896d25881fe35f28bad53c5412e3e1d4b2661
2024-02-13 16:36:11 -08:00
Zheng Pan
92a7e1c55c Revert "bionic: loader: Extend LOAD segment VMAs"
Revert submission 2803156-loader_crt_pad_segment

Reason for revert: b/324952273

Reverted changes: /q/submissionid:2803156-loader_crt_pad_segment

Change-Id: I8af115c426c0113914abbf8fbd3e74c0d89408d1
2024-02-14 00:04:10 +00:00
Zheng Pan
9535c32e1c Revert "bionic: loader: Extend GNU_RELRO protection"
Revert submission 2803156-loader_crt_pad_segment

Reason for revert: b/324952273

Reverted changes: /q/submissionid:2803156-loader_crt_pad_segment

Change-Id: I22d4ae1972c5de7da908eb090a2fea5565ead88b
2024-02-14 00:04:10 +00:00
Treehugger Robot
92f515bb72 Merge "llvm-readelf only accepts --headers." into main am: 704cd26c33
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2961462

Change-Id: I15a6f69b9b932b8b28856f0a4342b3d114282528
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-13 23:04:08 +00:00
Elliott Hughes
e4066859e4 Merge "Admit to another LP32 bug." into main am: 4674a3fe36
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2959270

Change-Id: I3928e3107bce86b10fd99d78678ec8f7bb8d406f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-13 23:03:32 +00:00
Treehugger Robot
704cd26c33 Merge "llvm-readelf only accepts --headers." into main 2024-02-13 22:26:51 +00:00
Elliott Hughes
4674a3fe36 Merge "Admit to another LP32 bug." into main 2024-02-13 22:24:48 +00:00
Florian Mayer
e2aefc46e7 Allow to re-use the same crash_detail.
This is for advanced use-cases that have high performance demands and
know they will repeatedly re-use the crash_detail.

Bug: 155462331
Change-Id: Ib15dac70d1d598f78b74b539aeadf88b0ca32bc7
2024-02-13 13:44:32 -08:00
Florian Mayer
7c83d09679 Add API to allow apps to attach extra information to tombstones.
Test: atest debuggerd_test
Bug: 155462331
Bug: 309446525
Change-Id: Idc8387307738957dbba3daaae59f605566329f0f
2024-02-13 13:41:12 -08:00
Elliott Hughes
8e4e6f9805 llvm-readelf only accepts --headers.
GNU readelf accepts both `--header` and `--headers`, but we don't ship
that in the NDK any more, so anyone on macOS or Windows will hit this
incompatibility (even though Linux users are probably still using GNU
readelf).

Test: treehugger
Change-Id: I61eb389d4d9c0bc4f5d75ceefeb5709345299585
2024-02-13 15:25:13 +00:00
Elliott Hughes
8880cab65c Admit to another LP32 bug.
But explain why we're not going to bother fixing it.

Test: treehugger
Change-Id: Ib7358fceff10f80b9e359ea3f4d088c64d440021
2024-02-13 00:43:24 +00:00
Nick Desaulniers
2add976832 Merge "libc/Android.bp: make libc_headers visible to llvm-libc" into main am: d74f255a50
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957803

Change-Id: Ic4dcd7b9d032cc775057b5e3cc5306d50452be26
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 22:03:07 +00:00
Elliott Hughes
048c52b92b Merge "libc/Android.bp: more cleanup." into main am: 16da14df14
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2956138

Change-Id: I287684dfd59d42abcc479886ceac6ace76257060
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 21:19:56 +00:00
Nick Desaulniers
d74f255a50 Merge "libc/Android.bp: make libc_headers visible to llvm-libc" into main 2024-02-12 21:13:33 +00:00
Elliott Hughes
16da14df14 Merge "libc/Android.bp: more cleanup." into main 2024-02-12 20:40:48 +00:00
Nick Desaulniers
942ae55dc4 libc/Android.bp: make libc_headers visible to llvm-libc
llvm-libc will reuse parts of the existing system headers for types that have
implications on the ABI.

Fixes:
    error: external/llvm-libc/Android.bp:3:1: module "llvmlibc" variant
    "android_recovery_riscv64_static": depends on //bionic/libc:libc_headers
    which is not visible to this module You may need to add
    "//external/llvm-libc" to its visibility

Test: TH
Bug: 321313756
Change-Id: I33b93d8e1617a480249641dc2cdf4bbee9f9e19d
2024-02-12 10:28:40 -08:00
Kalesh Singh
d985b390d6 Merge "bionic: ReadPadSegmentNote: Skip empty PT_NOTEs" into main am: d90d990468
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2954562

Change-Id: I559d9b791801f0fc8be16515cf2343121c389184
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 18:00:22 +00:00
Kalesh Singh
d90d990468 Merge "bionic: ReadPadSegmentNote: Skip empty PT_NOTEs" into main 2024-02-12 17:28:57 +00:00
Kalesh Singh
13fb3cfb23 bionic: ReadPadSegmentNote: Skip empty PT_NOTEs
Some obfuscated ELFs may containe "empty" PT_NOTEs (p_memsz == 0).
Attempting to mmap these will cause a EINVAL failure since the requested
mapping size is zero.

Skip these phrogram headers when parsing notes.

Also improve the failure log with arguments to the mmap syscall.

Test: Platinum Tests
Bug: 324468126
Change-Id: I7de4e55c6d221d555faabfcc33bb6997921dd022
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-09 16:57:49 -08:00
Treehugger Robot
fde8cd20d7 Merge "Update linker/NOTICE." into main am: 3da4f9d7ad
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2956137

Change-Id: I80f5d82d22d4818491663c8c887e12b87d3f0d70
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-09 23:47:32 +00:00