diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index bcb6c0f9ae87a..72eb32a05da9f 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -24,7 +24,6 @@ import android.content.pm.ApplicationInfo; import android.net.Credentials; import android.net.LocalServerSocket; import android.net.LocalSocket; -import android.os.Build; import android.os.FactoryTest; import android.os.IVold; import android.os.Process; @@ -254,16 +253,13 @@ public final class Zygote { */ public static int forkAndSpecialize(int uid, int gid, int[] gids, int runtimeFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, - int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir, - int targetSdkVersion) { + int[] fdsToIgnore, boolean startChildZygote, String instructionSet, String appDataDir) { ZygoteHooks.preFork(); int pid = nativeForkAndSpecialize( uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, fdsToIgnore, startChildZygote, instructionSet, appDataDir); if (pid == 0) { - Zygote.disableExecuteOnly(targetSdkVersion); - // Note that this event ends at the end of handleChildProc, Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "PostFork"); } @@ -649,8 +645,6 @@ public final class Zygote { args.mSeInfo, args.mNiceName, args.mStartChildZygote, args.mInstructionSet, args.mAppDataDir); - disableExecuteOnly(args.mTargetSdkVersion); - Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); return ZygoteInit.zygoteInit(args.mTargetSdkVersion, @@ -729,17 +723,6 @@ public final class Zygote { } } - /** - * Mark execute-only segments of libraries read+execute for apps with targetSdkVersion #include #include -#include #include #include #include @@ -55,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -72,10 +70,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -1783,31 +1779,6 @@ static void com_android_internal_os_Zygote_nativeEmptyUsapPool(JNIEnv* env, jcla } } -static int disable_execute_only(struct dl_phdr_info *info, size_t size, void *data) { - // Search for any execute-only segments and mark them read+execute. - for (int i = 0; i < info->dlpi_phnum; i++) { - const auto& phdr = info->dlpi_phdr[i]; - if ((phdr.p_type == PT_LOAD) && (phdr.p_flags == PF_X)) { - auto addr = reinterpret_cast(info->dlpi_addr + PAGE_START(phdr.p_vaddr)); - size_t len = PAGE_OFFSET(phdr.p_vaddr) + phdr.p_memsz; - if (mprotect(addr, len, PROT_READ | PROT_EXEC) == -1) { - ALOGE("mprotect(%p, %zu, PROT_READ | PROT_EXEC) failed: %m", addr, len); - return -1; - } - } - } - // Return non-zero to exit dl_iterate_phdr. - return 0; -} - -/** - * @param env Managed runtime environment - * @return True if disable was successful. - */ -static jboolean com_android_internal_os_Zygote_nativeDisableExecuteOnly(JNIEnv* env, jclass) { - return dl_iterate_phdr(disable_execute_only, nullptr) == 0; -} - static void com_android_internal_os_Zygote_nativeBlockSigTerm(JNIEnv* env, jclass) { auto fail_fn = std::bind(ZygoteFailure, env, "usap", nullptr, _1); BlockSignal(SIGTERM, fail_fn); @@ -1889,8 +1860,6 @@ static const JNINativeMethod gMethods[] = { (void *) com_android_internal_os_Zygote_nativeGetUsapPoolCount }, { "nativeEmptyUsapPool", "()V", (void *) com_android_internal_os_Zygote_nativeEmptyUsapPool }, - { "nativeDisableExecuteOnly", "()Z", - (void *) com_android_internal_os_Zygote_nativeDisableExecuteOnly }, { "nativeBlockSigTerm", "()V", (void* ) com_android_internal_os_Zygote_nativeBlockSigTerm }, { "nativeUnblockSigTerm", "()V",