From b87b2555406fd9541389a1bc4671816e7153e75c Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Tue, 21 May 2024 17:27:39 +0000 Subject: [PATCH] riscv64: increase ASLR randomness for Sv48/57 Linux 6.9+ supports 33 bits with Sv48 and Sv57. Increase the maximum and update the comment. Bug: https://github.com/google/android-riscv64/issues/1 Test: Treehugger Change-Id: Ia2731143ad30c5febe2058d35a381c01b14d8c3c --- init/security.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init/security.cpp b/init/security.cpp index 3e1544750..a0d63bca8 100644 --- a/init/security.cpp +++ b/init/security.cpp @@ -114,10 +114,9 @@ Result SetMmapRndBitsAction(const BuiltinArguments&) { return {}; } #elif defined(__riscv) - // TODO: sv48 and sv57 have both been added to the kernel, but the kernel - // still doesn't support more than 24 bits. - // https://github.com/google/android-riscv64/issues/1 - if (SetMmapRndBitsMin(24, 24, false)) { + // riscv64 supports 24 rnd bits with Sv39, and starting with the 6.9 kernel, + // 33 bits with Sv48 and Sv57. + if (SetMmapRndBitsMin(33, 24, false)) { return {}; } #elif defined(__x86_64__)