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

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