bootctl: calculate secureboot state taking MokSBStateRT into account (#39298)
shim is often used as part of the EFI boot chain with Linux kernels. shim has an option to disable all verification of binaries it loads. This can be performed by end-user using mokutil / mokmanager EFI app, which set BootServices only variable MokSBState. shim honors that, and mirrors it as readonly MokSBStateRT for the post-ExitBootService access. Thus presense of MokSBStateRT is an indicator that shim was used during boot chain. Some OEM vendors are known to set MokSBState variable, without user having done so. When verification is disabled, one should assume secureboot is insecure, because any EFI binary was allowed to run, including but not limited to unsigned or revoked: - grub - systemd-boot - UKI - linux kernel Linux kernel also has code to check this variable, and correctly report that Secure Boot is disabled, see: - https://github.com/torvalds/linux/blob/3a8660878839faadb4f1a6dd72c3179c1df56787/drivers/firmware/efi/libstub/secureboot.c#L57 With this change bootctl output changes like this: ```diff System: Firmware: n/a (n/a) Firmware Arch: x64 - Secure Boot: enabled (user) + Secure Boot: disabled (insecure) TPM2 Support: yes Measured UKI: no Boot into FW: supported ``` This implementation is trying to mimic mokutil behaviour like this one: ``` $ mokutil --sb-state SecureBoot enabled SecureBoot validation is disabled in shim ``` As well as the linux kernel behavior of: ``` $ journalctl -b | grep 'Secure boot disabled' kernel: Secure boot disabled ``` Note that MokSBState is extended into PCR7 as well as also into PCR14. For more details see https://github.com/rhboot/shim/blob/main/README.tpm
This commit is contained in:
@@ -20,7 +20,7 @@ bool secure_boot_enabled(void) {
|
||||
}
|
||||
|
||||
SecureBootMode secure_boot_mode(void) {
|
||||
bool secure, audit = false, deployed = false, setup = false;
|
||||
bool secure, audit = false, deployed = false, setup = false, moksb = false;
|
||||
EFI_STATUS err;
|
||||
|
||||
err = efivar_get_boolean_u8(MAKE_GUID_PTR(EFI_GLOBAL_VARIABLE), u"SecureBoot", &secure);
|
||||
@@ -32,8 +32,9 @@ SecureBootMode secure_boot_mode(void) {
|
||||
(void) efivar_get_boolean_u8(MAKE_GUID_PTR(EFI_GLOBAL_VARIABLE), u"AuditMode", &audit);
|
||||
(void) efivar_get_boolean_u8(MAKE_GUID_PTR(EFI_GLOBAL_VARIABLE), u"DeployedMode", &deployed);
|
||||
(void) efivar_get_boolean_u8(MAKE_GUID_PTR(EFI_GLOBAL_VARIABLE), u"SetupMode", &setup);
|
||||
(void) efivar_get_boolean_u8(MAKE_GUID_PTR(SHIM_LOCK), u"MokSBStateRT", &moksb);
|
||||
|
||||
return decode_secure_boot_mode(secure, audit, deployed, setup);
|
||||
return decode_secure_boot_mode(secure, audit, deployed, setup, moksb);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -30,9 +30,6 @@ struct ShimLock {
|
||||
EFI_STATUS __sysv_abi__ (*read_header) (void *data, uint32_t datasize, void *context);
|
||||
};
|
||||
|
||||
#define SHIM_LOCK_GUID \
|
||||
{ 0x605dab50, 0xe046, 0x4300, { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } }
|
||||
|
||||
#define SHIM_IMAGE_LOADER_GUID \
|
||||
{ 0x1f492041, 0xfadb, 0x4e59, { 0x9e, 0x57, 0x7c, 0xaf, 0xe7, 0x3a, 0x55, 0xab } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user