Commit graph

12115 commits

Author SHA1 Message Date
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
cb3a3a9edb Merge "Reland^2 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: ca6861e8ad am: ce81e05947
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2966402

Change-Id: If9b203dbc49fc869a5c48afceb2d3f007e11b589
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-17 01:03:11 +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
Jernej Virag
dc6a21a1d1 Merge "Revert "use /system/bin/sh for new vendor partition"" into main am: 44890f9e52 am: 2b11b65adc
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2967125

Change-Id: I7f169705445807d6b67299b134154b8f0bed56b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 11:30:03 +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
Jooyung Han
809cfbb34b Merge "use /system/bin/sh for new vendor partition" into main am: 1a1d7a189e am: a97819cf51
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2963307

Change-Id: Ifd51fbd0798518ca01b294e7cee5852ad6eebf17
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 08:40:03 +00:00
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
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
243d421837 Merge "Simplify our trivial initgroups(), and add a test." into main am: 76cab44ab1 am: 886193648e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2961910

Change-Id: If888b50abe9187cf8578608fa589dc357bc459a2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-16 00:15:42 +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
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
a2c712c940 Merge "Revert^3 "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: 469568b94a am: 37bea4ec73
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957057

Change-Id: Ieaca004a0afe921839ade69c4eab9291773982e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-15 01:03:24 +00: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
c057791a54 Merge "Fix sysconf(_SC_NGROUPS_MAX)." into main am: b28adb35bd am: 976f598cf3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2962906

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

Change-Id: Ibf6fe758089df0d5f0ef1c5be58e114228627ab3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 22:16:18 +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
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
Florian Mayer
aa1bc0bfda Merge "Add API to allow apps to attach extra information to tombstones." into main am: 50f4d83960 am: ff5de237b4
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955867

Change-Id: I874dd57aec72347be3c920f3c4e859a0e4191601
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-14 18:26:11 +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
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
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
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
Nick Desaulniers
9c9248b474 Merge "libc/Android.bp: make libc_headers visible to llvm-libc" into main am: d74f255a50 am: 2add976832
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2957803

Change-Id: Idf8c0e3c86be1b5836fcf25f5f55183d3c4d4772
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 22:28:29 +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
08dc62e447 Merge "libc/Android.bp: more cleanup." into main am: 16da14df14 am: 048c52b92b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2956138

Change-Id: I7f2ee4ebb166dd1d0d1d04e605cf7482f20c3099
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-12 22:00:34 +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
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
Elliott Hughes
69bd8e9da2 libc/Android.bp: more cleanup.
These files were segregated because they were lacking a little cleanup.
Unfortunately that means this change has to do some of the cleanup, but
that's probably for the best.

Test: treehugger
Change-Id: I2dd33504787fc3313995de99e0745a0df22915b3
2024-02-09 10:04:26 -08:00
Elliott Hughes
69d4e959e3 Merge "libc/Android.bp: merge libc_openbsd_ndk." into main am: e3f09effb3 am: 8ca76a29b7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2954357

Change-Id: I5c07e2937f59becffecf7f4779dbb2563061ddf1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-09 17:30:42 +00:00
Elliott Hughes
8ca76a29b7 Merge "libc/Android.bp: merge libc_openbsd_ndk." into main am: e3f09effb3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2954357

Change-Id: Icb53f37f8ba36fcc93d820b4ae8b5aedaf87bbce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-09 16:49:54 +00:00
Elliott Hughes
e3f09effb3 Merge "libc/Android.bp: merge libc_openbsd_ndk." into main 2024-02-09 16:09:54 +00:00
Florian Mayer
62cb54ca90 Merge "Reland "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: a732e2aef5 am: 5b44bc316a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955914

Change-Id: I11860136c155016bf322c06a8fd34946de1994e8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-09 05:53:57 +00:00
Florian Mayer
5b44bc316a Merge "Reland "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: a732e2aef5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955914

Change-Id: I91f22862517b6c3b41893ac913a282a600a9f398
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-09 05:15:16 +00:00
Florian Mayer
a732e2aef5 Merge "Reland "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main 2024-02-09 04:35:03 +00:00
Florian Mayer
a453c2df74 Reland "[MTE] remap stacks with PROT_MTE when requested by dlopened library"
This reverts commit c20e1c2bdf.

Reason for revert: Was not the root-cause of test failure.

Change-Id: I7dcd9fc3cbac47703fa8ecd5aafd7e1c3ed87301
2024-02-09 00:40:45 +00:00
Elliott Hughes
968adf951c libc/Android.bp: merge libc_openbsd_ndk.
Test: treehugger
Change-Id: I313f8ecc28f1d0129e2b6d65ace3b6a1e05c906a
2024-02-08 13:15:53 -08:00
Florian Mayer
920345607e Merge "Revert "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: cebe1f1351 am: e8ea440525
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2954775

Change-Id: Ie5d41c895c8d2e0dccc2e87be9fc4455517406ed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-08 20:06:48 +00:00
Florian Mayer
e8ea440525 Merge "Revert "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main am: cebe1f1351
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2954775

Change-Id: I6a49c246c2415e6ae6c676d129f7d917b47bdf92
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-08 19:30:28 +00:00
Florian Mayer
cebe1f1351 Merge "Revert "[MTE] remap stacks with PROT_MTE when requested by dlopened library"" into main 2024-02-08 18:47:42 +00:00
Elliott Hughes
048f9e5986 Merge "More libc/Android.bp simplification." into main am: 8259120694 am: cd0b553f42
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955183

Change-Id: Idb0dff0df51160c10482c4873929979f8debb1b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-08 18:45:13 +00:00
Elliott Hughes
cd0b553f42 Merge "More libc/Android.bp simplification." into main am: 8259120694
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2955183

Change-Id: Ie4b1c4d6bf7c3803a7066323464749b9b33bc58d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-08 18:11:12 +00:00
Sojin Moon
c20e1c2bdf Revert "[MTE] remap stacks with PROT_MTE when requested by dlopened library"
This reverts commit 79c9694c91.

Reason for revert: DroidMonitor: Potential culprit for Bug b/324348078 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I32f7bc824900e18a7d53b025ffe3aaef0ee71802
2024-02-08 07:21:15 +00:00
Elliott Hughes
2e2b9bcf3d More libc/Android.bp simplification.
Merge libc_bionic_ndk into libc_bionic.

Test: treehugger
Change-Id: I07dbb7e20e12000a2c18ff6fab2d5bd81db0cfcd
2024-02-07 16:10:23 -08:00
Kalesh Singh
50b9e8949b Merge changes Ie770320e,I32c05cce,Ia7cb2f40 into main am: 41ed53fac6 am: 653bf2a743
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2948920

Change-Id: Ied825554b52a68b4774e156a82458b47f1347bf4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-07 20:59:59 +00:00
Kalesh Singh
653bf2a743 Merge changes Ie770320e,I32c05cce,Ia7cb2f40 into main am: 41ed53fac6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2948920

Change-Id: Id2b075604fa8832f1f4b9729599a28a2276cac87
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-07 20:19:59 +00:00
Kalesh Singh
41ed53fac6 Merge changes Ie770320e,I32c05cce,Ia7cb2f40 into main
* changes:
  bionic: linker_phdr: Introduce kPageSize
  bionic: Introduce ElfReader::ReadPadSegmentNote()
  bionic: Refactor __get_elf_note()
2024-02-07 19:28:40 +00:00
Elliott Hughes
8db29953ac Merge "Remove treble_linker_namespaces." into main am: aa19eae4c2 am: 63eb28c589
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2951946

Change-Id: I36e8df620bb1323ff3d5c3ad72d82cf8f8324604
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-07 17:28:59 +00:00
Elliott Hughes
63eb28c589 Merge "Remove treble_linker_namespaces." into main am: aa19eae4c2
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2951946

Change-Id: Icbbd2e8ccac65eb8e69e972258c385edb780b802
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-07 16:47:55 +00:00
Elliott Hughes
aa19eae4c2 Merge "Remove treble_linker_namespaces." into main 2024-02-07 16:05:57 +00:00
Kalesh Singh
f0050fb015 bionic: Refactor __get_elf_note()
Factor out generic __get_elf_note() logic and rename __get_elf_note() to
__find_elf_note(). Expose __get_elf_note() in libc/private/bionic_note.h

This will be used in the subsequent patch to test the presence of
NT_ANDROID_TYPE_PAD_SEGMENT note when loading segments.

Test: atest -c linker-unit-tests [Later patch]
Test: m && launch_cvd
Bug: 316403210
Change-Id: Ia7cb2f40b10cfaef402182a675087c8422b37e4d
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-06 17:58:40 -08:00
Florian Mayer
79cd8b8519 Merge "[MTE] remap stacks with PROT_MTE when requested by dlopened library" into main am: ba5630cede am: f252b3fda6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2901508

Change-Id: Id912233d287ce492657d5ebca053e5a7995bf113
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-06 17:40:52 +00:00
Florian Mayer
f252b3fda6 Merge "[MTE] remap stacks with PROT_MTE when requested by dlopened library" into main am: ba5630cede
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2901508

Change-Id: I23578f32fb295e96f6f074f00952e72dd3d9640e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-06 17:00:26 +00:00
Florian Mayer
ba5630cede Merge "[MTE] remap stacks with PROT_MTE when requested by dlopened library" into main 2024-02-06 16:16:03 +00:00
Florian Mayer
79c9694c91 [MTE] remap stacks with PROT_MTE when requested by dlopened library
BYPASS_INCLUSIVE_LANGUAGE_REASON="man" refers to manual not person

Bug: 318749472
Test: atest pthread on MTE enabled device
Test: atest memtag_stack_dlopen_test on MTE enabled device
Test: manual with NDK r26b built app with fsanitize=memtag-stack
Change-Id: Iac191c31b87ccbdc6a52c63ddd22e7b440354202
2024-02-05 18:17:24 -08:00
Elliott Hughes
ddd6bf1bfe Remove treble_linker_namespaces.
This is hard-coded on now.

Bug: http://b/67975799
Test: treehugger
Change-Id: Ifcf79ee3be1917827bbced40359a9f98ff5e7fd9
2024-02-06 00:29:40 +00:00
Aditya Choudhary
829c064ccc Merge "Migrate Test Targets to New Android Ownership Model" into main am: d7144fcdf0 am: 72f82334d5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2946528

Change-Id: Ib29cccd2cba3862f451518437b56421ff031c2d1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-04 22:14:00 +00:00
Aditya Choudhary
72f82334d5 Merge "Migrate Test Targets to New Android Ownership Model" into main am: d7144fcdf0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2946528

Change-Id: I0c73cc7b9392f70936f629fe4a712569462cf237
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-04 21:29:43 +00:00
Aditya Choudhary
d7144fcdf0 Merge "Migrate Test Targets to New Android Ownership Model" into main 2024-02-04 20:48:36 +00:00
Elliott Hughes
1eab8c7988 Merge "Remove libc_ndk." into main am: 38dadd1225 am: dedf9f7a34
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2945353

Change-Id: I73206327c64afc26ec72df4fbbe7b292423f15f0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-02 22:42:38 +00:00
Elliott Hughes
dedf9f7a34 Merge "Remove libc_ndk." into main am: 38dadd1225
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2945353

Change-Id: I8da5d3c71e071e0b1226f8107226ee2703d9e413
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-02 21:59:37 +00:00
Elliott Hughes
38dadd1225 Merge "Remove libc_ndk." into main 2024-02-02 21:12:29 +00:00
Aditya Choudhary
d9d37c09d8 Migrate Test Targets to New Android Ownership Model
This CL is created as a best effort to migrate test targets to the new Android ownership model.
It is based on historical data from repository history and insights from git blame.
Given the nature of this effort, there may be instances of incorrect attribution. If you find incorrect or unnecessary
attribution in this CL, please create a new CL to fix that.

For detailed guidelines and further information on the migration please refer to the link below,
go/new-android-ownership-model

Bug: 304529413
Test: N/A
Change-Id: Ie36b2a3245d9901323affcc5e51dafbb87af9248
2024-02-02 13:57:12 +00:00
Elliott Hughes
6034df4abd Remove libc_ndk.
Literally unused!

Test: treehugger
Change-Id: Ic02c9573106444411af53c45ae4f818504a8254d
2024-02-01 17:13:57 -08:00
Treehugger Robot
1d4190f88d Merge "NFC: remove unnecessary branching" into main am: 8e631624e9 am: 7995a74a3d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2940087

Change-Id: I92c57047906d1232d9386c5dd60ead5a36292c51
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-01 20:59:38 +00:00
Treehugger Robot
7995a74a3d Merge "NFC: remove unnecessary branching" into main am: 8e631624e9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2940087

Change-Id: I436a3a87b36753b944fc1a95e18b3f5d83e0d071
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-02-01 20:19:01 +00:00
Florian Mayer
d541611c77 NFC: remove unnecessary branching
Change-Id: Iac82f1fdc30261be262810de0d86369f0071044f
2024-01-31 23:09:39 +00:00
Xin Li
d70a5f022c Merge Android 24Q1 Release (ab/11220357)
Bug: 319669529
Merged-In: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
Change-Id: Ie7928dbaee63c4e4d4b4f3854017933cbc3072a3
2024-01-29 10:10:43 -08:00
Elliott Hughes
7886caf36f Merge "libc/Android.bp: remove libc_pthread and libc_nopthread." into main am: 28c0d8b42c am: f0cc62cb42
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2928796

Change-Id: Idf4bb613b50c921c39a33c366a3ca58334b33356
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-27 01:39:50 +00:00
Elliott Hughes
c5b30874e6 Merge "Start removing unnecessary libc/Android.bp complexity." into main am: b02dbce7d8 am: ac23a05aac
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2929450

Change-Id: I42936248603a3431187babdb90d77d97bd6cc4a8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-26 01:01:38 +00:00
Elliott Hughes
b094892bed libc/Android.bp: remove libc_pthread and libc_nopthread.
The motivation for these is long gone, and now they only serve to
distract/duplicate.

Test: treehugger
Change-Id: I28f4ea6dd02fb564a15ab23b9f70d447ddf0c090
2024-01-26 00:28:12 +00:00
Elliott Hughes
b02dbce7d8 Merge "Start removing unnecessary libc/Android.bp complexity." into main 2024-01-26 00:25:42 +00:00
Elliott Hughes
427931cdf5 Merge "Clarify which architectures do/don't need sa_restorer." into main am: 3a4a0c73bb am: dc7d5ab6a9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2925677

Change-Id: I9d018f1f7dba1409c3782a9551ba0c5f340de917
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-26 00:17:25 +00:00
Elliott Hughes
99cc916f7a Start removing unnecessary libc/Android.bp complexity.
Things have gotten way out of hand in here...

Test: treehugger
Change-Id: I0dc6f9369828578409d422f76cb48a4553472d3e
2024-01-25 22:45:24 +00:00
Elliott Hughes
20a3661d6c Clarify which architectures do/don't need sa_restorer.
In particular: 32-bit x86 doesn't need sa_restorer either.

I still don't fully understand why arm32 and x86-64 do, so I've left the
comments in those .S files alone. I haven't (knowingly) tested
compiler-rt since we switched from libgcc (which is what the comments
refer to), but I have tested libunwindstack since we switched from
libunwind, and that does fail existing bionic tests for unwinds through
signal frames --- I just don't know why, or whether there's a better fix.

Anyway, local testing suggests that the 32-bit x86 code is vestigial, so
let's get rid of it.

Test: treehugger
Change-Id: I3e2616f736d27a8463814356e5adb52fd76a90cc
2024-01-24 14:25:00 -08:00
Elliott Hughes
0cdb68e704 Merge "Fix assembler warnings." into main am: 5c73b4f984 am: eebbd1db0f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2701796

Change-Id: I770f4217d64c35eef5b361e41d5cd204be59d69f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-24 17:25:54 +00:00
Elliott Hughes
5c73b4f984 Merge "Fix assembler warnings." into main 2024-01-24 15:59:47 +00:00
Elliott Hughes
d7831208b2 Fix assembler warnings.
clang complains if you define a symbol and _then_ make it weak, rather
than the other way round:

  /tmp/setjmp-c3c977.s:90:1: warning: sigsetjmp changed binding to STB_WEAK
  .weak sigsetjmp;
  ^

Test: treehugger
Change-Id: Iee6b0ea456bb2e92aea810ce45f171caabaa89d2
2024-01-23 22:06:19 +00:00
Treehugger Robot
1eb127b9ea Merge "bpfmt all the .bp files to silence ayeaye." into main am: 6467c97105 am: 2569eb859b
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2918991

Change-Id: I7fc367f7c75495525fba093761c8354f1042a378
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 23:32:41 +00:00
Elliott Hughes
9c656905f5 Merge "Remove ODR violation with arm64 memrchr." into main am: 569b45dce5 am: 238310803e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2918431

Change-Id: I57dceab03ef2603a24f3220ba570afb31d50d7e5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 20:17:39 +00:00
Elliott Hughes
1eacc0edc0 bpfmt all the .bp files to silence ayeaye.
Test: treehugger
Change-Id: I5b7add6f013dcd2d4eee4851b7a2a22310c6d533
2024-01-19 19:05:36 +00:00
Elliott Hughes
569b45dce5 Merge "Remove ODR violation with arm64 memrchr." into main 2024-01-19 19:03:08 +00:00
Christopher Ferris
3c2690bb91 Merge "Update to v6.7 kernel headers." into main am: 599887ae3e am: e11a189edf
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2917312

Change-Id: Ie0525864d1de094666f1750a2bbd02dc26055bf7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-19 02:13:20 +00:00
Elliott Hughes
1ab5d279a1 Remove ODR violation with arm64 memrchr.
I haven't seen this cause a problem in practice --- I noticed this while
looking at something else entirely.

Test: llvm-objdump
Change-Id: I56e38165f45554ede538a50439f8e8ffe72871c8
2024-01-19 00:08:23 +00:00
Christopher Ferris
0f79521706 Update to v6.7 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-6.7

NOTE: The file bionic/libc/kernel/uapi/linux/usb/f_accessory.h was
deleted in the 6.7 kernel along with the functionality. However,
there is no current replacement. For now keep the file here, but at
some point when the new implementation is ready, this file will need to
be moved to the places that still need to be backwards compatible.

Test: Builds and bionic unit tests pass on raven.
Test: Able to log in to an Android GO 32 bit device.
Change-Id: Ibf5684ed140616c02bb9464bbd6422a9281a29cf
2024-01-18 12:45:00 -08:00
Treehugger Robot
a04eb8aad4 Merge "Update libc/NOTICE." into main am: 6a25dff8a3 am: ff4284eb6a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2915991

Change-Id: Ic2ced28ec18ef03ae62f820e0e73598174ea6b3e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-18 03:16:10 +00:00
Elliott Hughes
78afa49091 Update libc/NOTICE.
Test: tools/update_notice.sh
Change-Id: I4068999ee3269f0db0a52eb2c65db8587f2f0911
2024-01-17 17:02:30 -08:00
Kalesh Singh
520241007d Merge "bionic: Add crt_pad_segment" into main am: f5146642e1 am: 7a4ebce58f am: 4bf757f97c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2902180

Change-Id: I7faf8d7ad86f8077576ffdde592381f8f2e77306
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-13 01:45:24 +00:00
Kalesh Singh
862a23dfdf bionic: Add crt_pad_segment
crt_pad_segment provides a note of type NT_ANDROID_TYPE_PAD_SEGMENT.
It's intended when present is for the loader to pad segment gaps to
reduce kernel slab memory usage (due to additional vm_area_struct's
for gaps). crt_pad_segment.o retains control to the static linker so
that app developers can opt out (build with different flags) it there
are undesireable side effects.

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB          0000000000000000 0000f8 000066 00      0   0  1
  [ 2] .text             PROGBITS        0000000000000000 000040 000000 00  AX  0   0  4
  [ 3] .note.GNU-stack   PROGBITS        0000000000000000 000040 000000 00      0   0  1
  [ 4] .note.android.pad_segment NOTE            0000000000000000 000040 00001c 00   A  0   0  4
  [ 5] .rela.note.android.pad_segment RELA            0000000000000000 0000e0 000018 18   I  7   4  8
  [ 6] .debug_line       PROGBITS        0000000000000000 00005c 000052 00      0   0  1
  [ 7] .symtab           SYMTAB          0000000000000000 0000b0 000030 18      1   1  8
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), l (large), p (processor specific)

Bug: 316403210
Test: m -j50 ndk
Test: find out/soong/ndk -name 'crt_pad_segment.o'
Test: readelf -SW crt_pag_segment.o
Change-Id: I94af5e85fd602e7ba5fd56788ae39277368229d8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-01-12 10:22:08 -08:00
Ryan Prichard
6fb015232e Merge "WriteProtected: std::atomic<T> is no longer POD" into main am: 67d1705618 am: 37241b6c11 am: bd56503581
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2901170

Change-Id: Ic60cf4ab76ca9d275810a35efb2cfd34661190b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-09 21:42:11 +00:00
Ryan Prichard
67d1705618 Merge "WriteProtected: std::atomic<T> is no longer POD" into main 2024-01-09 19:46:44 +00:00
Ryan Prichard
72507e4ed5 WriteProtected: std::atomic<T> is no longer POD
std::atomic<T>'s default constructor is no longer trivial, because it
now does value-initialization. As a result, the class is no longer
trivial, so libc_globals is no longer trivial, so it is no longer POD.
(FWIW, the "POD" notion has been deprecated in favor of "trivial" and
"standard layout" concepts: POD == trivial + stdlayout.)

See https://cplusplus.github.io/LWG/issue2334 and wg21.link/p0883r2.

Mark __libc_globals as constinit, because that seems closer to
something we actually care about, AFAICT.

Bug: http://b/175635923
Test: m libc_malloc_debug
Change-Id: I338589bce03d06f20752bca342eeb86a42fc1ee7
2024-01-08 15:17:35 -08:00
Dennis Shen
5951b4100c sys_prop: add a flag to enable large sys prop node only for internal
builds

Use a soong config var to control if we should use a large sys prop node
size. Node in prop_area.cpp, the PA_SIZE is controlled by a macro flag.
This macro flag is passed in as a compiler flag which is then added when
the soong configure variable (large_system_property_node) is true.

The sooong configure variable is then backed by a build system flag
defined in build/release/build_flags.scl. The value of this flag is then
determined by different release configurations. Only internal build
release configuration would set this flag to true.

Bug: b/316932568
Change-Id: Ibe2ffda9155246f2217aaa0e7d589ed7effec311
2024-01-05 23:53:47 +00:00
Treehugger Robot
6f186f926a Merge "Make apex availability of some bionic libraries explicit" into main am: 343381d593 am: 36e5cbda7f am: 0400dab2c1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2898302

Change-Id: I46480be5e76e7ef4dee531140e93fab2283df45b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-05 02:45:33 +00:00
Treehugger Robot
343381d593 Merge "Make apex availability of some bionic libraries explicit" into main 2024-01-05 00:32:10 +00:00
Dennis Shen
88b46a867b Merge "Revert "system properties: doubling the shared file size to 256Kb"" into main am: c1e79efa0a am: f56f1c6794 am: cfe1d0dee6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2898001

Change-Id: I0fa656c53f4ad11fc10d0ee56bfda2b103b71142
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-04 23:13:58 +00:00
Dennis Shen
c1e79efa0a Merge "Revert "system properties: doubling the shared file size to 256Kb"" into main 2024-01-04 21:24:20 +00:00
Spandan Das
0a6cfe992e Make apex availability of some bionic libraries explicit
The libraries are
- libdl_static
- liblinker_main
- liblinker_malloc
- libsystemproperties

The availability to runtime apex was done implicitly using a baseline map in
build/soong/apex/apex.go. Make this explicit in Android.bp

Bug: 281077552
Test: m nothing
Change-Id: I029ae204f6cfef8c301a20b7c4294636b60b38be
2024-01-04 18:14:44 +00:00
Dennis Shen
3d1ce8c831 Revert "system properties: doubling the shared file size to 256Kb"
This reverts commit 46cce48995.

Reason for revert: 

Will put a change behind flags to bump storage to 1Mb for internal build only. AOSP code does not need to be changed. The change will be only made to git_main.

Change-Id: If3484d0e56f4c3d8fc729f55744c2d8ebdd13b11
2024-01-04 14:18:38 +00:00
Elliott Hughes
a325f3d422 Merge "Microoptimize the strtol() family." into main am: 4fe4f10069 am: cd42be98ae am: eae0f5de60
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2871135

Change-Id: Ib984c5f2a551f662149dd1e53854ec82e057f90d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2024-01-02 22:50:20 +00:00
Elliott Hughes
4fe4f10069 Merge "Microoptimize the strtol() family." into main 2024-01-02 21:26:41 +00:00
Dennis Shen
f7c6161741 Merge "system properties: doubling the shared file size to 256Kb" into main am: b28d496c18 am: 37f741a7d4 am: a9b0a5df7a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2874874

Change-Id: I89cb257325e045e3eb477020cb6cf8ded7f605ee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-18 18:10:04 +00:00
Dennis Shen
46cce48995 system properties: doubling the shared file size to 256Kb
While aconfig flag storage is being migrated to its own dedicated
storage, we need to provide some relief to the current flag users which
are running into storage capacity limit of system property. Currently
system property by default allocates a file of 128Kb for each storage
node. Bump it to 256Kb for now.

Bug: b/316037066
Change-Id: I8b0b58733f362c3789ec92ae09ee589c7c1b72c6
2023-12-18 14:02:21 +00:00
Andy Hung
6f42ae00c4 Merge "bionic: fix pthread_mutex_timedlock for PI mutexes" into main am: 46f0ddb29f am: 6f3ca33f88 am: 1aea0903b7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2869605

Change-Id: I5226049ea7e58ad5bbf9a8026388152824bd73e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-14 19:34:07 +00:00
Elliott Hughes
9bbf4d58f7 Merge "-fno-emulated-tls is the default now." into main am: f6358c9126 am: b44804c2b0 am: 050f7353c0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2874456

Change-Id: Ic93e4036c2d667e953fc2f8999eaed074815c8f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-14 17:55:36 +00:00
Andy Hung
46f0ddb29f Merge "bionic: fix pthread_mutex_timedlock for PI mutexes" into main 2023-12-14 17:52:55 +00:00
Elliott Hughes
93e75ac33c -fno-emulated-tls is the default now.
bionic doesn't target old api levels.

Test: treehugger
Change-Id: I3534dd3fd34b9130fd5500dbd6a3a314081e9036
2023-12-13 16:03:25 -08:00
Andy Hung
5e19b185fd bionic: fix pthread_mutex_timedlock for PI mutexes
FUTEX_LOCK_PI uses CLOCK_REALTIME so adjust clock timebase
accordingly.

FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI, FUTEX_LOCK_PI2
are updated to check the presence of FUTEX_CLOCK_REALTIME flag.

Test: atest bionic-unit-tests
Bug: 312787238
Bug: 315897315
Change-Id: I2d93286cf22d3b3d9f3757d49b46f7ee9ea5490c
2023-12-13 12:10:50 -08:00
Elliott Hughes
ca89b33108 Microoptimize the strtol() family.
The main change here is to remember that we arm64/x86-64 have flags, and
__builtin_<op>_overflow() lets us look at them. There's a clear saving
for arm64, and x86-64 is better too, though interestingly there the
unsigned case doesn't work out as well as the signed case because both
unsigned __builtin_mul_overflow and unsigned __builtin_add_overflow are
less efficient than the signed multiply and subtract on that
architecture, but the new code still beats the old code even so.

There's a very tiny microoptimization of the hex path that takes
advantage of the fact that conversion to lowercase is a single
instruction on all our architectures when we already know we're dealing
with a letter.

This also merges the signed and unsigned variants of the code. Not
entirely successfully, but the vast majority of the code benefits.

Before (arm64):
```
----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_inttypes_strtoimax       44.6 ns         44.3 ns     15807654
BM_inttypes_strtoumax       43.1 ns         42.8 ns     16348848
BM_stdlib_strtol            44.6 ns         44.3 ns     15805384
BM_stdlib_strtol_hex        85.5 ns         85.0 ns      8235487
BM_stdlib_strtoll           44.5 ns         44.2 ns     15833137
BM_stdlib_strtoul           43.1 ns         42.8 ns     16353963
BM_stdlib_strtoul_hex       83.1 ns         82.6 ns      8477732
BM_stdlib_strtoull          43.1 ns         42.8 ns     16353015
```

After (arm64):
```
----------------------------------------------------------------
Benchmark                      Time             CPU   Iterations
----------------------------------------------------------------
BM_inttypes_strtoimax       37.9 ns         37.6 ns     17657577
BM_inttypes_strtoumax       35.9 ns         35.7 ns     19597727
BM_stdlib_strtol            36.9 ns         36.7 ns     19093037
BM_stdlib_strtol_hex        70.7 ns         70.3 ns      9961626
BM_stdlib_strtoll           36.9 ns         36.7 ns     19093032
BM_stdlib_strtoul           35.9 ns         35.7 ns     19617784
BM_stdlib_strtoul_hex       67.7 ns         67.3 ns     10113521
BM_stdlib_strtoull          35.9 ns         35.7 ns     19621828
```

Test: treehugger
Change-Id: Ibf53b29e34d63ac31520c6d27ef80ff281899d61
2023-12-13 10:46:42 -08:00
Treehugger Robot
16f36f1c0e Merge "Reserve TLS slot for native bridge" into main am: 0144257234 am: 907d4dcae4 am: 83b9c92266
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2824791

Change-Id: I31fa4dbcd97272ab12eada1d358b05f6228aff16
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-13 17:32:16 +00:00
Elliott Hughes
94c2369f4a Merge "Microoptimize vdso lookup." into main am: 18a6fa2d2f am: ad27b8618e am: e4ceb066c3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2871814

Change-Id: Ia737938236828928f5a88a1e9cfd21b16265386f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-13 17:30:41 +00:00
Treehugger Robot
0144257234 Merge "Reserve TLS slot for native bridge" into main 2023-12-13 16:07:49 +00:00
Elliott Hughes
cbcccd53eb Microoptimize vdso lookup.
Actually reusing the hash table stuff from the linker would be a lot of
work (and the benefit unclear for so few symbols), but we can at least
break out of loops as soon as we have what we need.

Test: treehugger
Change-Id: I9cbe4636a3e3163bd302c3676eb674a4278dbf2e
2023-12-12 15:13:03 -08:00
Elliott Hughes
4de849bd44 Merge "Closing the stream when the function returns" into main am: 14b322b251 am: dd9d3cd9a0 am: a7f8f36394
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2856549

Change-Id: I88db8520f2db892f369ded5160b2beeffad5ecd9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 18:08:13 +00:00
Elliott Hughes
14b322b251 Merge "Closing the stream when the function returns" into main 2023-12-12 16:39:01 +00:00
Florian Mayer
7e52c94edc Merge "Plumb scudo_stack_depot_size to debuggerd_process_info" into main am: 7fdb49f129 am: cbc2c8859f am: 62691e69d9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2858031

Change-Id: I22c12ca855ca68310466132940f5bb52a8881674
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-12 00:48:46 +00:00
Florian Mayer
7fdb49f129 Merge "Plumb scudo_stack_depot_size to debuggerd_process_info" into main 2023-12-11 23:38:13 +00:00
Elliott Hughes
c608e57893 Merge "Use the canonical idiom for sockaddr_storage." into main am: bb261225e0 am: 3f5aaa8812 am: 4b694b6969
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2852650

Change-Id: I70804a869978bd6f27482530af7446a2cc57b33b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 16:28:27 +00:00
Elliott Hughes
bb261225e0 Merge "Use the canonical idiom for sockaddr_storage." into main 2023-12-08 14:43:32 +00:00
Juan Yescas
f7f17a8dac Merge "16k: Set PTHREAD_STACK_MIN to 16384/8192 for 64-bit/32-bit archs" into main am: 93e0616836 am: 2fe3c7f701 am: 50fbc4d8a9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2864176

Change-Id: I1be6a6ab7cf232eb02261af8666dbeba2cde1390
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-08 05:45:19 +00:00
Juan Yescas
c065a2731a 16k: Set PTHREAD_STACK_MIN to 16384/8192 for 64-bit/32-bit archs
Set PTHREAD_STACK_MIN will be set to:

- 16384 for 64-bit arch
- 8192 for 32-bit arch

Bug: 315174209
Test: Built and start the targets
      - aosp_cf_arm64_phone_pgagnostic
      - aosp_cf_x86_64_phone
Change-Id: I8bb20a3433e615f9f80a0d52051f2e1635d4301a
2023-12-07 16:07:08 -08:00
Treehugger Robot
a0c24e92e8 Merge "Revert^2 "generate_notice.py: don't check for strings we don't use any more."" into main am: 73d0d3520a am: 5515be780e am: 792fdfb84a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2864178

Change-Id: Ieb0a1009e2ef599bb5c2f8aec5d449485a07f8ea
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-07 21:14:35 +00:00
Treehugger Robot
73d0d3520a Merge "Revert^2 "generate_notice.py: don't check for strings we don't use any more."" into main 2023-12-07 19:12:28 +00:00
Elliott Hughes
a7fcc1be3f Revert^2 "generate_notice.py: don't check for strings we don't use any more."
This reverts commit ef867550ac.

Reason for revert: a change to a python script run as a commit hook cannot cause a golang crash during builds.

Change-Id: Id63d4ea370e36f890a140b9e1bc69482e3610c42
2023-12-07 15:45:50 +00:00
Bob Yang
36b41c333d Merge "Revert "generate_notice.py: don't check for strings we don't use any more."" into main am: afd4f41337 am: e8eda8ae02 am: 18a1e9b231
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2864425

Change-Id: I75c8c2babdd6e5ad4d8d4f2e3c35b13ff080396a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-07 10:02:03 +00:00
Bob Yang
afd4f41337 Merge "Revert "generate_notice.py: don't check for strings we don't use any more."" into main 2023-12-07 08:14:22 +00:00
Bob Yang
ef867550ac Revert "generate_notice.py: don't check for strings we don't use any more."
This reverts commit adb8af2668.

Reason for revert: DroidMonitor: Potential culprit for Bug 315240955 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

BUG: 315240955
BUG: 315240463
Change-Id: I9f7297c6ca48728a91f7f4640ac19f901effb3cc
2023-12-07 07:12:02 +00:00
Evgenii Stepanov
cd0c908065 Merge changes from topic "revert-2709995-VVPYYBKIHY" into main am: 73a867a203 am: 3f54874625 am: 76a20d12f3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2862867

Change-Id: Iaeda56f0cb0a6f3fc21dcb10f26bc3fb5f78e647
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-07 03:38:50 +00:00
Evgenii Stepanov
73a867a203 Merge changes from topic "revert-2709995-VVPYYBKIHY" into main
* changes:
  Revert "Linker support for MTE globals."
  Revert "Add a memtag-globals test to bionic"
2023-12-07 01:36:49 +00:00
Treehugger Robot
1e903369f6 Merge "generate_notice.py: don't check for strings we don't use any more." into main am: aa56f2a2e1 am: b8e817cb9c am: f79fe49ee0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2862870

Change-Id: Ide2e78cead02f3cbbcf9a80c70ede06f84659159
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 23:46:01 +00:00
Juan Yescas
8de167971d Merge "bionic: Do not use PAGE_SIZE to define PTHREAD_STACK_MIN" into main am: b49314108d am: b3f5421462 am: d9bb13ac1e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2860686

Change-Id: Ib96af1b18f8fe3deed9c08800a3454e2bdb584e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 21:32:10 +00:00
Elliott Hughes
adb8af2668 generate_notice.py: don't check for strings we don't use any more.
Test: `repo upload .`
Change-Id: Idba382c22fb562ca9ba5b9bbdfd3800279b04c25
2023-12-06 13:19:53 -08:00
Elliott Hughes
2cbd262cf1 Merge "riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers." into main am: 75539ab928 am: 978c235f51 am: 53adad316c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2860689

Change-Id: I86a97139f856341ab257b5092b72e00abf2b0bed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 20:27:53 +00:00
Juan Yescas
b49314108d Merge "bionic: Do not use PAGE_SIZE to define PTHREAD_STACK_MIN" into main 2023-12-06 19:58:01 +00:00
Elliott Hughes
f70a74d1a5 Merge "arm32 __bionic_call_ifunc_resolver: let the compiler handle initialization." into main am: 20738af50e am: c4ad7fa2fb am: 507dbf28b9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2860690

Change-Id: Ia9e6e2af1b5d6251428326905004fe0d16e45635
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 19:15:12 +00:00
Evgenii Stepanov
6bbb75aa77 Revert "Linker support for MTE globals."
Revert submission 2709995

Reason for revert: linker crash in soinfo::apply_relr_reloc

Reverted changes: /q/submissionid:2709995

Bug: 314038442
Change-Id: I2c6ad7f46fb1174f009253602ad08ceb36aa7d71
2023-12-06 19:01:46 +00:00
Elliott Hughes
75539ab928 Merge "riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers." into main 2023-12-06 17:57:53 +00:00
Elliott Hughes
10cd6a9d4f Merge "Avoid multiple definitions of struct tcphdr." into main am: 001fabaa90 am: 28ea9363b6 am: 6bed16b594
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2850373

Change-Id: I0e0b0d398d3473bd1f9b85f11a0daac4bab693b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-12-06 00:54:41 +00:00
Elliott Hughes
4d06786ea8 arm32 __bionic_call_ifunc_resolver: let the compiler handle initialization.
I don't think we need this, and we're not doing it for the equivalent
code in riscv64. So either we do need it, and this will help us find out
quicker and make the corresponding riscv64 change, or we don't need it,
and this is a free cleanup.

Test: treehugger
Change-Id: Ie97492ea8bb4d1bc69f926980d9d4db798884285
2023-12-06 00:39:17 +00:00
Elliott Hughes
561e804ffb riscv64: pass a pointer to __riscv_hwprobe() to ifunc resolvers.
This way, callees don't need to worry about whether or not their
reference to __riscv_hwprobe() has been resolved before their ifunc
resolver is called.

This matches the current glibc proposal from rivos.

Test: treehugger
Change-Id: I0d5244aa837d0d1f0e6bd7d22091dfedb8a55bdb
2023-12-05 16:31:59 -08:00
Juan Yescas
b40f7b911d bionic: Do not use PAGE_SIZE to define PTHREAD_STACK_MIN
There is no need to use PAGE_SIZE to define the value of
PTHREAD_STACK_MIN.

Bug: 312546062
Bug: 313941999
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic-trunk-userdebug
      m
Change-Id: If3c3fe39f50592df58634d1c164e87dcd0aebad0
2023-12-05 16:03:33 -08:00
Elliott Hughes
5850f6f3be Use the canonical idiom for sockaddr_storage.
This works out a bit silly/ugly because the bits/ header file has the
wrong name, so I've also changed the map from kernel struct to boolean
to be a map from kernel struct to filename. That not only fixes this,
it's a bit more readable too. (Just yesterday, when I had no real reason
to change it, I was asking myself "why is this a boolean?"!)

Bug: http://b/236042740
Test: treehugger
Change-Id: I3eee25b493ea97d46cc5dc5fde07f7c5e77d2a46
2023-12-05 23:13:01 +00:00
Elliott Hughes
001fabaa90 Merge "Avoid multiple definitions of struct tcphdr." into main 2023-12-05 23:09:32 +00:00
wuhaitao3
12f8ec4004 Closing the stream when the function returns
Test: build
Signed-off-by: wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>
Change-Id: I85a7935d911bf19c85c51a4c52a43e2efed34929
2023-12-05 03:29:10 +00:00
Florian Mayer
af06759667 Plumb scudo_stack_depot_size to debuggerd_process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

We already did the equivalent change for the ring buffer size in
https://r.android.com/q/topic:%22scudo_ring_buffer_size%22

Bug: 309446692
Change-Id: Icdcf4cd0a3a486d1ea07a8c616cae776730e1047
2023-12-04 16:49:35 -08:00
Treehugger Robot
d529161014 Merge "Remove fs_config_generator.py symlink" into main am: 042e4c50d1 am: d70237c706 am: 075e65fe71
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2850374

Change-Id: I2cb8a49f69d5bd892a9cb2f518282774f5f675e1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 20:55:56 +00:00
Elliott Hughes
e5f0b8a529 Merge "Avoid multiple definitions of sigaction." into main am: 3906f3bc83 am: 222f4ca434 am: efb0a10807
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849972

Change-Id: I7ff80d1bdff69962e7f1a46dc6e5fa8ca6ce0026
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 20:54:49 +00:00
Treehugger Robot
042e4c50d1 Merge "Remove fs_config_generator.py symlink" into main 2023-11-29 19:32:36 +00:00
Elliott Hughes
3906f3bc83 Merge "Avoid multiple definitions of sigaction." into main 2023-11-29 19:03:26 +00:00
Christopher Ferris
beb8a706ec Merge "Add support for signal dumping log stats." into main am: 74ab77df47 am: ce22c7a43c am: 1f2feec882
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2848756

Change-Id: I26671489bc60b24ba7b093fe2f0b50bdb9cecd7d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 05:00:28 +00:00
Christopher Ferris
74ab77df47 Merge "Add support for signal dumping log stats." into main 2023-11-29 02:56:59 +00:00
Cole Faust
b1a0a9da1d Remove fs_config_generator.py symlink
Symlinks were previously able to escape the genrule sandbox, but
after aosp/2850015 they can't.

Instead of a symlink, just use the fs_config_generator soong module.

Bug: 307824623
Test: generated_android_ids
Change-Id: Ifcd9eb06c46181903ff57713132940939d5facf6
2023-11-28 17:51:16 -08:00
Treehugger Robot
7e84a9e03d Merge "Stop the kernel header scrubber from duplicating includes." into main am: 4195a49880 am: 6d76963490 am: e28763d8bb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849971

Change-Id: I480231c4a2b2a276f275f910403b07bfcb7be948
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-29 00:33:04 +00:00
Elliott Hughes
b4a9b17a55 Avoid multiple definitions of struct tcphdr.
No-one's hit this in practice, that I know of, but there are very few
instances of this old workaround for kernel/userspace mismatches still
present, and (as part of the much harder and less effective `struct
sigaction` cleanup), we should just remove them.

Bug: http://b/236042740
Test: treehugger
Change-Id: I6c71d4353044cf57cfa8a9796a4c3d6a4d51cd86
2023-11-28 15:41:54 -08:00
Elliott Hughes
df53b16fca Avoid multiple definitions of sigaction.
Before this change, we have the kernel's sigaction in the uapi headers,
and our own sigaction in <bits/signal_types.h> and we rely on callers
making sure to use `#define` to move the kernel type out of the way if
they include a uapi header directly. This is obviously error-prone and
undesireable, and not what we usually do now.

What we _usually_ do now is use the header scrubber's ability to replace
a struct definition with a `#include <bits/STRUCT.h>`, but that doesn't
work here because struct sigaction relies on a lot of other types,
some of which also come from uapi headers.

So instead use our second best trick, which is to "move the kernel struct
out of the way" at header scrubbing time instead. This means that someone
who does `#include <linux/signal.h>` or `#include <asm/signal.h>` won't
get `struct sigaction` (they'll only have `struct __kernel_sigaction`
instead), but it does mean that they can't get two incompatible
definitions if they include a uapi header both directly and indirectly.

So although this doesn't do what I'd set out to do, it's still an
improvement in some cases, and it's our preferred idiom in most cases
anyway. (I'll come back once this is in to tidy up the two other kernel
structs where we're still using the deprecated "rename out of the way
using #define" trick, but this change is already hairy enough, and
there's a possibility it will break code that didn't care that it was
getting the kernel `struct sigaction` rather than the userspace one.)

Bug: http://b/236042740
Test: treehugger
Change-Id: Icff50e330c09c587e8f77ba0fb7cffffd9c3b708
2023-11-28 14:20:43 -08:00
Elliott Hughes
844e8fc324 Stop the kernel header scrubber from duplicating includes.
We'll probably never hit this (because the case I hit it with, struct
sigaction, isn't amenable to the "replace with #include <bits/STRUCT.h>"
trick), but in case we do, and because a set expresses our intent better
than a list, keep the list^Wset of generated includes in a set.

Bug: http://b/236042740
Test: treehugger
Change-Id: I21f5c08515eab1b28e6a36fc00149b6bc7740b7e
2023-11-28 14:01:46 -08:00
Christopher Ferris
5610d5a3a4 Add support for signal dumping log stats.
Adding the new option log_allocator_stats_on_signal that will call
mallopt(M_LOG_STATS, 0), when a signal is sent to a process.

This call does not happen in the signal handler, but a variable
is set to trigger the mallopt call. The next time any allocation
call occurs, the mallopt call will be made.

Also, includes new unit tests for the new config option.

Test: All unit tests pass.
Test: Enabling the new feature and stop/start and sending the signal to
Test: a process and observing the log contains the memory stats.
Test: Did the above for a scudo and jemalloc based device.
Change-Id: Idcf6fca74036efb065b9c4cc037aaf9bcf0f139e
2023-11-28 13:29:42 -08:00
Treehugger Robot
6fb1697131 Merge "async_safe_log.cpp: remove unused #includes." into main am: ffbe696bb6 am: 4c7788d4fc am: e7498039ad
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2849965

Change-Id: I870e8a647c0a1b98fd04cc23bd52c135460e0a41
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 20:27:44 +00:00
Treehugger Robot
ffbe696bb6 Merge "async_safe_log.cpp: remove unused #includes." into main 2023-11-28 18:01:42 +00:00
Elliott Hughes
3f98012768 async_safe_log.cpp: remove unused #includes.
Test: treehugger
Change-Id: I044e58e9ab1163c94e9d4912b4d2412cffd3d4ad
2023-11-28 15:16:47 +00:00
Mitch Phillips
7734bbfc48 Merge changes I2fc4fc9d,Id7b1a925 into main am: 456ce1e7ce am: dd504fc03a am: a41c2c0646
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2709995

Change-Id: I16a166cb9e31b3555ae75954b83f50647ac2ea5b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 11:29:39 +00:00
Mitch Phillips
456ce1e7ce Merge changes I2fc4fc9d,Id7b1a925 into main
* changes:
  Add a memtag-globals test to bionic
  Linker support for MTE globals.
2023-11-28 09:31:57 +00:00
Treehugger Robot
af7885d67f Merge "riscv64: correct comparison logic of have_fast_v" into main am: 0b4dfb9ba3 am: 9c3b74d1ac am: 598aed1c61
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2844983

Change-Id: I3412e7ee93f755c2169f69a67e94895dfad40898
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-28 01:24:12 +00:00
Kenny Gong
066f4b778b riscv64: correct comparison logic of have_fast_v
Change-Id: I47fdc0900a8edf878e99a57d6f06ff6e12ca74f2
Signed-off-by: Kenny Gong <kenny.gong@intel.com>
2023-11-23 11:14:45 +08:00
Mitch Phillips
e8139f585a Linker support for MTE globals.
This patch adds the necessary bionic code for the linker to protect
global data using MTE.

The implementation is described in the MemtagABI addendum to the
AArch64 ELF ABI:
https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst

In summary, this patch includes:

1. When MTE globals is requested, the linker maps writable SHF_ALLOC
   sections as anonymous pages with PROT_MTE (copying the file contents
   into the anonymous mapping), rather than using a file-backed private
   mapping. This is required as file-based mappings are not necessarily
   backed by the kernel with tag-capable memory. For sections already
   mapped by the kernel when the linker is invoked via. PT_INTERP, we
   unmap the contents, remap a PROT_MTE+anonymous mapping in its place,
   and re-load the file contents from disk.

2. When MTE globals is requested, the linker tags areas of global memory
   (as defined in SHT_AARCH64_MEMTAG_GLOBALS_DYNAMIC) with random tags,
   but ensuring that adjacent globals are never tagged using the same
   memory tag (to provide detemrinistic overflow detection).

3. Changes to RELATIVE, ABS64, and GLOB_DAT relocations to load and
   store tags in the right places. This ensures that the address tags are
   materialized into the GOT entries as well. These changes are a
   functional no-op to existing binaries and/or non-MTE capable hardware.

Bug: N/A
Test: atest bionic-unit-tests CtsBionicTestCases --test-filter=*Memtag*

Change-Id: Id7b1a925339b14949d5a8f607dd86928624bda0e
2023-11-20 15:53:06 +01:00
Prashanth Swaminathan
7b873fb033 Merge "string/memory functions: avoid qemu bugs/performance issues." into main am: c20bf013a1 am: 453fbd0e9a am: 7c32826486
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2806377

Change-Id: I110797573c0c309313815c0e2144c786d1b0fd13
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-17 19:18:42 +00:00
Elliott Hughes
e7b35c0dc4 Merge "libc_init_static.cpp: drop gold support." into main am: 63dce74ca0 am: b620ed5206 am: 7e7d42a8ce
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2836070

Change-Id: Ie8642466c77ed05b82e9d0dfc56b5cfb9f9d129e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-17 18:26:20 +00:00
Prashanth Swaminathan
c20bf013a1 Merge "string/memory functions: avoid qemu bugs/performance issues." into main 2023-11-17 17:47:20 +00:00
Elliott Hughes
d65368e7d7 libc_init_static.cpp: drop gold support.
The NDK no longer includes gold, so static binaries built by the NDK no
longer need to support gold.

Test: bionic static unit tests
Change-Id: Idddcb9eb18921acfc1ae2a3c755592a5ab30290a
2023-11-16 17:31:09 -08:00
Elliott Hughes
aefe999d92 string/memory functions: avoid qemu bugs/performance issues.
Use V on real hardware, but GC on qemu.

Change-Id: I419546d94555540e14a14dcc52bd99413cbbcfa1
2023-11-15 15:49:57 -08:00
Treehugger Robot
21ec4adb23 Merge "Move ; in NDK declaration" into main am: c6034e4228 am: ec6677350c am: 15c9f8f608
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2830814

Change-Id: I5bcfbb42ea39d291bbc47b52f4b1852d8547dffb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-15 02:11:04 +00:00
Treehugger Robot
c6034e4228 Merge "Move ; in NDK declaration" into main 2023-11-15 00:26:40 +00:00
Nate Myren
4b94522c14 Move ; in NDK declaration
per comment on aosp/2796861, it should be at the end of the line

Bug: 291814949
Test: presubmit
Change-Id: Ib104d6764791b7a2507e371d955cbd8e69e3ccdc
2023-11-14 15:28:57 -08:00
Treehugger Robot
034c05be11 Merge "string.h: drag in <strings.h> for GNU source as well as BSD." into main am: fb85d77da6 am: e57e7f3102 am: 5614a5815c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2828517

Change-Id: I09326b1a10226ac2f3bffe4a049041c8deae1c43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-14 19:57:51 +00:00
Treehugger Robot
fb85d77da6 Merge "string.h: drag in <strings.h> for GNU source as well as BSD." into main 2023-11-14 17:59:13 +00:00
Elliott Hughes
c5d9795cf4 string.h: drag in <strings.h> for GNU source as well as BSD.
Both glibc/musl's and Apple's <string.h> drags in <strings.h> in most
cases. So do the BSDs. Given so much historic precedent (often accompanied
by comments saying "POSIX made us move this stuff out into another
file, but we don't want to break existing code [from the 1980s]"!), plus
the fact that someone hit this in practice, trying to build one of the
linux selftests against bionic, let's change bionic over too...

Bug: http://b/310035365
Test: treehugger
Change-Id: I8f13d82fe3d3df71a656641a725410acdfd97465
2023-11-14 00:40:30 +00:00
Christopher Ferris
63c9540ea6 Merge "Make sure debug_frame is not compressed." into main am: 77704b7505 am: 93c0926a52 am: f6c9fffdd1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2826691

Change-Id: Iddd1090aff99c937963ecb9b06adac859a946b6e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-11 03:17:20 +00:00
Christopher Ferris
9d03a16d8c Make sure debug_frame is not compressed.
Right now, the unwinder doesn't support compressed sections, so unwinds
through the 32 bit libc.so don't work. It will be supported very soon,
but even then, it will be slower to use, so make sure the debug_frame
is not compressed at all.

Bug: 309857311

Test: 32 bit debuggerd unit tests pass.
Test: 32 bit unwind unit tests pass.
Change-Id: Ic8bec1d275c629ec43051bbe912014f281450eda
2023-11-10 11:19:11 -08:00
dimitry
a66a6830aa Reserve TLS slot for native bridge
Adding the slot to store pointer to the guest state
for natively translated environment.

Test: run bionic unit tests on redfin
Bug: http://b/293142668
Change-Id: I4fea5595fb613f37c85cd2b591cbcd15313973c1
2023-11-10 00:25:07 +01:00
Treehugger Robot
93bf1d0a99 Merge "elf.h: add SHT_RISCV_ATTRIBUTES." into main am: 5512532418 am: 64bc0859a3 am: ce9887d94c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2818165

Change-Id: I13a3ee00299f2afc756703d31047e1728069ff2d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-04 03:45:04 +00:00
Treehugger Robot
5512532418 Merge "elf.h: add SHT_RISCV_ATTRIBUTES." into main 2023-11-04 02:19:11 +00:00
Elliott Hughes
a3f24eb6b2 elf.h: add SHT_RISCV_ATTRIBUTES.
Test: treehugger
Change-Id: I1919ae440f56c46aad0948e4535eb6fc90b10895
2023-11-03 17:25:09 -07:00
Elliott Hughes
7ff1324aca Merge "Remove extraneous text from header comments." into main am: c43ebff0a7 am: 172da47c49 am: b988676b60
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2808593

Change-Id: I029acb6af222884e2526f77146149fc95b34ee82
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-02 17:45:57 +00:00
Elliott Hughes
180edefbd2 Remove extraneous text from header comments.
Test: treehugger
Change-Id: I8e27e8ac15f5f1380046accbd7875da1c3b512f2
2023-11-02 00:08:05 +00:00
Christopher Ferris
abe2b20309 Merge "Stop fp unwinding if the pc is 0." into main am: 0b27d314d6 am: 94df76e5ed am: e013c439b8
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2813433

Change-Id: Iaef76f9c61b7a645343ed407747ca2edef72565c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 21:32:30 +00:00
Christopher Ferris
0b27d314d6 Merge "Stop fp unwinding if the pc is 0." into main 2023-11-01 19:50:33 +00:00
Christopher Ferris
f9a2674094 Merge "Update to v6.6 kernel headers." into main am: 85dd55530a am: 511a846c42 am: 8094b84e28
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2812362

Change-Id: I15e1aa6bec3fa89568ff4ba1242c25978884999f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 03:20:21 +00:00
Treehugger Robot
8611847e5a Merge "time.h: use "duration" rather than "request"." into main am: 318a1276b4 am: 0dc540d286 am: 84d495f57e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2813844

Change-Id: I564ef94ed6e9e14a419b97a53090bac48d079de0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 03:19:55 +00:00
Treehugger Robot
8d05992702 Merge "dlfcn.h: dlclose doc ~'do not use'" into main am: 2e9bc49ac5 am: 227e78148d am: a900808621
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2813726

Change-Id: Ice29c3d56b92b78d2298d8bcbc2475326dd5b6f6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 03:19:09 +00:00
Christopher Ferris
85dd55530a Merge "Update to v6.6 kernel headers." into main 2023-11-01 02:14:31 +00:00
Treehugger Robot
318a1276b4 Merge "time.h: use "duration" rather than "request"." into main 2023-11-01 02:02:23 +00:00
Treehugger Robot
2e9bc49ac5 Merge "dlfcn.h: dlclose doc ~'do not use'" into main 2023-11-01 01:54:25 +00:00
Steven Moreland
f61b2b16b8 dlfcn.h: dlclose doc ~'do not use'
There are a lot of bugs about this over the years, too many to
reference here. Though, I referenced b/176065420 to understand
exactly why it's problematic and what the future direction may
be.

Fixes: 307859642
Test: N/A
Change-Id: Ida31fe622309a7f9b2cd55e5bbb3569fc5aded0e
2023-11-01 00:48:24 +00:00
Treehugger Robot
fb41260023 Merge "Remove accidental re-addition of factored-out cruft." into main am: 5f8ae9f942 am: e8378e2353 am: e05ea9fd94
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2812364

Change-Id: Id16c81c800af2555800299e786fd01057e545b31
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-11-01 00:35:03 +00:00
Elliott Hughes
77add1bbfd time.h: use "duration" rather than "request".
This came up in a man-pages discussion. I've left the ones that take an
integer to say what _units_ they sleep in, but the ones that take a
struct seem clearest if they just say "duration".

Test: treehugger
Change-Id: I13e39855a9d2c49e1653ec2263cb09c9f239254d
2023-11-01 00:34:47 +00:00
Elliott Hughes
f2e04f5fbd Remove accidental re-addition of factored-out cruft.
This is in libc_defaults now.

Test: treehugger
Change-Id: I3b10c5ca4274aacb75be7ea0bedafb727881444b
2023-10-31 22:17:27 +00:00
Christopher Ferris
cfcb7b6c83 Stop fp unwinding if the pc is 0.
The android_unsafe_frame_pointer_chase keeps going even when a
frame is 0. Modify the unwind to stop when this case is found.

I found this while running the GwpAsanCrasherTest.run_gwp_asan_test
from debuggerd_test and printing the tombstone created. The
deallocated by and allocated by stack traces always ended in 0 frame.

After fixing this, the last 0 frame is no longer present.

Test: Ran the debuggerd test and printed the tombstone on a raven
Test: verifying that the last frame is non-zero.
Test: Ran the bionic unit tests.
Change-Id: I8d64679277abcf5f237e6759051db11ffaa34c2f
2023-10-31 14:14:28 -07:00
Christopher Ferris
67d1e5eb74 Update to v6.6 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-6.6

Test: Builds and bionic unit tests pass on raven.
Test: Able to log in to an Android GO 32 bit device.
Change-Id: Ib5ff5a23f382721d98d1e428a295c6794b190d8d
2023-10-31 13:36:37 -07:00
Prashanth Swaminathan
7296609081 Merge "Temporarily fall back to non-V memcmp" into main am: b2570535c0 am: 4374505e7a am: 7cbc50644f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2810917

Change-Id: Icab6486f4bd6a3fa3fbb917c56baeaf4f1d46f56
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-31 17:21:23 +00:00
Prashanth Swaminathan
b2570535c0 Merge "Temporarily fall back to non-V memcmp" into main 2023-10-31 15:46:06 +00:00
Treehugger Robot
d78dfdb75a Merge changes from topic "appcompat_override" into main am: 0207a6a186 am: 9460fe5a83 am: 3fd59cb6af
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2796861

Change-Id: I1c6d5b67876e69650e721e465533ee897983efc4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-31 03:56:37 +00:00
Christopher Ferris
44dfd3ebab Merge "Add android_mallopt M_GET_DECAY_TIME_ENABLED." into main am: 35aaed9e1b am: be90376e0c am: 41f64cc03d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2810911

Change-Id: Ib46ad5bb6ed2dbd74462544ffe940f348bf24586
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-31 03:56:04 +00:00
Treehugger Robot
0207a6a186 Merge changes from topic "appcompat_override" into main
* changes:
  Move __system_properties_reload to LIBC from LIBC_PLATFORM
  Write appcompat_override system properties
2023-10-31 02:29:57 +00:00
Prashanth Swaminathan
a4d7102cf2 Temporarily fall back to non-V memcmp
Investigation revealed that the vector instructions in the assembly
implementation of memcmp seem to be putting QEMU into a bad state. This
code sometimes results in a SIGILL.

Temporarily disable the vector instructions for just this function.

Bug: 306514350
Test: Verified boot on AOSP CF image.
Change-Id: I184762354092b4b500c78a29a10db18cef0dab90
2023-10-30 18:04:20 -07:00
Christopher Ferris
b4e560ed7c Add android_mallopt M_GET_DECAY_TIME_ENABLED.
The bionic benchmarks set the decay time in various ways, but
don't necessarily restore it properly. Add a new method for
getting the current decay time and then a way to restore it.

Right now the assumption is that the decay time defaults to zero,
but in the near future that assumption might be incorrect. Therefore
using this method will future proof the code.

Bug: 302212507

Test: Unit tests pass for both static and dynamic executables.
Test: Ran bionic benchmarks that were modified.
Change-Id: Ia77ff9ffee3081c5c1c02cb4309880f33b284e82
2023-10-30 15:30:16 -07:00
Elliott Hughes
e563370427 Merge "riscv64: fix ODR violations." into main am: 0db95a4f23 am: 7cbe1fad9d am: 19fcc0a5ae
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2808261

Change-Id: Iacc7d05b1665a26a66d08c117f0c4bb820097a1e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-30 16:08:59 +00:00
Elliott Hughes
7d13666b53 riscv64: fix ODR violations.
Rather than do the work to fix the ODR violations while preserving non-V,
let's just remove the non-V code. Android will require V anyway, and
anyone trying to work on a non-V system in the meantime already needs
a bunch of patches to the build system and ART, so one more shouldn't
hurt too much.

Test: treehugger
Change-Id: Iab43d8a80d99a4d045b0008dbea4e7e8696d1167
2023-10-27 16:42:52 -07:00
Treehugger Robot
14fbd26824 Merge "Fix riscv64 stpcpy()." into main am: f971dc6b4a am: f2f9d64a0a am: 7aec3e086e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2806858

Change-Id: I5c730a4436ce865e97b788d12ce47b8228fef785
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-27 16:23:49 +00:00
Treehugger Robot
2d7fdf4307 Merge "Explain why system(3)'s argument is marked _Nonnull." into main am: 19346eaaec am: 33e9fe330c am: 73a05a9dce
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2807093

Change-Id: I906bc95974bcf14afe8c2179716dd7fcc273d846
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-27 01:20:02 +00:00
Elliott Hughes
1b2e844745 Fix riscv64 stpcpy().
We were copying the data fine, but the return value was one vector
length too far (but also not taking into account the actual number of
bytes in the last transfer).

Also move the stpcpy() tests to EXPECT_EQ() so we get all the details
of the failure at once.

Test: treehugger
Change-Id: I76bf02c8a31f40722acb7c9fd8e301d50e405bf8
2023-10-26 17:50:16 -07:00
Elliott Hughes
cc87eec645 Explain why system(3)'s argument is marked _Nonnull.
Change-Id: I566f982148c58e74db55ccbd762e0e4ca9fad240
2023-10-26 21:28:58 +00:00
Nate Myren
0ab0615f8c Move __system_properties_reload to LIBC from LIBC_PLATFORM
The zygote cannot have visiblity to LIBC_PLATFORM methods. Therefore,
move __system_properties_reload to LIBC, and rename it
__system_properties_zygote_reload, and indicate in comments that it
should not be used by non-zygote apps

Bug: 291814949
Test: atest CtsBionicRootTestCases
Change-Id: Iee8fa0c76b740543c05a433393f2f4bef36d6d3d
2023-10-25 17:41:33 -07:00
Treehugger Robot
ff55925cd4 Merge "<syslog.h>: add facilitynames[] and prioritynames[]." into main am: 7bdcf765fa am: 7b6325cd05 am: c269f679d9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2799343

Change-Id: If08ccd4e62a6af692db1beb7cc52abb707bc8372
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-24 02:43:22 +00:00
Elliott Hughes
afb8e05eb3 <syslog.h>: add facilitynames[] and prioritynames[].
Test: treehugger
Change-Id: I2a65b3088fe5a28b66e7d1c2a8caa10cb4467202
2023-10-23 17:47:15 -07:00
Nate Myren
b8c87b14b0 Write appcompat_override system properties
Create a second set of system properties, that can be overlaid over the
real ones if necessary, for appcompat purposes.

Bug: 291814949
Ignore-AOSP-First: Aosp -> internal merge conflict
Test: manual, treehugger, system_properties_test

Change-Id: I541d3658cab7753c16970957c6ab4fc8bd68d8f3
Merged-In: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
2023-10-19 13:35:57 -07:00
Nate Myren
19d8167626 Merge "Write appcompat_override system properties" into main 2023-10-19 19:29:59 +00:00
Treehugger Robot
8f7b679767 Merge "Clarify one of the "missing" FreeBSD ELF constants." into main am: b8021fbe21 am: bbedb0295b am: bdc8f354b9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2796853

Change-Id: I87aaec664797e4654aff470df444dd950e51eca6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-19 01:23:09 +00:00
Nate Myren
ae7f33dd57 Write appcompat_override system properties
Create a second set of system properties, that can be overlaid over the
real ones if necessary, for appcompat purposes.

Bug: 291814949
Ignore-AOSP-First: Aosp -> internal merge conflict
Test: manual, treehugger, system_properties_test

Change-Id: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
2023-10-18 17:28:42 -07:00
Elliott Hughes
dcfd870fac Clarify one of the "missing" FreeBSD ELF constants.
Test: treehugger
Change-Id: I7173ac704e6537a4e99a976baec46aa22df751bd
2023-10-18 14:47:12 -07:00
Mitch Phillips
25ab1c2abf Merge "Use DYNAMIC entries for MTE enablement" into main am: 363e743200 am: 3b3a96de07 am: 059d2db070
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2765590

Change-Id: I307efae2207df52c9dffdfb920fa9df075d5c695
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-18 12:31:48 +00:00
Mitch Phillips
363e743200 Merge "Use DYNAMIC entries for MTE enablement" into main 2023-10-18 10:17:37 +00:00
Edward Liaw
4082c09e24 Merge "Add test for replacing macro arguments" into main am: f2f99ec626 am: a0b40cfe92 am: f60797d6b5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2794634

Change-Id: I7d4a990f7af441efe3c17fdd87284e1e6f72a721
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-17 22:59:21 +00:00
Edward Liaw
372f2b07a3 Merge "Replace macro arguments when applying replaceTokens" into main am: 2f993a51bd am: 61124943f8 am: dccb59f76d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2792161

Change-Id: I3d275f7d4cc9c22e19faa4a43cc0cb5554b97aa7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-17 21:38:02 +00:00
Edward Liaw
d903a736fb Add test for replacing macro arguments
Add test for aosp/2792161

Bug: 297317502
Test: cpp.py
Change-Id: I2eadd3b9371ec2f8b8c24107888cad5e3ae26f60
Signed-off-by: Edward Liaw <edliaw@google.com>
2023-10-17 20:09:42 +00:00
Edward Liaw
c291c39137 Replace macro arguments when applying replaceTokens
replaceTokens was only replacing tokens for cpp name clashes in the
macro body.  This change will also replace tokens in the arguments.

Bug: 297317502
Test: bionic/libc/kernel/tools/update_all.py
Change-Id: I102d000a8a4cea507b00c867df2a16106d8aed89
Signed-off-by: Edward Liaw <edliaw@google.com>
2023-10-17 17:42:40 +00:00
Mitch Phillips
7c1f3770af Use DYNAMIC entries for MTE enablement
Adds support for the dynamic entries to specify MTE enablement. This is
now the preferred way for dynamically linked executables to specify to
the loader what mode MTE should be in, and whether stack MTE should be
enabled. In future, this is also needed for MTE globals support.

Leave the existing ELF note parsing as a backup option because dynamic
entries are not supported for fully static executables, and there's
still a bunch of glue sitting around in the build system and tests that
explicitly include the note. When -fsanitize=memtag* is specified, lld
will create the note implicitly (along with the new dynamic entries),
but at some point once we've cleaned up all the old references to the
note, we can remove the notegen from lld.

Bug: N/A
Test: atest bionic-unit-tests CtsBionicTestCases --test-filter=*Memtag*
Test: Build/boot the device under _fullmte.

Change-Id: I954b7e78afa5ff4274a3948b968cfad8eba94d88
2023-10-17 13:49:24 +02:00
Elliott Hughes
3f3bcb1372 Merge "Keep ioprio_value; <linux/ioprio.h> relies on this." into main am: 8fbdc58733 am: 211b6433db am: 289b4ef5f9 am: 7140fb9501 am: 674ef15589
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2787554

Change-Id: I3e92b4b150935c13e32f7703162fa166c1c4d495
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 18:41:47 +00:00
Elliott Hughes
b10c99d077 Keep ioprio_value; <linux/ioprio.h> relies on this.
We were keeping the macros that call this function, but not the function
itself. That's not helpful.

Bug: http://b/297317502
Test: treehugger
Change-Id: Icf8f734a129fe73ec740bb7cfbb11deb01a98cb3
2023-10-13 00:11:01 +00:00
Elliott Hughes
32c281cbb8 Merge "Clarify the fcntl() "that's not how F_SETFD works" error." into main am: b4e2219987 am: dfb9662b24 am: 4f1282b9bf am: 98c1a703b7 am: a4427fa9ab
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2780900

Change-Id: I7bc9c9f3e374731e0fdcf7b0815e09ff011a67b5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 20:35:45 +00:00
Elliott Hughes
b4e2219987 Merge "Clarify the fcntl() "that's not how F_SETFD works" error." into main 2023-10-12 17:51:20 +00:00
Elliott Hughes
25af17c587 Clarify the fcntl() "that's not how F_SETFD works" error.
The first app developer (we know of) that hit this didn't understand
what it was trying to tell them.

Before:
    FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x801

After:
    FORTIFY: fcntl(F_SETFD) only supports FD_CLOEXEC but was passed 0x801

Bug: https://issuetracker.google.com/304348746
Test: treehugger
Change-Id: I8522e851d8f74c91152ebae68b083b5272d49255
2023-10-12 16:04:14 +00:00
Elliott Hughes
b7bbf03451 Merge "Sync upstream OpenBSD stdio." into main am: 1bcebdae38 am: 865d80a22f am: 728bd30de8 am: 22d4072750 am: 7158fefe24
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2779341

Change-Id: Ia40e1d7fbdde6d095d8290c58c4d1f1a8263356e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-11 01:36:24 +00:00
Treehugger Robot
50d4e9d550 Merge "<ctype.h>: stop using _ctype_." into main am: e253761e14 am: 01de1a47fa am: aba9b2107d am: e00cd3f4cb am: 24c836e906
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2779335

Change-Id: I962271d3bffddb528601b2e54cf426d569337fd4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-10 03:24:23 +00:00
Elliott Hughes
307ff340db Sync upstream OpenBSD stdio.
"""
__swsetup: set error flag and errno on error.

Previously, we set errno to EBADF if the cantwrite() macro (which calls
__swsetup()) returns true for POSIX compliance.  However, we neglected
to also set the error flag, __SERR.  Rather than set the error flag in
all callers of cantwrite(), set both errno and the error flag in
__swsetup().  This matches what FreeBSD does and makes it possible
to choose a proper errno value for the second error condition in
__swsetup().  OK deraadt@
"""
fc99cf9338

Bug: http://b/302742247
Test: treehugger
Change-Id: If3be4905fc21e513cb8718cca671eae3885e411a
2023-10-09 16:53:31 -07:00
Elliott Hughes
69270ed6b9 <ctype.h>: stop using _ctype_.
The code comment that's being removed here defends the old
implementation by claiming that it's faster. Annoyingly, we don't know
what hardware that was run on. Running on current-ish hardware
(cheetah), I can't really tell the difference except: (a) for hwasan,
avoiding the unsafe memory access by _not_ using the array is a huge
win, and (b) even for arm32 the logic is (very slightly) faster than the
array lookup.

So let's get rid of the unsafety (as musl and FreeBSD have already done)
and the large hwasan slowdown (10ns vs 2ns). It's possible in-order
cores might still care, but it's 2023 and it's time to move on.

This change _does not_ remove `_ctype_` and associated macros from the
headers, though we might want to come back and do that. Historically
libc++ used these implementation details directly, but that's no longer
the case, and it seems unlikely that anyone else is, and today's results
suggest they probably shouldn't anyway, and doing so only ever really
made sense for something like ISO-Latin-1 anyway. Most ASCII tests are
_always_ better off inlined, and Android's never supported non-ASCII for
<ctype.h> anyway (use the isw*() functions if you want that, but bear in
mind that if you're actually dealing with human languages, you probably
want icu4c rather than libc anyway).

Test: treehugger & benchmarks
Change-Id: Ifac25c23ac33e996a3c726317b5c6e602dc72e30
2023-10-09 13:53:03 -07:00
Elliott Hughes
f1ce4648a9 Merge "Remove <ctype.h> cruft." into main am: 389a40a0a8 am: a468e56569 am: bc717f9b8d am: 4ca2aabbff am: ac7ef66045
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2455758

Change-Id: If05fcc6343f23138f026fe0759948ca3f6fae967
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-07 00:59:27 +00:00
Elliott Hughes
389a40a0a8 Merge "Remove <ctype.h> cruft." into main 2023-10-06 19:49:26 +00:00
Elliott Hughes
e37068889d Remove <ctype.h> cruft.
The NDK only supports API 21 and later, so we don't need to worry
about older API levels any more.

All the functions in this file are trivial, being but a single
instruction on most architectures. For that reason, we inline them by
default. (We continue to also provide actual symbols for any caller
that needs them --- in particular existing binaries!)

Also inline all the _l() variants too. No-one should be using them,
but since we're already using trickery to only implement the non-_l()
variants once, we may as well use the same trick for both.

Test: treehugger
Change-Id: I17637c49dd14be9e5ecb8246e72e8acc662739f1
2023-10-06 15:06:17 +00:00