Merge "[libc] Zero and pattern initialization of heap memory."
This commit is contained in:
commit
f9d72d45d8
2 changed files with 17 additions and 0 deletions
|
@ -88,6 +88,12 @@ cc_defaults {
|
||||||
experimental_mte: {
|
experimental_mte: {
|
||||||
cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
|
cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
|
||||||
},
|
},
|
||||||
|
malloc_zero_contents: {
|
||||||
|
cflags: ["-DSCUDO_ZERO_CONTENTS"],
|
||||||
|
},
|
||||||
|
malloc_pattern_fill_contents: {
|
||||||
|
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
#include "pthread_internal.h"
|
#include "pthread_internal.h"
|
||||||
|
|
||||||
extern "C" int __system_properties_init(void);
|
extern "C" int __system_properties_init(void);
|
||||||
|
extern "C" void scudo_malloc_set_zero_contents(int);
|
||||||
|
extern "C" void scudo_malloc_set_pattern_fill_contents(int);
|
||||||
|
|
||||||
__LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
|
__LIBC_HIDDEN__ WriteProtected<libc_globals> __libc_globals;
|
||||||
|
|
||||||
|
@ -83,6 +85,14 @@ static void arc4random_fork_handler() {
|
||||||
_thread_arc4_lock();
|
_thread_arc4_lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __libc_init_malloc_fill_contents() {
|
||||||
|
#if defined(SCUDO_PATTERN_FILL_CONTENTS)
|
||||||
|
scudo_malloc_set_pattern_fill_contents(1);
|
||||||
|
#elif defined(SCUDO_ZERO_CONTENTS)
|
||||||
|
scudo_malloc_set_zero_contents(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
|
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
|
||||||
void __libc_add_main_thread() {
|
void __libc_add_main_thread() {
|
||||||
// Get the main thread from TLS and add it to the thread list.
|
// Get the main thread from TLS and add it to the thread list.
|
||||||
|
@ -106,6 +116,7 @@ void __libc_init_common() {
|
||||||
__libc_init_fdsan(); // Requires system properties (for debug.fdsan).
|
__libc_init_fdsan(); // Requires system properties (for debug.fdsan).
|
||||||
__libc_init_fdtrack();
|
__libc_init_fdtrack();
|
||||||
|
|
||||||
|
__libc_init_malloc_fill_contents();
|
||||||
SetDefaultHeapTaggingLevel();
|
SetDefaultHeapTaggingLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue