diff options
| author | 2018-05-14 18:16:52 +0000 | |
|---|---|---|
| committer | 2018-05-14 18:16:52 +0000 | |
| commit | 690eff4bd0b9d535d0a93af0d791a39e63e47cd8 (patch) | |
| tree | 02ba0e4c3143f617cb08dca906d57b5c4cb2f1e4 | |
| parent | 466ada94fe8848da5637d2134a460291b5e00a22 (diff) | |
| parent | 2da359c5464d68a74279919ee4741c7b22a7ef0b (diff) | |
Merge "Merge "When suid_dumpable == 2, set dumpable to 0 for apps" am: 659a13121c" into stage-aosp-master
| -rw-r--r-- | core/jni/com_android_internal_os_Zygote.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index e5281ff9b624..8d6a2800a45d 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -704,6 +704,26 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra fail_fn(CREATE_ERROR("setresuid(%d) failed: %s", uid, strerror(errno))); } + // The "dumpable" flag of a process, which controls core dump generation, is + // overwritten by the value in /proc/sys/fs/suid_dumpable when the effective + // user or group ID changes. See proc(5) for possible values. In most cases, + // the value is 0, so core dumps are disabled for zygote children. However, + // when running in a Chrome OS container, the value is already set to 2, + // which allows the external crash reporter to collect all core dumps. Since + // only system crashes are interested, core dump is disabled for app + // processes. This also ensures compliance with CTS. + int dumpable = prctl(PR_GET_DUMPABLE); + if (dumpable == -1) { + ALOGE("prctl(PR_GET_DUMPABLE) failed: %s", strerror(errno)); + RuntimeAbort(env, __LINE__, "prctl(PR_GET_DUMPABLE) failed"); + } + if (dumpable == 2 && uid >= AID_APP) { + if (prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) == -1) { + ALOGE("prctl(PR_SET_DUMPABLE, 0) failed: %s", strerror(errno)); + RuntimeAbort(env, __LINE__, "prctl(PR_SET_DUMPABLE, 0) failed"); + } + } + if (NeedsNoRandomizeWorkaround()) { // Work around ARM kernel ASLR lossage (http://b/5817320). int old_personality = personality(0xffffffff); |