From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Ard Biesheuvel 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: [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: , X-List-Received-Date: Mon, 20 Mar 2017 14:51:51 -0000 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(-) 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 ); } -- 2.7.4