am cb634bda: Merge "clean up native com.android.internal.os.Zygote"
* commit 'cb634bda7b0130015509b0e4d236d10b20b2340d': clean up native com.android.internal.os.Zygote
This commit is contained in:
@@ -14,46 +14,40 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "android_runtime/AndroidRuntime.h"
|
#define LOG_TAG "Zygote"
|
||||||
|
|
||||||
// sys/mount.h has to come before linux/fs.h due to redefinition of MS_RDONLY, MS_BIND, etc
|
// sys/mount.h has to come before linux/fs.h due to redefinition of MS_RDONLY, MS_BIND, etc
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <sys/capability.h>
|
||||||
|
#include <sys/personality.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include "cutils/fs.h"
|
|
||||||
#include "cutils/multiuser.h"
|
#include <cutils/fs.h>
|
||||||
#include "cutils/sched_policy.h"
|
#include <cutils/multiuser.h>
|
||||||
#include "utils/String8.h"
|
#include <cutils/sched_policy.h>
|
||||||
|
#include <utils/String8.h>
|
||||||
|
#include <selinux/android.h>
|
||||||
|
|
||||||
|
#include "android_runtime/AndroidRuntime.h"
|
||||||
#include "JNIHelp.h"
|
#include "JNIHelp.h"
|
||||||
#include "ScopedLocalRef.h"
|
#include "ScopedLocalRef.h"
|
||||||
#include "ScopedPrimitiveArray.h"
|
#include "ScopedPrimitiveArray.h"
|
||||||
#include "ScopedUtfChars.h"
|
#include "ScopedUtfChars.h"
|
||||||
|
|
||||||
#if defined(HAVE_PRCTL)
|
|
||||||
#include <sys/prctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <selinux/android.h>
|
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
#include <sys/personality.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#if defined(HAVE_ANDROID_OS)
|
|
||||||
#include <sys/capability.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using android::String8;
|
using android::String8;
|
||||||
@@ -97,11 +91,9 @@ static void SigChldHandler(int /*signal_number*/) {
|
|||||||
if (WTERMSIG(status) != SIGKILL) {
|
if (WTERMSIG(status) != SIGKILL) {
|
||||||
ALOGI("Process %d exited due to signal (%d)", pid, WTERMSIG(status));
|
ALOGI("Process %d exited due to signal (%d)", pid, WTERMSIG(status));
|
||||||
}
|
}
|
||||||
#ifdef WCOREDUMP
|
|
||||||
if (WCOREDUMP(status)) {
|
if (WCOREDUMP(status)) {
|
||||||
ALOGI("Process %d dumped core.", pid);
|
ALOGI("Process %d dumped core.", pid);
|
||||||
}
|
}
|
||||||
#endif /* ifdef WCOREDUMP */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the just-crashed process is the system_server, bring down zygote
|
// If the just-crashed process is the system_server, bring down zygote
|
||||||
@@ -199,8 +191,6 @@ static void SetRLimits(JNIEnv* env, jobjectArray javaRlimits) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_ANDROID_OS)
|
|
||||||
|
|
||||||
// The debug malloc library needs to know whether it's the zygote or a child.
|
// The debug malloc library needs to know whether it's the zygote or a child.
|
||||||
extern "C" int gMallocLeakZygoteChild;
|
extern "C" int gMallocLeakZygoteChild;
|
||||||
|
|
||||||
@@ -254,17 +244,6 @@ static void SetSchedulerPolicy(JNIEnv* env) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static int gMallocLeakZygoteChild = 0;
|
|
||||||
|
|
||||||
static void EnableKeepCapabilities(JNIEnv*) {}
|
|
||||||
static void DropCapabilitiesBoundingSet(JNIEnv*) {}
|
|
||||||
static void SetCapabilities(JNIEnv*, int64_t, int64_t) {}
|
|
||||||
static void SetSchedulerPolicy(JNIEnv*) {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create a private mount namespace and bind mount appropriate emulated
|
// Create a private mount namespace and bind mount appropriate emulated
|
||||||
// storage for the given user.
|
// storage for the given user.
|
||||||
static bool MountEmulatedStorage(uid_t uid, jint mount_mode) {
|
static bool MountEmulatedStorage(uid_t uid, jint mount_mode) {
|
||||||
@@ -337,7 +316,6 @@ static bool MountEmulatedStorage(uid_t uid, jint mount_mode) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
static bool NeedsNoRandomizeWorkaround() {
|
static bool NeedsNoRandomizeWorkaround() {
|
||||||
#if !defined(__arm__)
|
#if !defined(__arm__)
|
||||||
return false;
|
return false;
|
||||||
@@ -357,7 +335,6 @@ static bool NeedsNoRandomizeWorkaround() {
|
|||||||
return (major < 3) || ((major == 3) && (minor < 4));
|
return (major < 3) || ((major == 3) && (minor < 4));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Utility to close down the Zygote socket file descriptors while
|
// Utility to close down the Zygote socket file descriptors while
|
||||||
// the child is still running as root with Zygote's privileges. Each
|
// the child is still running as root with Zygote's privileges. Each
|
||||||
@@ -474,7 +451,6 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
|
|||||||
RuntimeAbort(env);
|
RuntimeAbort(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
if (NeedsNoRandomizeWorkaround()) {
|
if (NeedsNoRandomizeWorkaround()) {
|
||||||
// Work around ARM kernel ASLR lossage (http://b/5817320).
|
// Work around ARM kernel ASLR lossage (http://b/5817320).
|
||||||
int old_personality = personality(0xffffffff);
|
int old_personality = personality(0xffffffff);
|
||||||
@@ -483,14 +459,11 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
|
|||||||
ALOGW("personality(%d) failed", new_personality);
|
ALOGW("personality(%d) failed", new_personality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SetCapabilities(env, permittedCapabilities, effectiveCapabilities);
|
SetCapabilities(env, permittedCapabilities, effectiveCapabilities);
|
||||||
|
|
||||||
SetSchedulerPolicy(env);
|
SetSchedulerPolicy(env);
|
||||||
|
|
||||||
#if defined(HAVE_ANDROID_OS)
|
|
||||||
{ // NOLINT(whitespace/braces)
|
|
||||||
const char* se_info_c_str = NULL;
|
const char* se_info_c_str = NULL;
|
||||||
ScopedUtfChars* se_info = NULL;
|
ScopedUtfChars* se_info = NULL;
|
||||||
if (java_se_info != NULL) {
|
if (java_se_info != NULL) {
|
||||||
@@ -529,12 +502,6 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
|
|||||||
|
|
||||||
delete se_info;
|
delete se_info;
|
||||||
delete se_name;
|
delete se_name;
|
||||||
}
|
|
||||||
#else
|
|
||||||
UNUSED(is_system_server);
|
|
||||||
UNUSED(java_se_info);
|
|
||||||
UNUSED(java_se_name);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UnsetSigChldHandler();
|
UnsetSigChldHandler();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user