Blame SOURCES/0038-tpm-Define-EFI_VARIABLE_DATA_TREE-as-packed.patch

00e791
From 9f80be9f16a854e3946568fa92edebe26eb79e78 Mon Sep 17 00:00:00 2001
00e791
From: Chris Coulson <chris.coulson@canonical.com>
00e791
Date: Sat, 22 Jun 2019 15:37:29 +0100
00e791
Subject: [PATCH 38/62] tpm: Define EFI_VARIABLE_DATA_TREE as packed
00e791
00e791
tpm_measure_variable() calculates VarLogSize by adding the size of VarName
00e791
and VarData to the size of EFI_VARIABLE_DATA_TREE, and then subtracting
00e791
the size of the UnicodeName and VariableData members. This results in a
00e791
calculation that is 5 bytes larger than necessary because it doesn't take
00e791
in to account the padding of these members. The effect of this is that
00e791
shim measures an additional 5 zero bytes when measuring UEFI variables
00e791
(at least on 64-bit architectures).
00e791
00e791
Byte packing EFI_VARIABLE_DATA_TREE fixes this.
00e791
00e791
Upstream-commit-id: 7e4d3f1c8c7
00e791
---
00e791
 tpm.c | 2 +-
00e791
 1 file changed, 1 insertion(+), 1 deletion(-)
00e791
00e791
diff --git a/tpm.c b/tpm.c
00e791
index 516fb876caa..c0617bb479e 100644
00e791
--- a/tpm.c
00e791
+++ b/tpm.c
00e791
@@ -233,7 +233,7 @@ typedef struct {
00e791
 	UINT64 VariableDataLength;
00e791
 	CHAR16 UnicodeName[1];
00e791
 	INT8 VariableData[1];
00e791
-} EFI_VARIABLE_DATA_TREE;
00e791
+} __attribute__ ((packed)) EFI_VARIABLE_DATA_TREE;
00e791
 
00e791
 static BOOLEAN tpm_data_measured(CHAR16 *VarName, EFI_GUID VendorGuid, UINTN VarSize, VOID *VarData)
00e791
 {
00e791
-- 
00e791
2.26.2
00e791