From ffd57d7a41bfdd29ec97f5474a9a77e4492287f1 Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Mon, 30 Jan 2023 11:36:59 -0800 Subject: [PATCH] Skip resetting the stack protector on eng builds This CL will cause the Zygote to skip re-initialization of the stack protector cookie on Eng builds. This will prevent interpreter functions that would not normally appear on the critical call path from causing stack check failures. Bug: 265760793 Test: m libandroid_runtime (to ensure correct branch of pre-processor conditional is taken) Change-Id: I7ec7ac5a2230d1078c818013ae90f3d2597734a3 --- core/jni/Android.bp | 6 ++++++ core/jni/com_android_internal_os_Zygote.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/jni/Android.bp b/core/jni/Android.bp index f7d1014ab62d3..b5b7c0f38bb9c 100644 --- a/core/jni/Android.bp +++ b/core/jni/Android.bp @@ -40,6 +40,12 @@ cc_library_shared { cppflags: ["-Wno-conversion-null"], + product_variables: { + eng: { + cflags: ["-DNO_RESET_STACK_PROTECTOR"], + }, + }, + cpp_std: "gnu++20", srcs: [ diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 19bcd7fe09ad4..963a83e5d3eed 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -2296,7 +2296,7 @@ pid_t zygote::ForkCommon(JNIEnv* env, bool is_system_server, setpriority(PRIO_PROCESS, 0, PROCESS_PRIORITY_MIN); } -#if defined(__BIONIC__) +#if defined(__BIONIC__) && !defined(NO_RESET_STACK_PROTECTOR) // Reset the stack guard for the new process. android_reset_stack_guards(); #endif