Skip to content

Commit c8a43c1

Browse files
liyueyiwildea01
authored andcommitted
arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region
When KASLR is enabled (CONFIG_RANDOMIZE_BASE=y), the top 4K of kernel virtual address space may be mapped to physical addresses despite being reserved for ERR_PTR values. Fix the randomization of the linear region so that we avoid mapping the last page of the virtual address space. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: liyueyi <liyueyi@live.com> [will: rewrote commit message; merged in suggestion from Ard] Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent acafce4 commit c8a43c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎arch/arm64/mm/init.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ void __init arm64_memblock_init(void)
457457
* memory spans, randomize the linear region as well.
458458
*/
459459
if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) {
460-
range = range / ARM64_MEMSTART_ALIGN + 1;
460+
range /= ARM64_MEMSTART_ALIGN;
461461
memstart_addr -= ARM64_MEMSTART_ALIGN *
462462
((range * memstart_offset_seed) >> 16);
463463
}

0 commit comments

Comments
 (0)