Merge "Skip rather than reject invalid ELF notes for existing apps." into main
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index 6741be3..c731970 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -123,6 +123,7 @@
}
atomic_store(&__libc_memtag_stack, false);
atomic_store(&globals->memtag, false);
+ atomic_store(&__libc_shared_globals()->memtag_currently_on, false);
});
if (heap_tagging_level != M_HEAP_TAGGING_LEVEL_TBI) {
diff --git a/libc/bionic/libc_init_mte.cpp b/libc/bionic/libc_init_mte.cpp
index 3c8ef7d..eda2eec 100644
--- a/libc/bionic/libc_init_mte.cpp
+++ b/libc/bionic/libc_init_mte.cpp
@@ -273,6 +273,7 @@
if (prctl(PR_SET_TAGGED_ADDR_CTRL, prctl_arg | PR_MTE_TCF_SYNC, 0, 0, 0) == 0 ||
prctl(PR_SET_TAGGED_ADDR_CTRL, prctl_arg, 0, 0, 0) == 0) {
__libc_shared_globals()->initial_heap_tagging_level = level;
+ atomic_store(&__libc_shared_globals()->memtag_currently_on, true);
struct sigaction action = {};
action.sa_flags = SA_SIGINFO | SA_RESTART;
@@ -320,6 +321,5 @@
#endif // __aarch64__
bool __libc_mte_enabled() {
- HeapTaggingLevel lvl = __libc_shared_globals()->initial_heap_tagging_level;
- return lvl == M_HEAP_TAGGING_LEVEL_SYNC || lvl == M_HEAP_TAGGING_LEVEL_ASYNC;
+ return atomic_load(&__libc_shared_globals()->memtag_currently_on);
}
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index cd6dca9..77ac21f 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -146,6 +146,7 @@
size_t scudo_stack_depot_size = 0;
HeapTaggingLevel initial_heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
+ _Atomic(bool) memtag_currently_on = false;
// See comments for __libc_memtag_stack / __libc_memtag_stack_abi above.
bool initial_memtag_stack = false;
bool initial_memtag_stack_abi = false;
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 8f78915..0b829b3 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2369,8 +2369,10 @@
}
void* tls_block = get_tls_block_for_this_thread(tls_module, /*should_alloc=*/true);
*symbol = static_cast<char*>(tls_block) + sym->st_value;
- } else {
+ } else if (__libc_mte_enabled()) {
*symbol = get_tagged_address(reinterpret_cast<void*>(found->resolve_symbol_address(sym)));
+ } else {
+ *symbol = reinterpret_cast<void*>(found->resolve_symbol_address(sym));
}
failure_guard.Disable();
LD_LOG(kLogDlsym,