From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 589531D0156; Wed, 2 Oct 2024 13:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727876925; cv=none; b=rmGSJ9NPqTrdLSLdoVj8rfm4pG6AtgBxi78eHEQafLXoueCDY42MFAoFAbXAEItSs0pnfL8XEyx6FliG2Pk+W2dtsYOFdo1iKfxhVYBRs7mcQojpFPR2EhP4Ca6hqyFqw5OltL0kOVPnGF5jVYO9enlvf5oVg3F6kGNkZDD5n7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727876925; c=relaxed/simple; bh=LH5lwcoUD9py9dPJVKJNVnsqPu7XmcE9JgeXYLXqsws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XolQ9hOQeouD07BFOzsLlvs774v1xwgZXP5AkTLneTH8c+CsdCszWa32+vktikEhnnar/htQMai0nxzGZxL2szSYLX4HxB4PYRJPMLzl7j58fmgzBAzEnXwxJnZSgvIY0iQOXHoj6RaMK45UpKpWJ+t0tPf2TMYnN9dITXPAFsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=q1Ws3kz7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="q1Ws3kz7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71C1EC4CEC5; Wed, 2 Oct 2024 13:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1727876924; bh=LH5lwcoUD9py9dPJVKJNVnsqPu7XmcE9JgeXYLXqsws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1Ws3kz7yvcMjK8k4ewSM/7CFGAPX5N4YngCpdKWasRnYhah4h+8RsDeOuh4iICeZ q6GEQ3d9YStEyuTeu2wYFf+k4AIOPHDy3ljfPbBHVntfpvkojly2DGpxzpccNRbQfV YOXAHRsxoeCYpzglSk7bi9Y3+6CtgsIetlWekHjA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Breno Leitao , Usama Arif , Ilias Apalodimas , Ard Biesheuvel Subject: [PATCH 6.11 607/695] efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption Date: Wed, 2 Oct 2024 15:00:05 +0200 Message-ID: <20241002125846.746253426@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241002125822.467776898@linuxfoundation.org> References: <20241002125822.467776898@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit 77d48d39e99170b528e4f2e9fc5d1d64cdedd386 upstream. The TPM event log table is a Linux specific construct, where the data produced by the GetEventLog() boot service is cached in memory, and passed on to the OS using an EFI configuration table. The use of EFI_LOADER_DATA here results in the region being left unreserved in the E820 memory map constructed by the EFI stub, and this is the memory description that is passed on to the incoming kernel by kexec, which is therefore unaware that the region should be reserved. Even though the utility of the TPM2 event log after a kexec is questionable, any corruption might send the parsing code off into the weeds and crash the kernel. So let's use EFI_ACPI_RECLAIM_MEMORY instead, which is always treated as reserved by the E820 conversion logic. Cc: Reported-by: Breno Leitao Tested-by: Usama Arif Reviewed-by: Ilias Apalodimas Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/tpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -96,7 +96,7 @@ static void efi_retrieve_tcg2_eventlog(i } /* Allocate space for the logs and copy them. */ - status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, + status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY, sizeof(*log_tbl) + log_size, (void **)&log_tbl); if (status != EFI_SUCCESS) {