Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1400304

[PATCH v5 4/4] x86, boot: Memory hotplug support for KASLR memory randomization

From Thomas Garnier <thgarnie@google.com>
Newsgroups linux.kernel
Subject [PATCH v5 4/4] x86, boot: Memory hotplug support for KASLR memory randomization
Date 2016-05-12 21:30 +0200
Message-ID <ry4t4-3G6-13@gated-at.bofh.it> (permalink)
References <ry4t4-3G6-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add a new option (CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING) to define
the padding used for the physical memory mapping section when KASLR
memory is enabled. It ensures there is enough virtual address space when
CONFIG_MEMORY_HOTPLUG is used. The default value is 10 terabytes. If
CONFIG_MEMORY_HOTPLUG is not used, no space is reserved increasing the
entropy available.

Signed-off-by: Thomas Garnier <thgarnie@google.com>
---
Based on next-20160511
---
 arch/x86/Kconfig    | 15 +++++++++++++++
 arch/x86/mm/kaslr.c |  7 ++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f5ed150..0e5087d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2005,6 +2005,21 @@ config RANDOMIZE_MEMORY
 
 	   If unsure, say N.
 
+config RANDOMIZE_MEMORY_PHYSICAL_PADDING
+	hex "Physical memory mapping padding" if EXPERT
+	depends on RANDOMIZE_MEMORY
+	default "0xa" if MEMORY_HOTPLUG
+	default "0x0"
+	range 0x1 0x40 if MEMORY_HOTPLUG
+	range 0x0 0x40
+	---help---
+	   Define the padding in terabyte added to the existing physical memory
+	   size during kernel memory randomization. It is useful for memory
+	   hotplug support but reduces the entropy available for address
+	   randomization.
+
+	   If unsure, leave at the default value.
+
 config HOTPLUG_CPU
 	bool "Support for hot-pluggable CPUs"
 	depends on SMP
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 2415178..5e86082 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -88,8 +88,13 @@ void __init kernel_randomize_memory(void)
 	if (!kaslr_enabled())
 		return;
 
+	/*
+	 * Update Physical memory mapping to available and
+	 * add padding if needed (especially for memory hotplug support).
+	 */
 	BUG_ON(kaslr_regions[0].base != &page_offset_base);
-	mem_tb = ((max_pfn << PAGE_SHIFT) >> TB_SHIFT);
+	mem_tb = ((max_pfn << PAGE_SHIFT) >> TB_SHIFT) +
+		CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING;
 
 	if (mem_tb < kaslr_regions[0].size_tb)
 		kaslr_regions[0].size_tb = mem_tb;
-- 
2.8.0.rc3.226.g39d4020

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/4] x86, boot: KASLR memory randomization Thomas Garnier <thgarnie@google.com> - 2016-05-12 21:30 +0200
  [PATCH v5 2/4] x86, boot: PUD VA support for physical mapping (x86_64) Thomas Garnier <thgarnie@google.com> - 2016-05-12 21:30 +0200
  [PATCH v5 1/4] x86, boot: Refactor KASLR entropy functions Thomas Garnier <thgarnie@google.com> - 2016-05-12 21:30 +0200
    Re: [PATCH v5 1/4] x86, boot: Refactor KASLR entropy functions kbuild test robot <lkp@intel.com> - 2016-05-12 22:30 +0200
  [PATCH v5 4/4] x86, boot: Memory hotplug support for KASLR memory randomization Thomas Garnier <thgarnie@google.com> - 2016-05-12 21:30 +0200
  [PATCH v5 3/4] x86, boot: Implement ASLR for kernel memory sections (x86_64) Thomas Garnier <thgarnie@google.com> - 2016-05-12 21:30 +0200
  Re: [PATCH v5 0/4] x86, boot: KASLR memory randomization Thomas Garnier <thgarnie@google.com> - 2016-05-16 20:30 +0200
    Re: [PATCH v5 0/4] x86, boot: KASLR memory randomization Kees Cook <keescook@chromium.org> - 2016-05-17 10:20 +0200
      Re: [PATCH v5 0/4] x86, boot: KASLR memory randomization Kees Cook <keescook@chromium.org> - 2016-05-17 21:40 +0200
  Re: [PATCH v5 0/4] x86, boot: KASLR memory randomization Kees Cook <keescook@chromium.org> - 2016-05-17 21:40 +0200

csiph-web