From patchwork Tue Jan 16 13:57:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10167085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3694960325 for ; Tue, 16 Jan 2018 13:57:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28CD62823D for ; Tue, 16 Jan 2018 13:57:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D09128433; Tue, 16 Jan 2018 13:57:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85C292823D for ; Tue, 16 Jan 2018 13:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbeAPN5f (ORCPT ); Tue, 16 Jan 2018 08:57:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:53507 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751295AbeAPN5e (ORCPT ); Tue, 16 Jan 2018 08:57:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 234A7ABF0; Tue, 16 Jan 2018 13:57:33 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, x86@kernel.org Cc: lenb@kernel.org, rafael.j.wysocki@intel.com, hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, Juergen Gross Subject: [PATCH] x86/acpi: check rsdp address received via bootparams to be valid Date: Tue, 16 Jan 2018 14:57:30 +0100 Message-Id: <20180116135730.19216-1-jgross@suse.com> X-Mailer: git-send-email 2.13.6 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There seem to exist several grub2 versions trashing boot_params.hdr.acpi_rsdp_addr. So don't just believe this address to be valid, but verify it pointing to a valid RSDP table. Signed-off-by: Juergen Gross --- To be applied on top of my RSDP series currently in tip.git x86/boot Mike Galbraith has tested this patch to repair his broken boot --- drivers/acpi/acpica/tbxfroot.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/acpi/osl.c | 2 +- include/acpi/acpixf.h | 5 +++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c index f9f9a7da2cad..9edc71780a38 100644 --- a/drivers/acpi/acpica/tbxfroot.c +++ b/drivers/acpi/acpica/tbxfroot.c @@ -249,6 +249,42 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_find_root_pointer) /******************************************************************************* * + * FUNCTION: acpi_verify_root_pointer + * + * + * PARAMETERS: rsdp_address - Pointer to suspected RSDP + * + * RETURN: AE_OK if rsdp_address really points to a RSDP, AE_NOT_FOUND + * else + * + * DESCRIPTION: Verify a physical address being a valid RSDP + * + ******************************************************************************/ + +acpi_status ACPI_INIT_FUNCTION +acpi_verify_root_pointer(acpi_physical_address rsdp_address) +{ + acpi_status status; + struct acpi_table_rsdp *rsdp; + + ACPI_FUNCTION_TRACE(acpi_verify_root_pointer); + + rsdp = acpi_os_map_memory(rsdp_address, sizeof(*rsdp)); + + if (!rsdp) + return_ACPI_STATUS(AE_NO_MEMORY); + + status = acpi_tb_validate_rsdp(rsdp); + + acpi_os_unmap_memory(rsdp, sizeof(*rsdp)); + + return_ACPI_STATUS(status); +} + +ACPI_EXPORT_SYMBOL_INIT(acpi_verify_root_pointer) + +/******************************************************************************* + * * FUNCTION: acpi_tb_scan_memory_for_rsdp * * PARAMETERS: start_address - Starting pointer for search diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 2b77db914752..facff5c11f32 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -201,7 +201,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void) return acpi_rsdp; #endif pa = acpi_arch_get_root_pointer(); - if (pa) + if (pa && acpi_verify_root_pointer(pa) == AE_OK) return pa; if (efi_enabled(EFI_CONFIG_TABLES)) { diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index e1dd1a8d42b6..1edc47bd13c1 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -505,6 +505,11 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_INIT_FUNCTION acpi_find_root_pointer(acpi_physical_address *rsdp_address)) + +ACPI_EXTERNAL_RETURN_OK(acpi_status ACPI_INIT_FUNCTION + acpi_verify_root_pointer(acpi_physical_address + rsdp_address)) + ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_get_table_header(acpi_string signature, u32 instance,