[PATCH 2/2] x86/boot: increase maximum number of avoided KASLR regions

From: Julian Stecklina
Date: Wed Jan 30 2019 - 11:40:57 EST


From: Julian Stecklina <jsteckli@xxxxxxxxx>

The boot code has a limit of 4 "non-standard" regions to avoid for
KASLR. This limit is easy to reach when supplying memmap= parameters to
the kernel. In this case, KASLR would be disabled.

Increase the limit to avoid turning off KASLR even when the user is
heavily manipulating the memory map.

Signed-off-by: Julian Stecklina <jsteckli@xxxxxxxxx>
---
arch/x86/boot/compressed/kaslr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 5657e34..f078d60 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -92,8 +92,8 @@ struct mem_vector {
unsigned long long size;
};

-/* Only supporting at most 4 unusable memmap regions with kaslr */
-#define MAX_MEMMAP_REGIONS 4
+/* Only supporting at most this many unusable memmap regions with kaslr */
+#define MAX_MEMMAP_REGIONS 16

static bool memmap_too_large;

@@ -213,7 +213,7 @@ static void mem_avoid_memmap(char *str)
i++;
}

- /* More than 4 memmaps, fail kaslr */
+ /* Can't store all regions, fail kaslr */
if ((i >= MAX_MEMMAP_REGIONS) && str)
memmap_too_large = true;
}
--
2.7.4