From patchwork Mon Mar 20 14:51:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 95554 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp976761qgd; Mon, 20 Mar 2017 07:51:53 -0700 (PDT) X-Received: by 10.98.65.211 with SMTP id g80mr33417659pfd.187.1490021512969; Mon, 20 Mar 2017 07:51:52 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id b21si17752202pgh.172.2017.03.20.07.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 07:51:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 30D6980467; Mon, 20 Mar 2017 07:51:52 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B853380466 for ; Mon, 20 Mar 2017 07:51:50 -0700 (PDT) Received: by mail-wr0-x233.google.com with SMTP id u108so94077711wrb.3 for ; Mon, 20 Mar 2017 07:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=hngXpwzxv1UjHmU4Zn2QMyBGR0OsfTUXKNxoe0pf9r0=; b=bcHhtv6Hj2GaSqJLvChTiqb21zqh/SOjSqR8grci7MOpwpoMXeyFLyXlimIqEsnXsw QNWGp4ZCCWxsRCaZRvLLXz1YPtGpd2tbjJBf7lsqsJ/Hp9F2m9NcvHBMEqAnBMvgeIKU kvduZngpGPN3YIs+N8spBmt+LVovFHGy9plNk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hngXpwzxv1UjHmU4Zn2QMyBGR0OsfTUXKNxoe0pf9r0=; b=tu/BwUF039SfUZsXlXbYS0sEn8k+I3tAOGT+B71zOfyuHpakPmVSjaxdygnDOqSEoc xmS3pGalSGJoZg1hqe/DHJ+rKm6rCbWdskyIJJtp78dkbFPXIpAcOL2OVXr+Uj5e6DKZ wyN8ntWmikrHd4Ie9XmAmWy54fA3sNv/MAEfEN6WS6PyjIs/+uXe2KU/X6TIp5u8bL5O DT0dHtFRwkh25IDJ6deuIr5NrqKvPH3qTDiGSmvkAhV7wtXPKoiHlgGoCkuH0gtuf6o8 CUOrMht614DuDlIct90KySREbhpPiLug4sPgrwjqQJ3Vdcn7ppuaYGJh6u6Bfr0Nu903 MBOA== X-Gm-Message-State: AFeK/H2a28Tox2eIBgsKHc/OXmyoNCkx+0NQqYjn2Rx1N3kVfXHg8oRDz6e0l5CIO7AHIa0K X-Received: by 10.223.134.44 with SMTP id 41mr25873679wrv.26.1490021509103; Mon, 20 Mar 2017 07:51:49 -0700 (PDT) Received: from localhost.localdomain ([160.167.112.48]) by smtp.gmail.com with ESMTPSA id k8sm20839236wre.19.2017.03.20.07.51.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 07:51:48 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, star.zeng@intel.com, feng.tian@intel.com Date: Mon, 20 Mar 2017 14:51:36 +0000 Message-Id: <1490021496-10195-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [edk2] [PATCH] MdeModulePkg/AcpiTableDxe: consider version mask when removing tables X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Invocations of EFI_ACPI_TABLE_PROTOCOL::UninstallAcpiTable() may result in a crash when the value of PcdAcpiExposedTableVersions does not include EFI_ACPI_TABLE_VERSION_1_0B. The reason is that EFI_ACPI_TABLE_PROTOCOL::InstallAcpiTable() will only populate the Rsdt1/Rsdt3 pointers when EFI_ACPI_TABLE_VERSION_1_0B is set, whereas EFI_ACPI_TABLE_PROTOCOL::UninstallAcpiTable() will invoke PublishTables with EFI_ACPI_TABLE_VERSION_1_0B alawys set, resulting in a NULL pointer dereference of the Rsdt1/Rsdt3 pointers. So take PcdAcpiExposedTableVersions into account for UninstallAcpiTable as well. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Star Zeng Signed-off-by: Ard Biesheuvel diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index 4bb848df5203..a635e1de5a7c 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -290,24 +290,27 @@ UninstallAcpiTable ( { EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance; EFI_STATUS Status; + EFI_ACPI_TABLE_VERSION Version; // // Get the instance of the ACPI table protocol // AcpiTableInstance = EFI_ACPI_TABLE_INSTANCE_FROM_THIS (This); + Version = PcdGet32 (PcdAcpiExposedTableVersions); + // // Uninstall the ACPI table // Status = RemoveTableFromList ( AcpiTableInstance, - EFI_ACPI_TABLE_VERSION_1_0B | ACPI_TABLE_VERSION_GTE_2_0, + Version, TableKey ); if (!EFI_ERROR (Status)) { Status = PublishTables ( AcpiTableInstance, - EFI_ACPI_TABLE_VERSION_1_0B | ACPI_TABLE_VERSION_GTE_2_0 + Version ); }