From d3d8abeb1499d51fc2d881d933e4059fbffe448c Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 27 Aug 2021 10:20:04 -0700 Subject: [PATCH] Remove unnecessary ASLR workaround The ADDR_NO_RANDOMIZE workaround for ASLR is not required for 3.4+ kernels. As Android 11+ requires kernel 4.4+, this workaround can be safely removed from app startup. Bug: 193448904 Test: Manual Change-Id: I3c5517c34176573256176a4753f4a9113a62a49f --- core/jni/com_android_internal_os_Zygote.cpp | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 8b9a688a63e79..515c08d8517e2 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -62,7 +62,6 @@ #include #include #include -#include #include #include @@ -837,26 +836,6 @@ static void MountEmulatedStorage(uid_t uid, jint mount_mode, } } -static bool NeedsNoRandomizeWorkaround() { -#if !defined(__arm__) - return false; -#else - int major; - int minor; - struct utsname uts; - if (uname(&uts) == -1) { - return false; - } - - if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) { - return false; - } - - // Kernels before 3.4.* need the workaround. - return (major < 3) || ((major == 3) && (minor < 4)); -#endif -} - // Utility to close down the Zygote socket file descriptors while // the child is still running as root with Zygote's privileges. Each // descriptor (if any) is closed via dup3(), replacing it with a valid @@ -1687,15 +1666,6 @@ static void SpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray gids, // runtime. runtime_flags &= ~RuntimeFlags::GWP_ASAN_LEVEL_MASK; - if (NeedsNoRandomizeWorkaround()) { - // Work around ARM kernel ASLR lossage (http://b/5817320). - int old_personality = personality(0xffffffff); - int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE); - if (new_personality == -1) { - ALOGW("personality(%d) failed: %s", new_personality, strerror(errno)); - } - } - SetCapabilities(permitted_capabilities, effective_capabilities, permitted_capabilities, fail_fn);