Re: [PATCH 2/2] x86/mm/KASLR: Correct the upper boundary of KALSR mm regions if adjacent to EFI

From: Dave Young
Date: Wed Mar 08 2017 - 03:28:39 EST


On 03/08/17 at 03:47pm, Baoquan He wrote:
> EFI allocates runtime services regions top-down, starting from EFI_VA_START
> to EFI_VA_END. So EFI_VA_START is bigger than EFI_VA_END and is the end of
> EFI region. The upper boundary of memory regions randomized by KASLR should
> be EFI_VA_END if it's adjacent to EFI region, but not EFI_VA_START.
>
> Correct it in this patch.
>
> Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
> ---
> arch/x86/mm/kaslr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
> index 887e571..aed2064 100644
> --- a/arch/x86/mm/kaslr.c
> +++ b/arch/x86/mm/kaslr.c
> @@ -48,7 +48,7 @@ static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;
> #if defined(CONFIG_X86_ESPFIX64)
> static const unsigned long vaddr_end = ESPFIX_BASE_ADDR;
> #elif defined(CONFIG_EFI)
> -static const unsigned long vaddr_end = EFI_VA_START;
> +static const unsigned long vaddr_end = EFI_VA_END;
> #else
> static const unsigned long vaddr_end = __START_KERNEL_map;
> #endif
> @@ -105,7 +105,7 @@ void __init kernel_randomize_memory(void)
> */
> BUILD_BUG_ON(vaddr_start >= vaddr_end);
> BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) &&
> - vaddr_end >= EFI_VA_START);
> + vaddr_end >= EFI_VA_END);
> BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) ||
> IS_ENABLED(CONFIG_EFI)) &&
> vaddr_end >= __START_KERNEL_map);
> --
> 2.5.5
>

Acked-by: Dave Young <dyoung@xxxxxxxxxx>

Thanks
Dave