/** * DOC: efi_secret: Allow reading EFI confidential computing (coco) secret area * via securityfs interface. * * When the module is loaded (and securityfs is mounted, typically under * /sys/kernel/security), a "secrets/coco" directory is created in securityfs. * In it, a file is created for each secret entry. The name of each such file * is the GUID of the secret entry, and its content is the secret data.
*/
/* * Structure of the EFI secret area * * Offset Length * (bytes) (bytes) Usage * ------- ------- ----- * 0 16 Secret table header GUID (must be 1e74f542-71dd-4d66-963e-ef4287ff173b) * 16 4 Length of bytes of the entire secret area * * 20 16 First secret entry's GUID * 36 4 First secret entry's length in bytes (= 16 + 4 + x) * 40 x First secret entry's data * * 40+x 16 Second secret entry's GUID * 56+x 4 Second secret entry's length in bytes (= 16 + 4 + y) * 60+x y Second secret entry's data * * (... and so on for additional entries) * * The GUID of each secret entry designates the usage of the secret data.
*/
/** * struct secret_header - Header of entire secret area; this should be followed * by instances of struct secret_entry. * @guid: Must be EFI_SECRET_TABLE_HEADER_GUID * @len: Length in bytes of entire secret area, including header
*/ struct secret_header {
efi_guid_t guid;
u32 len;
} __attribute((packed));
/** * struct secret_entry - Holds one secret entry * @guid: Secret-specific GUID (or NULL_GUID if this secret entry was deleted) * @len: Length of secret entry, including its guid and len fields * @data: The secret data (full of zeros if this secret entry was deleted)
*/ struct secret_entry {
efi_guid_t guid;
u32 len;
u8 data[];
} __attribute((packed));
/* * Overwrite memory content with zeroes, and ensure that dirty cache lines are * actually written back to memory, to clear out the secret.
*/ staticvoid wipe_memory(void *addr, size_t size)
{
memzero_explicit(addr, size); #ifdef CONFIG_X86
clflush_cache_range(addr, size); #endif
}
ptr = (void __force *)s->secret_data;
h = (struct secret_header *)ptr; if (efi_guidcmp(h->guid, EFI_SECRET_TABLE_HEADER_GUID)) { /* * This is not an error: it just means that EFI defines secret * area but it was not populated by the Guest Owner.
*/
dev_dbg(&dev->dev, "EFI secret area does not start with correct GUID\n"); return -ENODEV;
} if (h->len < sizeof(*h)) {
dev_err(&dev->dev, "EFI secret area reported length is too small\n"); return -EINVAL;
} if (h->len > s->secret_data_len) {
dev_err(&dev->dev, "EFI secret area reported length is too big\n"); return -EINVAL;
}
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.