From bc54b94fe145a23a503120c39da35274c951e71d Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Tue, 23 Mar 2021 08:58:21 +1100 Subject: secvar/backend/edk2.h: mark structs as __packed explicitly The structes we import from EDK2 are expected to be packed. The code we imported does this a #pragma pack, but it doesn't restore the original non-packed state at the end of the header. Rather than changing that, just explictly pack every structure. The resulting skiboot.elf has the same disassembly (objdump -dr) and readelf -a output, but I haven't been able to test this on a real machine. Signed-off-by: Daniel Axtens Signed-off-by: Vasant Hegde --- libstb/secvar/backend/edk2.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libstb') diff --git a/libstb/secvar/backend/edk2.h b/libstb/secvar/backend/edk2.h index 1ed9a11..c7b1999 100644 --- a/libstb/secvar/backend/edk2.h +++ b/libstb/secvar/backend/edk2.h @@ -42,6 +42,8 @@ #ifndef __EDK2_H__ #define __EDK2_H__ +#include + #define UUID_SIZE 16 typedef struct { @@ -138,9 +140,8 @@ struct efi_time { /// /// The format of a signature database. /// -#pragma pack(1) -typedef struct { +typedef struct __packed { /// /// An identifier which identifies the agent which added the signature to the list. /// @@ -151,7 +152,7 @@ typedef struct { unsigned char SignatureData[0]; } EFI_SIGNATURE_DATA; -typedef struct { +typedef struct __packed { /// /// Type of the signature. GUID signature types are defined in below. /// @@ -204,7 +205,7 @@ struct win_certificate { * the certificate depends on wCertificateType. */ /// UINT8 bCertificate[ANYSIZE_ARRAY]; -}; +} __packed; /* * Certificate which encapsulates a GUID-specific digital signature @@ -226,7 +227,8 @@ struct win_certificate_uefi_guid { * EFI_CERT_BLOCK_RSA_2048_SHA256 structure. */ u8 cert_data[]; -}; +} __packed; + /* * When the attribute EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS is set, * then the Data buffer shall begin with an instance of a complete (and @@ -246,6 +248,6 @@ struct efi_variable_authentication_2 { * Only a CertType of EFI_CERT_TYPE_PKCS7_GUID is accepted. */ struct win_certificate_uefi_guid auth_info; -}; +} __packed; #endif -- cgit v1.1