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

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