Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp733490ima; Fri, 1 Feb 2019 10:07:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbhkgjdZ1vOzrL+c2FjwcgNUd+VrUp8CDH+J/UIosn9DgTXwWINdJejBUV4jBjMcJv/mE/U X-Received: by 2002:a63:287:: with SMTP id 129mr3169506pgc.332.1549044461950; Fri, 01 Feb 2019 10:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549044461; cv=none; d=google.com; s=arc-20160816; b=sTOYemYh8qBwlXF/dGCLT5uhnBXlWcJNLRqnHeTkmNI3z6lkNAMGUYvfnLKZp56yNx hwBy/3PcPFbBtU3yDAAl30O3/AMB3CC1X1vTPqPVqbjYI28YkMExpuiwLop0ca9KvRGl Twha6A4sozuew9gG38KnrEYZ4bZT1jC0jjProGw633EGUqLwyxrAYxZJTZaFWb6n3mJH TPdLgd7WkjjpbTIHfrczQQA6mRQfMujyt6Duwk3/c4cQkwMSX2tQFL0LE7myt0jp8/4S BXcjfKXO+YhQBgO3Uy3dETix25gQ236OEJ0hGlCAWDkuhsvU0TxZttSpcJNRCEH+/q7a RTSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=/4cRxjfDGnMZgnwhyW9L15fUiGZkCh42q+orhSuCK7Q=; b=yKP96AAvB84pleyvY24ulYEs7VlmNlU+bN7H3O6W25wsFqqcEhSFWrAC3KsxAQiDya h6PsAV3QOqK/qTiyAyBFRqUkQOmrQViteg0tnCJK5YLPttc35oPjgE5SW65U3PySdkRL VhrczOAwVOXYhn9vrC+7bs9TOgcLVh1yD/kzqGlU4ZSe0X+BQMb+S85pQKiaj+2Ui4/c uL8sL/TCyG7dNEpwJZWasocDewdBeDb6j2sRjLxCuaBJuWaC0QQnjLqCEFFHY17vfG3Q ylJAjjuMCC+iKon9BNZO02NWpukwokkWG1vrJBs9Ub8APumDcvtzwqg9D3rn93s704Yc r1Lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si7462455pgs.304.2019.02.01.10.07.26; Fri, 01 Feb 2019 10:07:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729830AbfBARhb (ORCPT + 99 others); Fri, 1 Feb 2019 12:37:31 -0500 Received: from terminus.zytor.com ([198.137.202.136]:55845 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfBARhb (ORCPT ); Fri, 1 Feb 2019 12:37:31 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x11HavC23410558 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 1 Feb 2019 09:36:57 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x11HauJ03410555; Fri, 1 Feb 2019 09:36:56 -0800 Date: Fri, 1 Feb 2019 09:36:56 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kairui Song Message-ID: Cc: x86@kernel.org, hpa@zytor.com, takahiro.akashi@linaro.org, linux-kernel@vger.kernel.org, bp@suse.de, dyoung@redhat.com, akpm@linux-foundation.org, tglx@linutronix.de, dhowells@redhat.com, yannik@sembritzki.me, kasong@redhat.com, mingo@redhat.com, prudo@linux.vnet.ibm.com, ard.biesheuvel@linaro.org, mingo@kernel.org Reply-To: dhowells@redhat.com, tglx@linutronix.de, akpm@linux-foundation.org, dyoung@redhat.com, bp@suse.de, linux-kernel@vger.kernel.org, x86@kernel.org, takahiro.akashi@linaro.org, hpa@zytor.com, ard.biesheuvel@linaro.org, mingo@kernel.org, prudo@linux.vnet.ibm.com, mingo@redhat.com, kasong@redhat.com, yannik@sembritzki.me In-Reply-To: <20190118111310.29589-2-kasong@redhat.com> References: <20190118111310.29589-2-kasong@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/kexec: Don't setup EFI info if EFI runtime is not enabled Git-Commit-ID: 2aa958c99c7fd3162b089a1a56a34a0cdb778de1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2aa958c99c7fd3162b089a1a56a34a0cdb778de1 Gitweb: https://git.kernel.org/tip/2aa958c99c7fd3162b089a1a56a34a0cdb778de1 Author: Kairui Song AuthorDate: Fri, 18 Jan 2019 19:13:08 +0800 Committer: Borislav Petkov CommitDate: Fri, 1 Feb 2019 18:18:54 +0100 x86/kexec: Don't setup EFI info if EFI runtime is not enabled 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 --- 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 0d5efa34f359..53917a3ebf94 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;