1From 6807d4b30f7d4ed32d3c54dfcaf3ace63eaa4f02 Mon Sep 17 00:00:00 2001 2From: Emekcan Aras <emekcan.aras@arm.com> 3Date: Thu, 26 Oct 2023 11:46:04 +0100 4Subject: [PATCH] platform: corstone1000: align capsule update structs 5 6U-boot mkefitool creates capsule image without packed and byte-aligned 7structs. This patch aligns the capsule-update structures and avoids 8crashes in case of unaligned pointer access. 9 10Signed-off-by: Emekcan Aras <emekcan.aras@arm.com> 11Upstream-Status: Pending 12--- 13 .../fw_update_agent/uefi_capsule_parser.c | 14 +++++++------- 14 1 file changed, 7 insertions(+), 7 deletions(-) 15 16diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c 17index c706c040ac..9f8d12ad4e 100644 18--- a/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c 19+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/uefi_capsule_parser.c 20@@ -34,14 +34,14 @@ typedef struct { 21 uint32_t header_size; 22 uint32_t flags; 23 uint32_t capsule_image_size; 24-} efi_capsule_header_t; 25+} efi_capsule_header_t __attribute__((packed, aligned(1))); 26 27 typedef struct { 28 uint32_t version; 29 uint16_t embedded_driver_count; 30 uint16_t payload_item_count; 31 uint64_t item_offset_list[]; 32-} efi_firmware_management_capsule_header_t; 33+} efi_firmware_management_capsule_header_t __attribute__((packed, aligned(1))); 34 35 typedef struct { 36 uint32_t version; 37@@ -52,14 +52,14 @@ typedef struct { 38 uint32_t update_vendorcode_size; 39 uint64_t update_hardware_instance; //introduced in v2 40 uint64_t image_capsule_support; //introduced in v3 41-} efi_firmware_management_capsule_image_header_t; 42+} efi_firmware_management_capsule_image_header_t __attribute__((packed, aligned(1))); 43 44 typedef struct { 45 uint32_t signature; 46 uint32_t header_size; 47 uint32_t fw_version; 48 uint32_t lowest_supported_version; 49-} fmp_payload_header_t; 50+} fmp_payload_header_t __attribute__((packed, aligned(1))); 51 52 #define ANYSIZE_ARRAY 0 53 54@@ -68,18 +68,18 @@ typedef struct { 55 uint16_t wRevision; 56 uint16_t wCertificateType; 57 uint8_t bCertificate[ANYSIZE_ARRAY]; 58-} WIN_CERTIFICATE; 59+} WIN_CERTIFICATE __attribute__((packed, aligned(1))); 60 61 typedef struct { 62 WIN_CERTIFICATE hdr; 63 struct efi_guid cert_type; 64 uint8_t cert_data[ANYSIZE_ARRAY]; 65-} win_certificate_uefi_guid_t; 66+} win_certificate_uefi_guid_t __attribute__((packed, aligned(1))); 67 68 typedef struct { 69 uint64_t monotonic_count; 70 win_certificate_uefi_guid_t auth_info; 71-} efi_firmware_image_authentication_t; 72+} efi_firmware_image_authentication_t __attribute__((packed, aligned(1))); 73 74 75 enum uefi_capsule_error_t uefi_capsule_retrieve_images(void* capsule_ptr, 76-- 772.25.1 78 79