Revert "[MTE] allocate ring buffer for stack history"
This reverts commit 10d11ddfcb52122db52ac9f15b4884f663e9915d.
Reason for revert: b/348239278
Change-Id: I14a1a3177ecbf5d8cf44836dc790c501c102960a
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index ac97376..3da0a92 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -289,7 +289,11 @@
// We can't short-circuit the environment override, as `stack` is still inherited from the
// binary's settings.
- get_environment_memtag_setting(&level);
+ if (get_environment_memtag_setting(&level)) {
+ if (level == M_HEAP_TAGGING_LEVEL_NONE || level == M_HEAP_TAGGING_LEVEL_TBI) {
+ *stack = false;
+ }
+ }
return level;
}
@@ -325,14 +329,13 @@
bool memtag_stack = false;
HeapTaggingLevel level =
__get_tagging_level(memtag_dynamic_entries, phdr_start, phdr_ct, load_bias, &memtag_stack);
- // initial_memtag_stack is used by the linker (in linker.cpp) to communicate than any library
- // linked by this executable enables memtag-stack.
- // memtag_stack is also set for static executables if they request memtag stack via the note,
- // in which case it will differ from initial_memtag_stack.
- if (__libc_shared_globals()->initial_memtag_stack || memtag_stack) {
+ // This is used by the linker (in linker.cpp) to communicate than any library linked by this
+ // executable enables memtag-stack.
+ if (__libc_shared_globals()->initial_memtag_stack) {
+ if (!memtag_stack) {
+ async_safe_format_log(ANDROID_LOG_INFO, "libc", "enabling PROT_MTE as requested by linker");
+ }
memtag_stack = true;
- __libc_shared_globals()->initial_memtag_stack_abi = true;
- __get_bionic_tcb()->tls_slot(TLS_SLOT_STACK_MTE) = __allocate_stack_mte_ringbuffer(0, nullptr);
}
if (int64_t timed_upgrade = __get_memtag_upgrade_secs()) {
if (level == M_HEAP_TAGGING_LEVEL_ASYNC) {