OSDN Git Service

In MountEmulatedStorage() do not try to mount for mode MOUNT_EXTERNAL_NONE.
authorRobert Sesek <rsesek@google.com>
Mon, 20 Mar 2017 21:30:05 +0000 (17:30 -0400)
committerRobert Sesek <rsesek@google.com>
Wed, 29 Mar 2017 23:03:14 +0000 (19:03 -0400)
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

index 90ad2da..ac9e636 100644 (file)
@@ -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));