Two common ways to do Secure Boot are:
EFI -> shim -> grub -> kernelEFI -> UKI
I want to keep grub, but discard all third party keys and use my own. One option would be to recompile shim with only my keys, but it seems more straightforward to do a simpler boot chain of EFI -> grub -> UKI.
So far I have:
# Install GRUB with the modules embedded grub-install --target=x86_64-efi --efi-directory=/boot/efi --boot-directory=/boot/efi/boot \ --modules="normal probe part_gpt part_msdos ext2 search fat lvm luks tpm mdraid1x mdraid09 raid5rec raid6rec all_video gzio datetime chain loadenv configfile test linux ls echo cat help" \ --no-floppy --uefi-secure-boot --force-extra-removable --disable-shim-lock # Sign with self-generated and enrolled key cp /boot/efi/boot/grub/x86_64-efi/grub.efi /boot/efi/EFI/BOOT/ cp grub.cfg /boot/efi/EFI/BOOT/grub.cfg sbsign --key MOK.key --cert MOK.crt --output /boot/efi/EFI/BOOT/grub.efi /boot/efi/EFI/BOOT/grub.efi sbsign --key MOK.key --cert MOK.crt --output /boot/efi/EFI/Linux/vmlinuz.efi /boot/efi/EFI/Linux/vmlinuz.efi efibootmgr --create -l '/EFI/BOOT/grub.efi' # grub.cfg chainloader /EFI/Linux/vmlinuz.efi boot This setup boots, but grub does not check the signature of the UKI. It can also probably be convinced to dynamically load unsigned modules.
What do I need to do in grub.cfg to allow proper Secure Boot without shim? Is this even a reasonable thing to do, or must I always use shim to properly populate the PCRs?
chainloadercommand, works with the UEFI secure boot and the shim." So the answer to your question would seem to be "Do not use thechainloadercommand to boot Linux." Also, what purpose does GRUB serve in your desired setup that cannot be handled with just thesystemd-stubwithin the UKI? When booting UKI under Secure Boot, you cannot specify boot options at boot time anyway - only options configured at UKI build time will be used bysystemd-stub.linuxcommand, because in my case there is no shim to "work with". I think the following page is describing how to explicitly check signatures, but I am not sure, and presumably we still have to block dynamic module loading? gnu.org/software/grub/manual/grub/html_node/…load_image()routine to load files, and the Secure Boot signature check is already embedded in it: if the firmware routine finds it's loading an*.efibinary with a valid signature, and it's not blacklisted, the firmware loads it into memory and marks that memory block as execution-enabled; everything else gets marked by the firmware as "not executable" using the processor's memory management unit. The shim hooks into that validation process somehow (too deep magic for me).