efi_loader: add PE/COFF image measurement

"TCG PC Client Platform Firmware Profile Specification"
requires to measure every attempt to load and execute
a OS Loader(a UEFI application) into PCR[4].
This commit adds the PE/COFF image measurement, extends PCR,
and appends measurement into Event Log.

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Replace CONFIG_HASH_CALCULATE by CONFIG_HASH
Fix conversions between pointers and u64.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
Masahisa Kojima
2021-05-26 12:09:58 +09:00
committed by Heinrich Schuchardt
parent 464010b0be
commit 163a0d7e2c
6 changed files with 277 additions and 26 deletions

View File

@@ -426,6 +426,10 @@ efi_status_t efi_disk_register(void);
efi_status_t efi_rng_register(void);
/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
efi_status_t efi_tcg2_register(void);
/* measure the pe-coff image, extend PCR and add Event Log */
efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
struct efi_loaded_image_obj *handle,
struct efi_loaded_image *loaded_image_info);
/* Create handles and protocols for the partitions of a block device */
int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
const char *if_typename, int diskid,
@@ -886,6 +890,8 @@ bool efi_secure_boot_enabled(void);
bool efi_capsule_auth_enabled(void);
void *efi_prepare_aligned_image(void *efi, u64 *efi_size);
bool efi_image_parse(void *efi, size_t len, struct efi_image_regions **regp,
WIN_CERTIFICATE **auth, size_t *auth_len);

View File

@@ -9,6 +9,7 @@
#if !defined _EFI_TCG2_PROTOCOL_H_
#define _EFI_TCG2_PROTOCOL_H_
#include <efi_api.h>
#include <tpm-v2.h>
#define EFI_TCG2_PROTOCOL_GUID \
@@ -53,6 +54,14 @@ struct efi_tcg2_event {
u8 event[];
} __packed;
struct uefi_image_load_event {
efi_physical_addr_t image_location_in_memory;
u64 image_length_in_memory;
u64 image_link_time_address;
u64 length_of_device_path;
struct efi_device_path device_path[];
};
struct efi_tcg2_boot_service_capability {
u8 size;
struct efi_tcg2_version structure_version;

View File

@@ -70,6 +70,24 @@ struct udevice;
#define EV_TABLE_OF_DEVICES ((u32)0x0000000B)
#define EV_COMPACT_HASH ((u32)0x0000000C)
/*
* event types, cf.
* "TCG PC Client Platform Firmware Profile Specification", Family "2.0"
* rev 1.04, June 3, 2019
*/
#define EV_EFI_EVENT_BASE ((u32)0x80000000)
#define EV_EFI_VARIABLE_DRIVER_CONFIG ((u32)0x80000001)
#define EV_EFI_VARIABLE_BOOT ((u32)0x80000002)
#define EV_EFI_BOOT_SERVICES_APPLICATION ((u32)0x80000003)
#define EV_EFI_BOOT_SERVICES_DRIVER ((u32)0x80000004)
#define EV_EFI_RUNTIME_SERVICES_DRIVER ((u32)0x80000005)
#define EV_EFI_GPT_EVENT ((u32)0x80000006)
#define EV_EFI_ACTION ((u32)0x80000007)
#define EV_EFI_PLATFORM_FIRMWARE_BLOB ((u32)0x80000008)
#define EV_EFI_HANDOFF_TABLES ((u32)0x80000009)
#define EV_EFI_HCRTM_EVENT ((u32)0x80000010)
#define EV_EFI_VARIABLE_AUTHORITY ((u32)0x800000E0)
/* TPMS_TAGGED_PROPERTY Structure */
struct tpms_tagged_property {
u32 property;