[PATCH 4.4 098/230] x86/kexec: Dont setup EFI info if EFI runtime is not enabled

Greg Kroah-Hartman gregkh at linuxfoundation.org
Fri Mar 22 04:13:56 PDT 2019

4.4-stable review patch.  If anyone has any objections, please let me know.


[ Upstream commit 2aa958c99c7fd3162b089a1a56a34a0cdb778de1 ]

Kexec-ing a kernel with "efi=noruntime" on the first kernel's command
line causes the following null pointer dereference:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
  #PF error: [normal kernel read fault]
  Call Trace:

Just skip the EFI info setup if EFI runtime services are not enabled.

 [ bp: Massage commit message. ]

Suggested-by: Dave Young <dyoung at redhat.com>
Signed-off-by: Kairui Song <kasong at redhat.com>
Signed-off-by: Borislav Petkov <bp at suse.de>
Acked-by: Dave Young <dyoung at redhat.com>
Cc: AKASHI Takahiro <takahiro.akashi at linaro.org>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Cc: bhe at redhat.com
Cc: David Howells <dhowells at redhat.com>
Cc: erik.schmauss at intel.com
Cc: fanc.fnst at cn.fujitsu.com
Cc: "H. Peter Anvin" <hpa at zytor.com>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: kexec at lists.infradead.org
Cc: lenb at kernel.org
Cc: linux-acpi at vger.kernel.org
Cc: Philipp Rudo <prudo at linux.vnet.ibm.com>
Cc: rafael.j.wysocki at intel.com
Cc: robert.moore at intel.com
Cc: Thomas Gleixner <tglx at linutronix.de>
Cc: x86-ml <x86 at kernel.org>
Cc: Yannik Sembritzki <yannik at sembritzki.me>
Link: https://lkml.kernel.org/r/20190118111310.29589-2-kasong@redhat.com
Signed-off-by: Sasha Levin <sashal at kernel.org>
 arch/x86/kernel/kexec-bzimage64.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
index 0f8a6bbaaa44..0bf17576dd2a 100644
--- a/arch/x86/kernel/kexec-bzimage64.c
+++ b/arch/x86/kernel/kexec-bzimage64.c
@@ -168,6 +168,9 @@ setup_efi_state(struct boot_params *params, unsigned long params_load_addr,
 	struct efi_info *current_ei = &boot_params.efi_info;
 	struct efi_info *ei = &params->efi_info;
+	if (!efi_enabled(EFI_RUNTIME_SERVICES))
+		return 0;
 	if (!current_ei->efi_memmap_size)
 		return 0;

More information about the kexec mailing list