/* * Enable reboot attack mitigation. This requests that the firmware clear the * RAM on next reboot before proceeding with boot, ensuring that any secrets * are cleared. If userland has ensured that all secrets have been removed * from RAM before reboot it can simply reset this variable.
*/ void efi_enable_reset_attack_mitigation(void)
{
u8 val = 1;
efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID;
efi_status_t status; unsignedlong datasize = 0;
status = get_efi_var(efi_MemoryOverWriteRequest_name, &var_guid,
NULL, &datasize, NULL);
/* * We populate the EFI table even if the logs are empty.
*/ if (!log_last_entry) {
log_size = 0;
} else {
last_entry_addr = (unsignedlong) log_last_entry; /* * get_event_log only returns the address of the last entry. * We need to calculate its size to deduce the full size of * the logs. * * CC Event log also uses TCG2 format, handle it same as TPM2.
*/ if (version > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) { /* * The TCG2 log format has variable length entries, * and the information to decode the hash algorithms * back into a size is contained in the first entry - * pass a pointer to the final entry (to calculate its * size) and the first entry (so we know how long each * digest is)
*/
last_entry_size =
__calc_tpm2_event_size((void *)last_entry_addr,
(void *)(long)log_location, false);
} else {
last_entry_size = sizeof(struct tcpa_event) +
((struct tcpa_event *) last_entry_addr)->event_size;
}
log_size = log_last_entry - log_location + last_entry_size;
}
/* Allocate space for the logs and copy them. */
status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY, sizeof(*log_tbl) + log_size, (void **)&log_tbl);
if (status != EFI_SUCCESS) {
efi_err("Unable to allocate memory for event log\n"); return;
}
/* * Figure out whether any events have already been logged to the * final events structure, and if so how much space they take up
*/ if (final_events_table && final_events_table->nr_events) { struct tcg_pcr_event2_head *header;
u32 offset; void *data;
u32 event_size; int i = final_events_table->nr_events;
data = (void *)final_events_table;
offset = sizeof(final_events_table->version) + sizeof(final_events_table->nr_events);
while (i > 0) {
header = data + offset + final_events_size;
event_size = __calc_tpm2_event_size(header,
(void *)(long)log_location, false); /* If calc fails this is a malformed log */ if (!event_size) break;
final_events_size += event_size;
i--;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.