android: add function for disabling MTE at runtime

On Android, MTE is always enabled in Zygote, and is disabled after fork for apps that didn't opt-in
to MTE.

Depends on the slab canary adjustments in the previous commit.
pull/226/head
Dmitry Muhomor 2023-10-26 10:22:55 +03:00 committed by Daniel Micay
parent 001fc86585
commit f042a6b9b0
2 changed files with 9 additions and 0 deletions

View File

@ -2148,3 +2148,11 @@ COLD EXPORT int h_malloc_set_state(UNUSED void *state) {
return -2; return -2;
} }
#endif #endif
#ifdef __ANDROID__
COLD EXPORT void h_malloc_disable_memory_tagging(void) {
#ifdef HAS_ARM_MTE
__is_memtag_enabled = false;
#endif
}
#endif

View File

@ -99,6 +99,7 @@ int h_malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t ptr
void *arg); void *arg);
void h_malloc_disable(void); void h_malloc_disable(void);
void h_malloc_enable(void); void h_malloc_enable(void);
void h_malloc_disable_memory_tagging(void);
#endif #endif
// hardened_malloc extensions // hardened_malloc extensions