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-next>] [day] [month] [year] [list]
Message-Id: <1453385519-11477-1-git-send-email-matt@codeblueprint.co.uk>
Date:	Thu, 21 Jan 2016 14:11:59 +0000
From:	Matt Fleming <matt@...eblueprint.co.uk>
To:	Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H . Peter Anvin" <hpa@...or.com>
Cc:	linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org,
	Matt Fleming <matt@...eblueprint.co.uk>,
	Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>,
	Dave Young <dyoung@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Borislav Petkov <bp@...en8.de>,
	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Subject: [PATCH] x86/efi: Setup separate EFI page tables in kexec paths

The switch to using a new dedicated page table for EFI runtime calls
in commit commit 67a9108ed431 ("x86/efi: Build our own page table
structures") failed to take into account changes required for the
kexec code paths, which are unfortunately duplicated in the EFI code.

Call the allocation and setup functions in kexec_enter_virtual_mode()
just like we do for __efi_enter_virtual_mode() to avoid hitting
NULL-pointer dereferences when making EFI runtime calls.

At the very least, the call to efi_setup_page_tables() should have
existed for kexec before commit 67a9108ed431. Things just magically
worked because we were actually using the kernel's page tables that
contained the required mappings.

Reported-by: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>
Cc: Dave Young <dyoung@...hat.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Borislav Petkov <bp@...en8.de>
Signed-off-by: Matt Fleming <matt@...eblueprint.co.uk>
---
 arch/x86/platform/efi/efi.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Folks, please apply this to the queue of EFI patches sitting in
tip/x86/efi.

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 3c1f3cd7b2ba..2aedee71f965 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -815,6 +815,7 @@ static void __init kexec_enter_virtual_mode(void)
 {
 #ifdef CONFIG_KEXEC_CORE
 	efi_memory_desc_t *md;
+	unsigned num_pages;
 	void *p;
 
 	efi.systab = NULL;
@@ -829,6 +830,12 @@ static void __init kexec_enter_virtual_mode(void)
 		return;
 	}
 
+	if (efi_alloc_page_tables()) {
+		pr_err("Failed to allocate EFI page tables\n");
+		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+		return;
+	}
+
 	/*
 	* Map efi regions which were passed via setup_data. The virt_addr is a
 	* fixed addr which was used in first kernel of a kexec boot.
@@ -843,6 +850,14 @@ static void __init kexec_enter_virtual_mode(void)
 
 	BUG_ON(!efi.systab);
 
+	num_pages = ALIGN(memmap.nr_map * memmap.desc_size, PAGE_SIZE);
+	num_pages >>= PAGE_SHIFT;
+
+	if (efi_setup_page_tables(memmap.phys_map, num_pages)) {
+		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
+		return;
+	}
+
 	efi_sync_low_kernel_mappings();
 
 	/*
-- 
2.6.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ