Merge "arm64: update the "minimum maximum" comment." into main

This commit is contained in:
Elliott Hughes 2023-09-20 15:55:18 +00:00 committed by Gerrit Code Review
commit cc8d909ccb

View file

@ -106,13 +106,9 @@ Result<void> SetMmapRndBitsAction(const BuiltinArguments&) {
// uml does not support mmap_rnd_bits
return {};
#elif defined(__aarch64__)
// arm64 architecture supports 18 - 33 rnd bits depending on pagesize and
// VA_SIZE. However the kernel might have been compiled with a narrower
// range using CONFIG_ARCH_MMAP_RND_BITS_MIN/MAX. To use the maximum
// supported number of bits, we start from the theoretical maximum of 33
// bits and try smaller values until we reach 24 bits which is the
// Android-specific minimum. Don't go lower even if the configured maximum
// is smaller than 24.
// arm64 supports 14 - 33 rnd bits depending on page size and ARM64_VA_BITS.
// The kernel (6.5) still defaults to 39 va bits for 4KiB pages, so shipping
// devices are only getting 24 bits of randomness in practice.
if (SetMmapRndBitsMin(33, 24, false) && (!Has32BitAbi() || SetMmapRndBitsMin(16, 16, true))) {
return {};
}