lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-c7d2361f7524f365c1ae42f47880e3fa9efb2c2a@git.kernel.org>
Date:	Wed, 10 Aug 2016 11:08:42 -0700
From:	tip-bot for Thomas Garnier <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	thgarnie@...gle.com, peterz@...radead.org,
	dave.hansen@...ux.intel.com, linux-kernel@...r.kernel.org,
	bhe@...hat.com, jroedel@...e.de, borntraeger@...ibm.com,
	fabf@...net.be, dyoung@...hat.com, lv.zheng@...el.com,
	luto@...nel.org, dan.j.williams@...el.com, tglx@...utronix.de,
	bp@...en8.de, aleksey.makarov@...aro.org, dvlasenk@...hat.com,
	msalter@...hat.com, toshi.kani@...com, mingo@...nel.org,
	keescook@...omium.org, torvalds@...ux-foundation.org,
	brgerst@...il.com, bp@...e.de, hpa@...or.com,
	rafael.j.wysocki@...el.com, akpm@...ux-foundation.org,
	jpoimboe@...hat.com
Subject: [tip:x86/mm] x86/mm/KASLR: Fix physical memory calculation on KASLR
 memory randomization

Commit-ID:  c7d2361f7524f365c1ae42f47880e3fa9efb2c2a
Gitweb:     http://git.kernel.org/tip/c7d2361f7524f365c1ae42f47880e3fa9efb2c2a
Author:     Thomas Garnier <thgarnie@...gle.com>
AuthorDate: Tue, 9 Aug 2016 10:11:04 -0700
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Wed, 10 Aug 2016 14:45:19 +0200

x86/mm/KASLR: Fix physical memory calculation on KASLR memory randomization

Initialize KASLR memory randomization after max_pfn is initialized. Also
ensure the size is rounded up. It could create problems on machines
with more than 1Tb of memory on certain random addresses.

Signed-off-by: Thomas Garnier <thgarnie@...gle.com>
Cc: Aleksey Makarov <aleksey.makarov@...aro.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Baoquan He <bhe@...hat.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Borislav Petkov <bp@...e.de>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Christian Borntraeger <borntraeger@...ibm.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Dave Young <dyoung@...hat.com>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: Fabian Frederick <fabf@...net.be>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Joerg Roedel <jroedel@...e.de>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Kees Cook <keescook@...omium.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Lv Zheng <lv.zheng@...el.com>
Cc: Mark Salter <msalter@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rafael J . Wysocki <rafael.j.wysocki@...el.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Toshi Kani <toshi.kani@...com>
Cc: kernel-hardening@...ts.openwall.com
Fixes: 021182e52fe0 ("Enable KASLR for physical mapping memory regions")
Link: http://lkml.kernel.org/r/1470762665-88032-1-git-send-email-thgarnie@google.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 arch/x86/kernel/setup.c | 8 ++++++--
 arch/x86/mm/kaslr.c     | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 991b779..95cf31c 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -936,8 +936,6 @@ void __init setup_arch(char **cmdline_p)
 
 	x86_init.oem.arch_setup();
 
-	kernel_randomize_memory();
-
 	iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
 	setup_memory_map();
 	parse_setup_data();
@@ -1055,6 +1053,12 @@ void __init setup_arch(char **cmdline_p)
 
 	max_possible_pfn = max_pfn;
 
+	/*
+	 * Define random base addresses for memory sections after max_pfn is
+	 * defined and before each memory section base is used.
+	 */
+	kernel_randomize_memory();
+
 #ifdef CONFIG_X86_32
 	/* max_low_pfn get updated here */
 	find_low_pfn_range();
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 26dccd6..ec8654f 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -97,7 +97,7 @@ void __init kernel_randomize_memory(void)
 	 * add padding if needed (especially for memory hotplug support).
 	 */
 	BUG_ON(kaslr_regions[0].base != &page_offset_base);
-	memory_tb = ((max_pfn << PAGE_SHIFT) >> TB_SHIFT) +
+	memory_tb = DIV_ROUND_UP(max_pfn << PAGE_SHIFT, 1UL << TB_SHIFT) +
 		CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING;
 
 	/* Adapt phyiscal memory region size based on available memory */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ