Skip to content

Commit a46f60d

Browse files
Baoquan HeIngo Molnar
authored andcommitted
x86/mm/KASLR: Exclude EFI region from KASLR VA space randomization
Currently KASLR is enabled on three regions: the direct mapping of physical memory, vamlloc and vmemmap. However the EFI region is also mistakenly included for VA space randomization because of misusing EFI_VA_START macro and assuming EFI_VA_START < EFI_VA_END. (This breaks kexec and possibly other things that rely on stable addresses.) The EFI region is reserved for EFI runtime services virtual mapping which should not be included in KASLR ranges. In Documentation/x86/x86_64/mm.txt, we can see: ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space EFI uses the space from -4G to -64G thus EFI_VA_START > EFI_VA_END, Here EFI_VA_START = -4G, and EFI_VA_END = -64G. Changing EFI_VA_START to EFI_VA_END in mm/kaslr.c fixes this problem. Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Acked-by: Dave Young <[email protected]> Acked-by: Thomas Garnier <[email protected]> Cc: <[email protected]> l1k#4.8+ Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ard Biesheuvel <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Matt Fleming <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 26a37ab commit a46f60d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/mm/kaslr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;
4848
#if defined(CONFIG_X86_ESPFIX64)
4949
static const unsigned long vaddr_end = ESPFIX_BASE_ADDR;
5050
#elif defined(CONFIG_EFI)
51-
static const unsigned long vaddr_end = EFI_VA_START;
51+
static const unsigned long vaddr_end = EFI_VA_END;
5252
#else
5353
static const unsigned long vaddr_end = __START_KERNEL_map;
5454
#endif
@@ -105,7 +105,7 @@ void __init kernel_randomize_memory(void)
105105
*/
106106
BUILD_BUG_ON(vaddr_start >= vaddr_end);
107107
BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) &&
108-
vaddr_end >= EFI_VA_START);
108+
vaddr_end >= EFI_VA_END);
109109
BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) ||
110110
IS_ENABLED(CONFIG_EFI)) &&
111111
vaddr_end >= __START_KERNEL_map);

0 commit comments

Comments
 (0)