]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/arm64-kaslr-reserve-size-of-arm64_memstart_align-in-.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / queue-4.19 / arm64-kaslr-reserve-size-of-arm64_memstart_align-in-.patch
1 From 47ed7d6da8d07637f01dab77a252bc36fe19dfcb Mon Sep 17 00:00:00 2001
2 From: Yueyi Li <liyueyi@live.com>
3 Date: Mon, 24 Dec 2018 07:40:07 +0000
4 Subject: arm64: kaslr: Reserve size of ARM64_MEMSTART_ALIGN in linear region
5
6 [ Upstream commit c8a43c18a97845e7f94ed7d181c11f41964976a2 ]
7
8 When KASLR is enabled (CONFIG_RANDOMIZE_BASE=y), the top 4K of kernel
9 virtual address space may be mapped to physical addresses despite being
10 reserved for ERR_PTR values.
11
12 Fix the randomization of the linear region so that we avoid mapping the
13 last page of the virtual address space.
14
15 Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
16 Signed-off-by: liyueyi <liyueyi@live.com>
17 [will: rewrote commit message; merged in suggestion from Ard]
18 Signed-off-by: Will Deacon <will.deacon@arm.com>
19 Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
20 ---
21 arch/arm64/mm/init.c | 2 +-
22 1 file changed, 1 insertion(+), 1 deletion(-)
23
24 diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
25 index 787e27964ab9..774c3e17c798 100644
26 --- a/arch/arm64/mm/init.c
27 +++ b/arch/arm64/mm/init.c
28 @@ -450,7 +450,7 @@ void __init arm64_memblock_init(void)
29 * memory spans, randomize the linear region as well.
30 */
31 if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) {
32 - range = range / ARM64_MEMSTART_ALIGN + 1;
33 + range /= ARM64_MEMSTART_ALIGN;
34 memstart_addr -= ARM64_MEMSTART_ALIGN *
35 ((range * memstart_offset_seed) >> 16);
36 }
37 --
38 2.19.1
39