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