From 06f393067772f613e938f794444dc90e90c40fc0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 20 Mar 2017 17:30:05 -0400 Subject: [PATCH] In MountEmulatedStorage() do not try to mount for mode MOUNT_EXTERNAL_NONE. When creating an isolatedProcess=true service and when the native bridge is in use, MountEmulatedStorage() is called with force_mount_namespace=true and MOUNT_EXTERNAL_NONE. This led to an abort crash, since the process would attempt to mount an empty path string. Test: android.externalservice.cts.ExternalServiceTest built for ARM, run on Fugu Bug: 36072260 Change-Id: I9441bcbd30167971ad486726bbeae57f3c4aebe9 --- core/jni/com_android_internal_os_Zygote.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 90ad2da6fb184..ac9e636adb2a0 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -346,6 +346,11 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, return false; } + // Handle force_mount_namespace with MOUNT_EXTERNAL_NONE. + if (mount_mode == MOUNT_EXTERNAL_NONE) { + return true; + } + if (TEMP_FAILURE_RETRY(mount(storageSource.string(), "/storage", NULL, MS_BIND | MS_REC | MS_SLAVE, NULL)) == -1) { ALOGW("Failed to mount %s to /storage: %s", storageSource.string(), strerror(errno));