Loading core/jni/com_android_internal_os_Zygote.cpp +17 −16 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ static void SetSigChldHandler() { int err = sigaction(SIGCHLD, &sa, NULL); if (err < 0) { ALOGW("Error setting SIGCHLD handler: %d", errno); ALOGW("Error setting SIGCHLD handler: %s", strerror(errno)); } } Loading @@ -142,7 +142,7 @@ static void UnsetSigChldHandler() { int err = sigaction(SIGCHLD, &sa, NULL); if (err < 0) { ALOGW("Error unsetting SIGCHLD handler: %d", errno); ALOGW("Error unsetting SIGCHLD handler: %s", strerror(errno)); } } Loading Loading @@ -257,7 +257,7 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na // Create a second private mount namespace for our process if (unshare(CLONE_NEWNS) == -1) { ALOGW("Failed to unshare(): %d", errno); ALOGW("Failed to unshare(): %s", strerror(errno)); return false; } Loading Loading @@ -294,14 +294,15 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na if (mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) { // Mount entire external storage tree for all users if (TEMP_FAILURE_RETRY(mount(source, target, NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s :%d", source, target, errno); ALOGW("Failed to mount %s to %s: %s", source, target, strerror(errno)); return false; } } else { // Only mount user-specific external storage if (TEMP_FAILURE_RETRY( mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %d", source_user.string(), target_user.string(), errno); if (TEMP_FAILURE_RETRY(mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %s", source_user.string(), target_user.string(), strerror(errno)); return false; } } Loading @@ -313,7 +314,7 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na // Finally, mount user-specific path into place for legacy users if (TEMP_FAILURE_RETRY( mount(target_user.string(), legacy, NULL, MS_BIND | MS_REC, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %d", target_user.string(), legacy, errno); ALOGW("Failed to mount %s to %s: %s", target_user.string(), legacy, strerror(errno)); return false; } } else { Loading Loading @@ -364,13 +365,13 @@ static void DetachDescriptors(JNIEnv* env, jintArray fdsToClose) { for (i = 0; i < count; i++) { devnull = open("/dev/null", O_RDWR); if (devnull < 0) { ALOGE("Failed to open /dev/null"); ALOGE("Failed to open /dev/null: %s", strerror(errno)); RuntimeAbort(env); continue; } ALOGV("Switching descriptor %d to /dev/null: %d", ar[i], errno); ALOGV("Switching descriptor %d to /dev/null: %s", ar[i], strerror(errno)); if (dup2(devnull, ar[i]) < 0) { ALOGE("Failed dup2() on descriptor %d", ar[i]); ALOGE("Failed dup2() on descriptor %d: %s", ar[i], strerror(errno)); RuntimeAbort(env); } close(devnull); Loading Loading @@ -400,7 +401,7 @@ void SetThreadName(const char* thread_name) { strlcpy(buf, s, sizeof(buf)-1); errno = pthread_setname_np(pthread_self(), buf); if (errno != 0) { ALOGW("Unable to set the name of current thread to '%s'", buf); ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno)); } } Loading Loading @@ -437,7 +438,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) { ALOGW("Failed to mount emulated storage: %d", errno); ALOGW("Failed to mount emulated storage: %s", strerror(errno)); if (errno == ENOTCONN || errno == EROFS) { // When device is actively encrypting, we get ENOTCONN here // since FUSE was mounted before the framework restarted. Loading Loading @@ -478,13 +479,13 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra int rc = setresgid(gid, gid, gid); if (rc == -1) { ALOGE("setresgid(%d) failed", gid); ALOGE("setresgid(%d) failed: %s", gid, strerror(errno)); RuntimeAbort(env); } rc = setresuid(uid, uid, uid); if (rc == -1) { ALOGE("setresuid(%d) failed", uid); ALOGE("setresuid(%d) failed: %s", uid, strerror(errno)); RuntimeAbort(env); } Loading @@ -493,7 +494,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra int old_personality = personality(0xffffffff); int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE); if (new_personality == -1) { ALOGW("personality(%d) failed", new_personality); ALOGW("personality(%d) failed: %s", new_personality, strerror(errno)); } } Loading Loading
core/jni/com_android_internal_os_Zygote.cpp +17 −16 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ static void SetSigChldHandler() { int err = sigaction(SIGCHLD, &sa, NULL); if (err < 0) { ALOGW("Error setting SIGCHLD handler: %d", errno); ALOGW("Error setting SIGCHLD handler: %s", strerror(errno)); } } Loading @@ -142,7 +142,7 @@ static void UnsetSigChldHandler() { int err = sigaction(SIGCHLD, &sa, NULL); if (err < 0) { ALOGW("Error unsetting SIGCHLD handler: %d", errno); ALOGW("Error unsetting SIGCHLD handler: %s", strerror(errno)); } } Loading Loading @@ -257,7 +257,7 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na // Create a second private mount namespace for our process if (unshare(CLONE_NEWNS) == -1) { ALOGW("Failed to unshare(): %d", errno); ALOGW("Failed to unshare(): %s", strerror(errno)); return false; } Loading Loading @@ -294,14 +294,15 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na if (mount_mode == MOUNT_EXTERNAL_MULTIUSER_ALL) { // Mount entire external storage tree for all users if (TEMP_FAILURE_RETRY(mount(source, target, NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s :%d", source, target, errno); ALOGW("Failed to mount %s to %s: %s", source, target, strerror(errno)); return false; } } else { // Only mount user-specific external storage if (TEMP_FAILURE_RETRY( mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %d", source_user.string(), target_user.string(), errno); if (TEMP_FAILURE_RETRY(mount(source_user.string(), target_user.string(), NULL, MS_BIND, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %s", source_user.string(), target_user.string(), strerror(errno)); return false; } } Loading @@ -313,7 +314,7 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode, bool force_mount_na // Finally, mount user-specific path into place for legacy users if (TEMP_FAILURE_RETRY( mount(target_user.string(), legacy, NULL, MS_BIND | MS_REC, NULL)) == -1) { ALOGW("Failed to mount %s to %s: %d", target_user.string(), legacy, errno); ALOGW("Failed to mount %s to %s: %s", target_user.string(), legacy, strerror(errno)); return false; } } else { Loading Loading @@ -364,13 +365,13 @@ static void DetachDescriptors(JNIEnv* env, jintArray fdsToClose) { for (i = 0; i < count; i++) { devnull = open("/dev/null", O_RDWR); if (devnull < 0) { ALOGE("Failed to open /dev/null"); ALOGE("Failed to open /dev/null: %s", strerror(errno)); RuntimeAbort(env); continue; } ALOGV("Switching descriptor %d to /dev/null: %d", ar[i], errno); ALOGV("Switching descriptor %d to /dev/null: %s", ar[i], strerror(errno)); if (dup2(devnull, ar[i]) < 0) { ALOGE("Failed dup2() on descriptor %d", ar[i]); ALOGE("Failed dup2() on descriptor %d: %s", ar[i], strerror(errno)); RuntimeAbort(env); } close(devnull); Loading Loading @@ -400,7 +401,7 @@ void SetThreadName(const char* thread_name) { strlcpy(buf, s, sizeof(buf)-1); errno = pthread_setname_np(pthread_self(), buf); if (errno != 0) { ALOGW("Unable to set the name of current thread to '%s'", buf); ALOGW("Unable to set the name of current thread to '%s': %s", buf, strerror(errno)); } } Loading Loading @@ -437,7 +438,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } if (!MountEmulatedStorage(uid, mount_external, need_native_bridge)) { ALOGW("Failed to mount emulated storage: %d", errno); ALOGW("Failed to mount emulated storage: %s", strerror(errno)); if (errno == ENOTCONN || errno == EROFS) { // When device is actively encrypting, we get ENOTCONN here // since FUSE was mounted before the framework restarted. Loading Loading @@ -478,13 +479,13 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra int rc = setresgid(gid, gid, gid); if (rc == -1) { ALOGE("setresgid(%d) failed", gid); ALOGE("setresgid(%d) failed: %s", gid, strerror(errno)); RuntimeAbort(env); } rc = setresuid(uid, uid, uid); if (rc == -1) { ALOGE("setresuid(%d) failed", uid); ALOGE("setresuid(%d) failed: %s", uid, strerror(errno)); RuntimeAbort(env); } Loading @@ -493,7 +494,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra int old_personality = personality(0xffffffff); int new_personality = personality(old_personality | ADDR_NO_RANDOMIZE); if (new_personality == -1) { ALOGW("personality(%d) failed", new_personality); ALOGW("personality(%d) failed: %s", new_personality, strerror(errno)); } } Loading