From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH AUTOSEL 4.14 38/45] x86/kexec: Don't setup EFI info if EFI runtime is not enabled Date: Sat, 23 Feb 2019 16:08:28 -0500 Message-ID: <20190223210835.201708-38-sashal@kernel.org> References: <20190223210835.201708-1-sashal@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190223210835.201708-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+glkk-kexec=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Sasha Levin , x86-ml , Philipp Rudo , rafael.j.wysocki-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, Kairui Song , bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, Ard Biesheuvel , fanc.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, robert.moore-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, David Howells , AKASHI Takahiro , Yannik Sembritzki , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Borislav Petkov , erik.schmauss-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, Thomas Gleixner , lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org List-Id: linux-acpi@vger.kernel.org From: Kairui Song [ 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: efi_runtime_map_copy+0x28/0x30 bzImage64_load+0x688/0x872 arch_kexec_kernel_image_load+0x6d/0x70 kimage_file_alloc_init+0x13e/0x220 __x64_sys_kexec_file_load+0x144/0x290 do_syscall_64+0x55/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Just skip the EFI info setup if EFI runtime services are not enabled. [ bp: Massage commit message. ] Suggested-by: Dave Young Signed-off-by: Kairui Song Signed-off-by: Borislav Petkov Acked-by: Dave Young Cc: AKASHI Takahiro Cc: Andrew Morton Cc: Ard Biesheuvel Cc: bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Cc: David Howells Cc: erik.schmauss-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org Cc: fanc.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Cc: lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Cc: linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Philipp Rudo Cc: rafael.j.wysocki-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org Cc: robert.moore-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org Cc: Thomas Gleixner Cc: x86-ml Cc: Yannik Sembritzki Link: https://lkml.kernel.org/r/20190118111310.29589-2-kasong-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Signed-off-by: Sasha Levin --- 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 928b0c6083c9c..4d948d87f01cc 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -167,6 +167,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 = ¶ms->efi_info; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + if (!current_ei->efi_memmap_size) return 0; -- 2.19.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81A30C43381 for ; Sat, 23 Feb 2019 21:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C3BD2086D for ; Sat, 23 Feb 2019 21:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956186; bh=EDrsdxAjNapM30aqqCBelQjfxMcVe8s+YQ0BDPXBnpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fyp0nAzbrPA2jG4l2pndAOcGDyDUBWT00ArgW6OK9AtETYrJKnKP1NyxIro+Irb8B f8q7uUYW9xExN7Y3tYmZun7dgxqKWyWQvHKUPM5gEZ+mJSduvG2w2hYWCDjgOFEV82 OSWM3x7MXnFJOoGOzAywQV/ql4M/sTj7+Gh522Ms= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729591AbfBWVJo (ORCPT ); Sat, 23 Feb 2019 16:09:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:45292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728652AbfBWVJh (ORCPT ); Sat, 23 Feb 2019 16:09:37 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 240662086C; Sat, 23 Feb 2019 21:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550956176; bh=EDrsdxAjNapM30aqqCBelQjfxMcVe8s+YQ0BDPXBnpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yVQegnnP17eeYx6t7KNPEWJVvZpeR1fWdpAeRCf2q65fMrdBgFjTELkH9QH4TkdLz qI5/+zf4lSG9SzAImMUXKNUXeIWig2BiKEJiLmxkcyKTrpVw1apjLrc/rWsr3r8eTR UO2BjZeQ9Eax3EEvC6YCUO/JLAAYojyzqTaZbQwc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kairui Song , Borislav Petkov , AKASHI Takahiro , Andrew Morton , Ard Biesheuvel , bhe@redhat.com, David Howells , erik.schmauss@intel.com, fanc.fnst@cn.fujitsu.com, "H. Peter Anvin" , Ingo Molnar , kexec@lists.infradead.org, lenb@kernel.org, linux-acpi@vger.kernel.org, Philipp Rudo , rafael.j.wysocki@intel.com, robert.moore@intel.com, Thomas Gleixner , x86-ml , Yannik Sembritzki , Sasha Levin Subject: [PATCH AUTOSEL 4.14 38/45] x86/kexec: Don't setup EFI info if EFI runtime is not enabled Date: Sat, 23 Feb 2019 16:08:28 -0500 Message-Id: <20190223210835.201708-38-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190223210835.201708-1-sashal@kernel.org> References: <20190223210835.201708-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kairui Song [ 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: efi_runtime_map_copy+0x28/0x30 bzImage64_load+0x688/0x872 arch_kexec_kernel_image_load+0x6d/0x70 kimage_file_alloc_init+0x13e/0x220 __x64_sys_kexec_file_load+0x144/0x290 do_syscall_64+0x55/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Just skip the EFI info setup if EFI runtime services are not enabled. [ bp: Massage commit message. ] Suggested-by: Dave Young Signed-off-by: Kairui Song Signed-off-by: Borislav Petkov Acked-by: Dave Young Cc: AKASHI Takahiro Cc: Andrew Morton Cc: Ard Biesheuvel Cc: bhe@redhat.com Cc: David Howells Cc: erik.schmauss@intel.com Cc: fanc.fnst@cn.fujitsu.com Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: kexec@lists.infradead.org Cc: lenb@kernel.org Cc: linux-acpi@vger.kernel.org Cc: Philipp Rudo Cc: rafael.j.wysocki@intel.com Cc: robert.moore@intel.com Cc: Thomas Gleixner Cc: x86-ml Cc: Yannik Sembritzki Link: https://lkml.kernel.org/r/20190118111310.29589-2-kasong@redhat.com Signed-off-by: Sasha Levin --- 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 928b0c6083c9c..4d948d87f01cc 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -167,6 +167,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 = ¶ms->efi_info; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + if (!current_ei->efi_memmap_size) return 0; -- 2.19.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxeYC-0000I7-TE for kexec@lists.infradead.org; Sat, 23 Feb 2019 21:09:38 +0000 From: Sasha Levin Subject: [PATCH AUTOSEL 4.14 38/45] x86/kexec: Don't setup EFI info if EFI runtime is not enabled Date: Sat, 23 Feb 2019 16:08:28 -0500 Message-Id: <20190223210835.201708-38-sashal@kernel.org> In-Reply-To: <20190223210835.201708-1-sashal@kernel.org> References: <20190223210835.201708-1-sashal@kernel.org> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin , x86-ml , Philipp Rudo , rafael.j.wysocki@intel.com, Kairui Song , bhe@redhat.com, Ard Biesheuvel , fanc.fnst@cn.fujitsu.com, kexec@lists.infradead.org, linux-acpi@vger.kernel.org, robert.moore@intel.com, David Howells , AKASHI Takahiro , Yannik Sembritzki , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Borislav Petkov , erik.schmauss@intel.com, Thomas Gleixner , lenb@kernel.org From: Kairui Song [ 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: efi_runtime_map_copy+0x28/0x30 bzImage64_load+0x688/0x872 arch_kexec_kernel_image_load+0x6d/0x70 kimage_file_alloc_init+0x13e/0x220 __x64_sys_kexec_file_load+0x144/0x290 do_syscall_64+0x55/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Just skip the EFI info setup if EFI runtime services are not enabled. [ bp: Massage commit message. ] Suggested-by: Dave Young Signed-off-by: Kairui Song Signed-off-by: Borislav Petkov Acked-by: Dave Young Cc: AKASHI Takahiro Cc: Andrew Morton Cc: Ard Biesheuvel Cc: bhe@redhat.com Cc: David Howells Cc: erik.schmauss@intel.com Cc: fanc.fnst@cn.fujitsu.com Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: kexec@lists.infradead.org Cc: lenb@kernel.org Cc: linux-acpi@vger.kernel.org Cc: Philipp Rudo Cc: rafael.j.wysocki@intel.com Cc: robert.moore@intel.com Cc: Thomas Gleixner Cc: x86-ml Cc: Yannik Sembritzki Link: https://lkml.kernel.org/r/20190118111310.29589-2-kasong@redhat.com Signed-off-by: Sasha Levin --- 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 928b0c6083c9c..4d948d87f01cc 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -167,6 +167,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 = ¶ms->efi_info; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + if (!current_ei->efi_memmap_size) return 0; -- 2.19.1 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec