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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 10 Sep 2018 17:39:38 +0800
From:   Feng Tang <feng.tang@...el.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Michal Hocko <mhocko@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        linux-kernel@...r.kernel.org, x86@...nel.org,
        Ingo Molnar <mingo@...e.hu>,
        "H . Peter Anvin" <hpa@...ux.intel.com>,
        Yinghai Lu <yinghai@...nel.org>,
        Dave Hansen <dave.hansen@...el.com>,
        Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH] x86, mm: Reserver some memory for bootmem allocator for
 NO_BOOTMEM

On Fri, Sep 07, 2018 at 12:52:17PM +0200, Thomas Gleixner wrote:
> On Fri, 7 Sep 2018, Feng Tang wrote:
> > On Fri, Aug 31, 2018 at 09:36:59PM +0800, Feng Tang wrote:
> > > Any sugestion? I can only have patch like this:
> > 
> > Could you review this patch, as at this time window there is no usable memory
> > block or other memory allocators that I know, so I follow the exisitng static
> > fixmap page table code and add one more.
> 
> You really want to add a proper sanity check for this. The static stuff has
> to cover the fixmap. Just making it work for this particular case is sloppy
> at best as the next larger change of the fixmap will just bring the problem
> back.
Yes, agree.

Since the issue happens very early before any serial console, I can only think
of a build time check.

Thanks,
Feng

---
 arch/x86/kernel/head_64.S |  6 +++++-
 arch/x86/mm/pgtable.c     | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 15ebc2fc166e..3a1d33b43c29 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -448,11 +448,15 @@ NEXT_PAGE(level2_fixmap_pgt)
 	.fill	506,8,0
 	.quad	level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
 	/* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
-	.fill	5,8,0
+	.quad	level1_fixmap_pgt1 - __START_KERNEL_map + _PAGE_TABLE_NOENC
+	.fill	4,8,0
 
 NEXT_PAGE(level1_fixmap_pgt)
 	.fill	512,8,0
 
+NEXT_PAGE(level1_fixmap_pgt1)
+	.fill	512,8,0
+
 #undef PMDS
 
 	.data
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index e848a4811785..fc172551048a 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -637,6 +637,19 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
 {
 	unsigned long address = __fix_to_virt(idx);
 
+#ifdef CONFIG_X86_64
+	/*
+	 * In arch/x86/kernel/head_64.S, the static page table
+	 * has been setup for 4M space [-12M, -8M]
+	 *	0xFFFFFFFFFF400000 ~ 0xFFFFFFFFFF7FFFFF
+	 * Add a sanity check whether fixed_address crosses
+	 * the boundary.
+	 */
+	#define FIXMAP_STATIC_PGTABLE_START	0xFFFFFFFFFF400000
+	BUILD_BUG_ON(__fix_to_virt(__end_of_permanent_fixed_addresses)
+			< FIXMAP_STATIC_PGTABLE_START);
+#endif
+
 	if (idx >= __end_of_fixed_addresses) {
 		BUG();
 		return;
-- 
2.14.1

> 
> Thanks,
> 
> 	tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ