aboutsummaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)Author
2021-02-09Make fd overflow an abort.Elliott Hughes
On LP32, just abort if we're asked to handle an fd that's too big for the `short` field in `struct FILE`. This is unreachable anyway because the ulimit is 32Ki, and this will make issues far more noticeable if we ever do increase that limit (which seems unlikely for LP32 devices). Also rename __finit() to __FILE_init() to match __FILE_close(). Test: treehugger Change-Id: I5db4d6c4529a1f558aff135b4dea071d73666be5
2021-02-08Merge "Fix freopen() where the path is null."Elliott Hughes
2021-02-08Mark //bionic filegroups/genrules as bp2build_available.Jingwen Chen
Test: GENERATE_BAZEL_FILES=true m nothing && build/bazel/scripts/bp2build-sync.sh write && bazel build //bionic/... Change-Id: Ie3e0092a3a03ddc6228a9191e5b78ab206072dde
2021-02-04Fix freopen() where the path is null.Elliott Hughes
This has been in the standard since C99, but we've never supported it before. It's apparently used by SPIRV-Tools. I tried implementing this the other way (with fcntl(2)) first, but eventually realized that that's more complicated and gives worse results. This implementation assumes that /proc is mounted, but so much of libc relies on that at this point that I don't think there's any realistic case where the fcntl(2) implementation would be preferable, and there are many where it's not. The fact that no-one's mentioned this until now suggests that it's not a heavily used feature anyway. I've also replaced AssertCloseOnExec() with a CloseOnExec() boolean-valued function instead, because it's really annoying getting assertion failures that don't point you at the test line in question, and instead point to some common helper code. Test: treehugger Change-Id: Ia2e53bf2664a4f782581042054ecd492830e2aed
2021-02-04Merge "Fix "deprecated instruction in IT block" warning"Chih-hung Hsieh
2021-02-03Fix "deprecated instruction in IT block" warningChih-Hung Hsieh
Bug: 179266557 Test: make with new clang compiler Change-Id: I963609861659cbb2be8ed467654109938185c747
2021-02-03Convert generate-NOTICE.py to Python 3, fix name.Dan Albert
Python module names should be lower case and not use hyphens (the former is a convention, the latter is a requirement for importable modules). Also updates the shell script to always use Python 3 so we don't need to maintain Python 2 compatibility. Test: repo upload, in both a python 2 and python 3 virtualenv Bug: None Change-Id: I486e54a12686b4e528dc6c9c47af5c7a52a7b790
2021-02-03Convert genfunctosyscallnrs to Python 3.Dan Albert
Test: treehugger Test: pytest libc/tools Bug: None Change-Id: Idda7161bbd2e2f351e0750874dc4d766ef98cc2b
2021-02-03Convert gensecomp.py to Python 3.Elliott Hughes
The genseccomp tests haven't been run since at least 2018. Deleted the ones that are testing APIs that no longer exist or have been refactored to take very different inputs. Test: treehugger Test: pytest tools Bug: None Change-Id: Iaf6b6b6a2e922b181a457a74eb4b5abe90425dfb
2021-02-02Move gensseccomp and genfunctosyscallnrs next to their sources.Jingwen Chen
This is a manual refactoring to ensure that the modules respect package boundaries for input files. Test: m gensseccomp genfunctosyscallnrs Change-Id: I8ca6cbe85a50e41bfe874a899653c2309c59a822
2021-02-02Merge changes from topic "builtins-exported"Ryan Prichard
* changes: Use exported variants of arm32/x86 builtins Fix -Wl,--exclude-libs typo: x86->i686
2021-02-01Merge "[MemInit] Remove old API, introduce new MemInit API."Mitch Phillips
2021-02-01Fix __VERSIONER_NO_GUARD cases for availability.Dan Albert
libc++ still depends on these being declared even if they are unavailable. This results in a worse error message (a link error rather than a compiler diagnostic) if these functions end up being used, but without the decl headers like libc++'s math.h can't be included because it refers to an undeclared function. For the cases where weak symbols aren't being used, don't annotate these functions with their availability information. Also need to avoid using __builtin_available for this case because the NDK doesn't have __isOSVersionAtLeast yet. __ANDROID_UNGUARDED_AVAILABILITY__ is being used as a proxy for "building for the NDK" here because we don't have a good signal for that which works for both the NDK proper and the NDK-in-the-platform case. Test: imported into the NDK, built and tested NDK Bug: None Change-Id: I9ef3e19a8fa083bca0be47b80dfef7ba52a94866
2021-01-29Merge "Sync libm with upstream FreeBSD."Treehugger Robot
2021-01-28Use exported variants of arm32/x86 builtinsRyan Prichard
For backwards compatibility (e.g. with old apps), arm32 libc.so and libm.so export some of the builtins. On 32-bit x86, libc.so also exports some of the builtins. The non-exported variant of the builtins will eventually have hidden symbols but doesn't currently because D93431 hasn't been merged into our toolchain yet. See: - https://reviews.llvm.org/D93431 - I44ec79728db92c089e2f39823c35b6f97d24c1ab in toolchain/llvm_android Bug: http://b/153025717 Test: bionic unit tests Change-Id: Ic489cb06a07ef61412502fc65a21b0cf630c11ed
2021-01-27Merge "[MTE] Change scudo init order to get correct PROT_MTE pages."Treehugger Robot
2021-01-26Sync libm with upstream FreeBSD.Elliott Hughes
Upstream SHA 78599c32efed3247d165302a1fbe8d9203e38974. Test: treehugger Change-Id: Ib103d211315e320df89a6f0bcb30cd8ba67dd603
2021-01-26Merge changes from topic "proc_madvise_framework"Edgar Arriaga
* changes: Add bionic headers for process_madvise Add a flag to distinguish shared VMAs
2021-01-25[MemInit] Remove old API, introduce new MemInit API.Mitch Phillips
Introduces new heap-zero-init API. We've realised that it's better to be able to individually control MTE and heap zero-init. Having heap-zero-init not be controllable without affecting MTE affects our ability to turn off heap-zero-init in zygote-forked applications. Bug: 135772972 Test: On FVP: atest -s localhost:5555 malloc#zero_init \ Test: malloc#disable_mte heap_tagging_level Change-Id: I8c6722502733259934c699f4f1269eaf1641a09f
2021-01-25Merge "PAC/BTI: no need to keep using `hint`."Elliott Hughes
2021-01-25PAC/BTI: no need to keep using `hint`.Elliott Hughes
The toolchain is new enough that should be able to use the actual instructions now... Test: treehugger Change-Id: I30aafcdc5386268344c40dc6cc9a22caf591915a
2021-01-25[libc] Change literal value in macroTamas Petz
"#" there is incorrect: macro parameter is expected following a hashmark. Test: build libc with -mbranch-protection=standard Change-Id: Ib8e7ddf260b4cdbd36246cc70f69970f33dee200
2021-01-21Merge changes from topic "future_symbol"Jiyong Park
* changes: crtbegin_static is built with min_sdk_version: "current" Guard __libc_current_sigrtmin/max with __builtin_available __INTRODUCED_IN macros add the availability attribute
2021-01-20[MTE] Change scudo init order to get correct PROT_MTE pages.Mitch Phillips
scudo_malloc_* for fill contents in __libc_init_scudo calls scudo's initializers. We haven't told Scudo whether we want MTE-capable (i.e. mapped with PROT_MTE) size class regions yet, which happens in SetDefaultHeapTaggingLevel. This can lead to inconsistent mappings, where processes without ELF notes get the base region with PROT_MTE (which is undesirable because the performance implications are not known). Make sure that scudo is informed of whether regions need to be mapped PROT_MTE or not by hoising the tagging level up. Bug: 135772972 Bug: 172365548 Test: On FVP - 'adb shell MEMTAG_OPTIONS=off sanitizer-status' should have no PROT_MTE mappings (validation by looking for no 'mt' under 'VmFlags:' in /proc/smaps'). Change-Id: Idad64479c4a9459cb40dd211fe942437f8ca16fd
2021-01-20Merge "Don't set native_bridge_supported: true for ndk libraries"Colin Cross
2021-01-20Merge "Switch libc.so and linker to prebuilt LLVM libunwind"Ryan Prichard
2021-01-19Don't set native_bridge_supported: true for ndk librariesColin Cross
Native bridge modules will never compile against stubs, remove native_bridge_supported: true. Test: m checkbuild Change-Id: I0eb93fe1a2c3f6ca34ce4dab17edda8807132ce8
2021-01-15Remove the now-unnecessary android_mallopt() options.Elliott Hughes
These are available from mallopt() now, and all callers have been switched over. Bug: http://b/135772972 Test: treehugger Change-Id: I90c7a7573b261c27001a2dfd4589b23861ad613b
2021-01-14Add bionic headers for process_madviseEdgar Arriaga
Test: atest bionic-unit-tests-static Bug: 173258203 Change-Id: I396945b95de364055b87cc53321aed4fad4ebc70
2021-01-15crtbegin_static is built with min_sdk_version: "current"Jiyong Park
crtbegin_static is used by static exectuables which are guaranteed to be with the latest library regardless of their target API level. This change is in fact not a regression as crtbegin_static has been built with __ANDROID_API__=10000 before I645e6bb1234c27ae0a69b7b87a59206cfd350744 when __ANDROID_API__ tracked sdk_version, not min_sdk_version. sdk_version was not set for crtbegin_* objects and therefore the default "current" was (incorrectly) used. With this change, we are recovering the original behavior for the static variant, while the building of the dynamic variant becomes more correct - it's now with __ANDROID_API__=16. Without this change, several static executables fail to build as 1) crtbegin_static for them is built with __ANDROID_API__=16 and 2) libc_init_common.cpp uses pthread_atfork which is available only after API level 23. We hit undefined symbol error when linking. Bug: 134795810 Test: m Change-Id: I1430e57302951df33530ea0ae91b0d7a0609bf3d
2021-01-15Guard __libc_current_sigrtmin/max with __builtin_availableJiyong Park
The two APIs were added for the API level 21 and beyond. Currently, its existence is tested using the null check which is done regardless of the min sdk version of the compilation unit. (which in turn required us to mark the API symbol weak regardless of the min sdk version.) Now, we have a better way of testing the API availability; __builtin_available. The null check is replaced with the call to the compiler-provided macro which determines if the code is running in a version of OS where the API is known to exist. Bug: 150860940 Bug: 134795810 Test: m Change-Id: Ib96c78f8d3cc71d7e755d1eab86051517bbbcc44
2021-01-15__INTRODUCED_IN macros add the availability attributeJiyong Park
__INTRODUCED_IN (and its variants) macro is used to mark the availability of an API symbol. The macros were used by the versioner tool for the NDK clients. When the Bionic headers are processed by the tool, APIs with the macros are guarded with __ANDROID_API__. e.g., void foo() __INTRDUCED_IN(30); is processed into \#if __ANDROID_API__ >= 30 void foo(); \#endif by the versioner. The macros however didn't play a role for other cases, e.g. OS components. This is too strict for NDK clients and too loose for the non-NDK clients. For the former, this completely hides the APIs that are newer than the min sdk version (__ANDROID_API__). For the latter, a call to such an API can be made without being guarded. This change is the first step towards a better way of handling the native APIs availability. The plan is that every NDK APIs are annotated with the availability attribute and callers are required to guard their API calls with a runtime check if the API is newer than the min sdk version of the caller. In this change, the macros now emits the availability attribute for the non-NDK clients (i.e. when not processed by versioner). Bug: 163288375 Bug: 134795810 Test: m Change-Id: I6eb2bce2bc2770cbfd69815e6816b6f25b3d6127
2021-01-14Switch libc.so and linker to prebuilt LLVM libunwindRyan Prichard
For libc.so, use a special build of libunwind.a whose symbols aren't hidden ("libunwind-exported"), because libc.so exports the _Unwind_* APIs. Bug: http://b/153025717 Test: bionic unit tests Change-Id: I7435e076ec8cc4410e3e6086d3cf5d2c6011c80c
2021-01-15Merge "Make "disable memory mitigations" and "set heap tagging level" more ↵Elliott Hughes
available."
2021-01-14Merge "[MTE] Add MEMTAG_OPTIONS and arm64.memtag.process.* sysprop parsing."Mitch Phillips
2021-01-14Make "disable memory mitigations" and "set heap tagging level" more available.Elliott Hughes
These were only available internally via android_mallopt(), but they're likely to be needed by more code in future, so move them into mallopt(). This change leaves the android_mallopt() options for now, but I plan on coming back to remove them after I've switched the handful of callers over to mallopt() instead. Bug: http://b/135772972 Test: treehugger Change-Id: Ia154614069a7623c6aca85975a91e6a156f04759
2021-01-14[MTE] Add MEMTAG_OPTIONS and arm64.memtag.process.* sysprop parsing.Mitch Phillips
These two options allow for ARM MTE to be enabled dynamically (instead of at compile time via the ELF note). They are settable from a non-root shell to allow device owners to test system binaries with MTE. The following values may be set: 1. 'off' -> No MTE, uses TBI on compatible devices. 2. 'sync' -> SYNC MTE. 3. 'async' -> ASYNC MTE. The following methods can be used to launch a process (sanitizer-status) with configurable values: 1. adb shell MEMTAG_OPTIONS=async sanitizer-status 2. adb shell setprop arm64.memtag.process.sanitizer-status async && \ adb shell sanitizer-status Note: The system server will require some special handing in the zygote pre-fork to check the sysprops. The zygote should always have the ELF note. TODO in a subsequent patch. Bug: 135772972 Bug: 172365548 Test: Launching sanitizer-status above using both the settings. Change-Id: Ic1dbf3985a3f23521ec86725ec482c8f6739c182
2021-01-11removing ro.kernel.ebpf.supported propertyMaciej Żenczykowski
Android S devices must support eBPF. Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I84a8d00f786fca8113dd3d555af279a1029f66f2
2021-01-11Merge "Fewer copies of ALIGN()/ALIGNBYTES."Elliott Hughes
2021-01-11Merge "Remove ANDROID_EXPERIMENTAL_MTE."Peter Collingbourne
2021-01-11Fewer copies of ALIGN()/ALIGNBYTES.Elliott Hughes
Noticed while updating fts.c. Bug: http://b/177003648 Test: treehugger Change-Id: Ic3625c1c3af47c4dafb8ad686bbbddbc82b69b70
2021-01-11Merge "Sync upstream fts.c."Elliott Hughes
2021-01-11Remove ANDROID_EXPERIMENTAL_MTE.Peter Collingbourne
Now that the feature guarded by this flag has landed in Linux 5.10 we no longer need the flag, so we can remove it. Bug: 135772972 Change-Id: I02fa50848cbd0486c23c8a229bb8f1ab5dd5a56f
2021-01-11Sync upstream fts.c.Elliott Hughes
I realize that we can probably clean up more of our half-forked code by reusing the same *-compat.h headers we use for the clean upstream code, but I'll come back and do that later. Bug: http://b/177003648 Test: treehugger Change-Id: I081255aaafd62718b85956c5502911a1cc80225d
2021-01-09Merge "Make the atomic load explicit"Adam Barth
2021-01-08Merge "Fix things so that <features.h> can be used from assembler again."Elliott Hughes
2021-01-08Suppress SetHeapTaggingLevel warning under hwasan.Evgenii Stepanov
This is expected behavior. Bug: b/135772972 Test: logcat on any hwasan device Change-Id: I38b235859000ca271f1b1beaeab6ed6645ec6a08
2021-01-08Merge "Fix -Wnewline-eof"Treehugger Robot
2021-01-07Fix things so that <features.h> can be used from assembler again.Elliott Hughes
Bug: https://github.com/android/ndk/issues/1422 Test: builds Change-Id: I1b94ffe688f3d420533074c94f7ffed606ca923f
2021-01-08Make the atomic load explicitAdam Barth
Technically, std::atomic does not have an operator(). Previously, this code was relying on an implicit behavior of our C++ standard library in order to compile. When compiling this code against a different C++ standard library, I encountered a compiler error on these lines. This CL makes the std::atomic load() operation explicit, makes it clearer what this code is actually doing and makes it conform better to the C++ standard library spec rather than a particular implmentation. Change-Id: I7f255dffc0a3d8e07c973c18e9ba4098c4b5843e