rhboot / shim

UEFI shim loader
Other
869 stars 293 forks source link

Add support for a LoadOpt Hive #678

Open hughsie opened 3 months ago

hughsie commented 3 months ago

Right now we can only store a UCS2-LE path in the loadopt data for Shim to consume. We now also need to provide that, and a way for customers to add and remove options for kernel command line if we want to remove grub with a 1st stage switchroot/kexec-able kernel like shim.

The other problem is that real-world broken firmware sometimes pads or offsets the loadopt data meaning that we can’t parse strings reliably. We should also make sure that the data inside the hive has not been corrupted, but do not need to cryptographically sign it.

We could create a hive, similar to the BCD hive found in Windows, that includes an extensible and robust key value store:

struct ShimHive {
    magic: [u8; 4],      // “HIVE”
    header_version: u8,  // 0x01
    items_count: u8,     // number of items to parse
    items_offset: u8,    // for forwards and backwards compatibility
    crc32: u32,          // of the entire hive (excluding padding)
    items: [ShimHiveItems; items_count]
}
struct ShimHiveItem {
    key_length: u8,
    value_length: u32,
    // key string, no trailing NUL
    // value string, no trailing NUL
}
hughsie commented 2 months ago

@vathpela what did you call the key for the path? i.e. the UCS-2 thing we store already? i.e. Path, PATH etc?

vathpela commented 2 months ago

path and cmdline are the two I've got defined so far.