Skip to content

Commit f042a6b

Browse files
muhomorrthestinger
authored andcommitted
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.
1 parent 001fc86 commit f042a6b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

h_malloc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,3 +2148,11 @@ COLD EXPORT int h_malloc_set_state(UNUSED void *state) {
21482148
return -2;
21492149
}
21502150
#endif
2151+
2152+
#ifdef __ANDROID__
2153+
COLD EXPORT void h_malloc_disable_memory_tagging(void) {
2154+
#ifdef HAS_ARM_MTE
2155+
__is_memtag_enabled = false;
2156+
#endif
2157+
}
2158+
#endif

include/h_malloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ int h_malloc_iterate(uintptr_t base, size_t size, void (*callback)(uintptr_t ptr
9999
void *arg);
100100
void h_malloc_disable(void);
101101
void h_malloc_enable(void);
102+
void h_malloc_disable_memory_tagging(void);
102103
#endif
103104

104105
// hardened_malloc extensions

0 commit comments

Comments
 (0)