From 12de0df1b7e7050750624a6625cee1d3cde9694e Mon Sep 17 00:00:00 2001 From: Mitch Phillips Date: Mon, 3 Feb 2020 08:43:35 -0800 Subject: [PATCH] [GWP-ASan] Maybe initialise GWP-ASan from Zygote. Calls the GWP-ASan mallopt() to possibly install GWP-ASan for the zygote child. Bug: 135634846 Test: ?? Change-Id: I08d6797fa9b5ca10b97e0ab1efc2dc1c219c1b45 --- core/jni/com_android_internal_os_Zygote.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index a09c0b38eb2d8..7a93d8db09319 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -579,6 +579,12 @@ static void PreApplicationInit() { // Set the jemalloc decay time to 1. mallopt(M_DECAY_TIME, 1); + + // Maybe initialize GWP-ASan here. Must be called after + // mallopt(M_SET_ZYGOTE_CHILD). + bool ForceEnableGwpAsan = false; + android_mallopt(M_INITIALIZE_GWP_ASAN, &ForceEnableGwpAsan, + sizeof(ForceEnableGwpAsan)); } static void SetUpSeccompFilter(uid_t uid, bool is_child_zygote) {