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

Commit 11d7bc52 authored by Jiyong Park's avatar Jiyong Park
Browse files

init: don't touch mmap_rnd_compat_bits on 64-bit only builds

mmap_rnd_compat_bits is for address space randomization of 32-bit
applications on 64-bit system. Configuring it is not only unnecessary
for 64-bit "only" builds, but also can cause a boot failure if the
kernel is built without CONFIG_COMPAT which is the case for Microdroid.

Use ro.product.abilist32 to determine whether 32-bit applications are
supported and if not, don't configure it, but mmap_rnd_bits.

Bug: 237950549
Test: run Microdroid with the kernel built with aosp/2153639

Change-Id: Ifca6fa02f14ad4c7d8f9b2ab8852494c12945c3a
parent 46fa45d8
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */


#include "security.h"
#include "security.h"
#include "util.h"


#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
@@ -106,12 +107,12 @@ Result<void> SetMmapRndBitsAction(const BuiltinArguments&) {
    return {};
    return {};
#elif defined(__aarch64__)
#elif defined(__aarch64__)
    // arm64 supports 18 - 33 bits depending on pagesize and VA_SIZE
    // arm64 supports 18 - 33 bits depending on pagesize and VA_SIZE
    if (SetMmapRndBitsMin(33, 24, false) && SetMmapRndBitsMin(16, 16, true)) {
    if (SetMmapRndBitsMin(33, 24, false) && (!Has32BitAbi() || SetMmapRndBitsMin(16, 16, true))) {
        return {};
        return {};
    }
    }
#elif defined(__x86_64__)
#elif defined(__x86_64__)
    // x86_64 supports 28 - 32 bits
    // x86_64 supports 28 - 32 bits
    if (SetMmapRndBitsMin(32, 32, false) && SetMmapRndBitsMin(16, 16, true)) {
    if (SetMmapRndBitsMin(32, 32, false) && (!Has32BitAbi() || SetMmapRndBitsMin(16, 16, true))) {
        return {};
        return {};
    }
    }
#elif defined(__arm__) || defined(__i386__)
#elif defined(__arm__) || defined(__i386__)
+5 −0
Original line number Original line Diff line number Diff line
@@ -733,5 +733,10 @@ bool IsMicrodroid() {
    return is_microdroid;
    return is_microdroid;
}
}


bool Has32BitAbi() {
    static bool has = !android::base::GetProperty("ro.product.cpu.abilist32", "").empty();
    return has;
}

}  // namespace init
}  // namespace init
}  // namespace android
}  // namespace android
+1 −0
Original line number Original line Diff line number Diff line
@@ -106,5 +106,6 @@ bool IsDefaultMountNamespaceReady();
void SetDefaultMountNamespaceReady();
void SetDefaultMountNamespaceReady();


bool IsMicrodroid();
bool IsMicrodroid();
bool Has32BitAbi();
}  // namespace init
}  // namespace init
}  // namespace android
}  // namespace android