]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/boot: Respect kaslr_enabled() for identity randomization
authorVasily Gorbik <gor@linux.ibm.com>
Wed, 25 Feb 2026 09:30:28 +0000 (10:30 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 5 Mar 2026 20:08:50 +0000 (21:08 +0100)
CONFIG_RANDOMIZE_IDENTITY_BASE only enables support for randomizing the
identity mapping base. The randomization (identity base != 0) itself
should happen only when KASLR is enabled at runtime.

Guard the __identity_base update with kaslr_enabled() so nokaslr (and
other KASLR-disabled cases) keep the non-randomized identity mapping at 0.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/boot/startup.c

index 7f3343493ab98c2a131a59f0c73b066132267810..c1dcf8b1b5794cdcb399d1cb613c0c986e46aa7c 100644 (file)
@@ -440,7 +440,8 @@ static unsigned long setup_kernel_memory_layout(unsigned long kernel_size)
        max_mappable = max(ident_map_size, MAX_DCSS_ADDR);
        max_mappable = min(max_mappable, vmemmap_start);
 #ifdef CONFIG_RANDOMIZE_IDENTITY_BASE
-       __identity_base = round_down(vmemmap_start - max_mappable, rte_size);
+       if (kaslr_enabled())
+               __identity_base = round_down(vmemmap_start - max_mappable, rte_size);
 #endif
        boot_debug("identity map:        0x%016lx-0x%016lx\n", __identity_base,
                   __identity_base + ident_map_size);