public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization
@ 2017-03-24  4:59 Baoquan He
       [not found] ` <1490331592-31860-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Baoquan He @ 2017-03-24  4:59 UTC (permalink / raw)
  To: linux-kernel
  Cc: Baoquan He, stable, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, linux-efi, Thomas Garnier, Kees Cook, Borislav Petkov,
	Andrew Morton, Masahiro Yamada, Dave Young, Bhupesh Sharma

Currently KASLR is enabled on three regions: the direct mapping of physical
memory, vamlloc and vmemmap. However 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.

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 use 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.

Cc: <stable@vger.kernel.org> #4.8+
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: linux-efi@vger.kernel.org
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Bhupesh Sharma <bhsharma@redhat.com>
---
v1->v2:
  No code change, just update patch log according to reviewer's comment.

 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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-03-24 11:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-24  4:59 [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization Baoquan He
     [not found] ` <1490331592-31860-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-24  8:08   ` Ingo Molnar
     [not found]     ` <20170324080833.GA15200-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-24  8:34       ` Baoquan He
2017-03-24  8:46         ` Dave Young
2017-03-24  9:24           ` Ingo Molnar
2017-03-24  9:36             ` Borislav Petkov
     [not found]             ` <20170324092433.GA3237-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-24  9:37               ` Ard Biesheuvel
2017-03-24  9:40                 ` Borislav Petkov
2017-03-24  9:42                   ` Ard Biesheuvel
     [not found]                     ` <CAKv+Gu9cyMccPSjzr9XGT6Gkhq57is+i_VajsZMTbd9eOAMkwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-24  9:46                       ` Borislav Petkov
     [not found]                         ` <20170324094656.r2nln4vbidj5jhqt-fF5Pk5pvG8Y@public.gmane.org>
2017-03-24  9:52                           ` Ard Biesheuvel
     [not found]                 ` <CAKv+Gu_V_VAWuDtKyOY9RS+cdhi+c5z2a7n2kcXVybvvdmPYBw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-24 10:36                   ` Ingo Molnar
2017-03-24 10:42                     ` Ard Biesheuvel
2017-03-24 10:54                       ` Ingo Molnar
2017-03-24 11:52             ` Baoquan He
2017-03-24  8:53     ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox