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

From: Borislav Petkov
Date: Tue Feb 05 2019 - 09:44:56 EST


On Wed, Jan 30, 2019 at 05:40:03PM +0100, Julian Stecklina wrote:
> 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;
> }
> --

Lemme add some of the folks from
f28442497b5caf7bf573ade22a7f8d3559e3ef56 to Cc.

It all looks arbitrary to me: first 4 unusable memmap regions, this
patch raises it to 16. Why are we even imposing such a limit?

Hmm.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.