arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region
authorYueyi Li <[email protected]>
Mon, 24 Dec 2018 07:40:07 +0000 (07:40 +0000)
committerWill Deacon <[email protected]>
Thu, 3 Jan 2019 18:03:54 +0000 (18:03 +0000)
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 <[email protected]>
Signed-off-by: liyueyi <[email protected]>
[will: rewrote commit message; merged in suggestion from Ard]
Signed-off-by: Will Deacon <[email protected]>
arch/arm64/mm/init.c

index 4bfe0fc9edac66801b4758dfe98467392a5c4b45..124be28e4e1630d87bb91e6d38080b2eecce51c8 100644 (file)
@@ -457,7 +457,7 @@ void __init arm64_memblock_init(void)
                 * memory spans, randomize the linear region as well.
                 */
                if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) {
-                       range = range / ARM64_MEMSTART_ALIGN + 1;
+                       range /= ARM64_MEMSTART_ALIGN;
                        memstart_addr -= ARM64_MEMSTART_ALIGN *
                                         ((range * memstart_offset_seed) >> 16);
                }