Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2da359c5 authored by Victor Hsieh's avatar Victor Hsieh Committed by android-build-merger
Browse files

Merge "When suid_dumpable == 2, set dumpable to 0 for apps"

am: 659a1312

Change-Id: I02d210fd4d9e13a3f548411cea57a4f2e37c7481
parents 36b515e3 659a1312
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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);
+4 −7
Original line number Diff line number Diff line
@@ -18,13 +18,10 @@
#include <utils/TypeHelpers.h>
#include <stdarg.h>

// SSIZE: mingw does not have signed size_t == ssize_t.
// STATUST: mingw does seem to redefine UNKNOWN_ERROR from our enum value, so a cast is necessary.
#if !defined(_WIN32)
#  define SSIZE(x) x
#  define STATUST(x) x
#else
#  define SSIZE(x) (signed size_t)x
#  define STATUST(x) (status_t)x
#endif

@@ -3040,7 +3037,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
        sp<AaptFile> strFile = p->getTypeStringsData();
        ssize_t amt = data->writeData(strFile->getData(), strFile->getSize());
        if (kPrintStringMetrics) {
            fprintf(stderr, "**** type strings: %zd\n", SSIZE(amt));
            fprintf(stderr, "**** type strings: %zd\n", amt);
        }
        strAmt += amt;
        if (amt < 0) {
@@ -3050,7 +3047,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
        strFile = p->getKeyStringsData();
        amt = data->writeData(strFile->getData(), strFile->getSize());
        if (kPrintStringMetrics) {
            fprintf(stderr, "**** key strings: %zd\n", SSIZE(amt));
            fprintf(stderr, "**** key strings: %zd\n", amt);
        }
        strAmt += amt;
        if (amt < 0) {
@@ -3322,8 +3319,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
    ssize_t amt = (dest->getSize()-strStart);
    strAmt += amt;
    if (kPrintStringMetrics) {
        fprintf(stderr, "**** value strings: %zd\n", SSIZE(amt));
        fprintf(stderr, "**** total strings: %zd\n", SSIZE(strAmt));
        fprintf(stderr, "**** value strings: %zd\n", amt);
        fprintf(stderr, "**** total strings: %zd\n", amt);
    }

    for (pi=0; pi<flatPackages.size(); pi++) {
+2 −9
Original line number Diff line number Diff line
@@ -12,13 +12,6 @@

#include "ResourceTable.h"

// SSIZE: mingw does not have signed size_t == ssize_t.
#if !defined(_WIN32)
#  define SSIZE(x) x
#else
#  define SSIZE(x) (signed size_t)x
#endif

// Set to true for noisy debug output.
static const bool kIsDebug = false;

@@ -202,7 +195,7 @@ ssize_t StringPool::add(const String16& value,

    if (kIsDebug) {
        printf("Adding string %s to pool: pos=%zd eidx=%zd vidx=%zd\n",
                String8(value).string(), SSIZE(pos), SSIZE(eidx), SSIZE(vidx));
                String8(value).string(), pos, eidx, vidx);
    }

    return pos;
@@ -598,7 +591,7 @@ ssize_t StringPool::offsetForString(const String16& val) const
    const Vector<size_t>* indices = offsetsForString(val);
    ssize_t res = indices != NULL && indices->size() > 0 ? indices->itemAt(0) : -1;
    if (kIsDebug) {
        printf("Offset for string %s: %zd (%s)\n", String8(val).string(), SSIZE(res),
        printf("Offset for string %s: %zd (%s)\n", String8(val).string(), res,
                res >= 0 ? String8(mEntries[mEntryArray[res]].value).string() : String8());
    }
    return res;
+2 −5
Original line number Diff line number Diff line
@@ -16,13 +16,10 @@
#define O_BINARY 0
#endif

// SSIZE: mingw does not have signed size_t == ssize_t.
// STATUST: mingw does seem to redefine UNKNOWN_ERROR from our enum value, so a cast is necessary.
#if !defined(_WIN32)
#  define SSIZE(x) x
#  define STATUST(x) x
#else
#  define SSIZE(x) (signed size_t)x
#  define STATUST(x) (status_t)x
#endif

@@ -1426,7 +1423,7 @@ status_t XMLNode::collect_attr_strings(StringPool* outPool,
                idx = outPool->add(attr.name);
                if (kIsDebug) {
                    printf("Adding attr %s (resid 0x%08x) to pool: idx=%zd\n",
                            String8(attr.name).string(), id, SSIZE(idx));
                            String8(attr.name).string(), id, idx);
                }
                if (id != 0) {
                    while ((ssize_t)outResIds->size() <= idx) {
@@ -1437,7 +1434,7 @@ status_t XMLNode::collect_attr_strings(StringPool* outPool,
            }
            attr.namePoolIdx = idx;
            if (kIsDebug) {
                printf("String %s offset=0x%08zd\n", String8(attr.name).string(), SSIZE(idx));
                printf("String %s offset=0x%08zd\n", String8(attr.name).string(), idx);
            }
        }
    }