[PATCH 1/1] KVM: arm64: Make nVHE ASLR conditional on nokaslr

qixiang.xu at outlook.com qixiang.xu at outlook.com
Wed Sep 4 23:30:26 PDT 2024


From: Qxiang Xu <qixiang.xu at outlook.com>

The random tag of hyp VA is determined by the `CONFIG_RANDOMIZE_BASE`
option, so even if `nokaslr` is set in the cmdline, KASLR cannot be
disabled for hyp VA. To align with kernel behavior, disable KASLR if
the kernel cmdline includes `nokaslr`.

Link: https://lore.kernel.org/r/20240905061659.3410362-1-qixiang.xu@outlook.com
Signed-off-by: Qxiang Xu <qixiang.xu at outlook.com>
---
 arch/arm64/kvm/va_layout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c
index 91b22a014610..bebb4b1ddc82 100644
--- a/arch/arm64/kvm/va_layout.c
+++ b/arch/arm64/kvm/va_layout.c
@@ -72,7 +72,7 @@ __init void kvm_compute_layout(void)
 	va_mask = GENMASK_ULL(tag_lsb - 1, 0);
 	tag_val = hyp_va_msb;
 
-	if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && tag_lsb != (vabits_actual - 1)) {
+	if (kaslr_enabled() && tag_lsb != (vabits_actual - 1)) {
 		/* We have some free bits to insert a random tag. */
 		tag_val |= get_random_long() & GENMASK_ULL(vabits_actual - 2, tag_lsb);
 	}
-- 
2.25.1




More information about the linux-arm-kernel mailing list