Skip to content

RFC Wrap font files into PE files

Zhang Boyang grub-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4util/grub-wrap: New tool to wrap a file as a PE image.gitignore Makefile.util.def docs/man/grub-wrap.h2m +6 more+341 -960 replies
2/4kern/unwrap: File filter to unwrap files wrapped by grub-wrapgrub-core/Makefile.core.def grub-core/kern/main.c grub-core/kern/unwrap.c +3 more+293 -00 replies
3/4kern/efi/sb: Set requirements for PE imagesgrub-core/kern/efi/sb.c+35 -20 replies
4/4kern/efi/sb: Use shim to verify font filesgrub-core/kern/efi/sb.c+9 -04 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] Wrap font files into PE files

Hi,

This patchset introduces a utility: grub-wrap. It can wrap a non-PE file as a PE file, which can be subsequently digitally signed (and verified by shim). The wrapped file will be unwrapped at runtime automatically and transparently by the unwrap filter.

With grub-wrap, a PF2 font file can be wrapped and digitally signed. The name of PE section must be .GRUBpf2, to clearly identifies such PE file is a wrapper of a PF2 font file.

Example usage:

# generate a MOK key for signing
pesign --certficate 'MyKey' --export-cert MyKey.crt
# import the new MOK key
mokutil --import MyKey.crt 
reboot
# wrap unicode.pf2 as unicode.pf2.dll
grub-wrap --input unicode.pf2 --output unicode.pf2.dll --name .GRUBpf2 -O x86_64-efi
# sign the wrapper with MOK key
pesign --in unicode.pf2.dll --out /boot/grub/fonts/unicode.pf2 --force --certficate 'MyKey' --sign

There is one problem: those wrappers mustn't be accepted by other PE loaders. To distinguish these wrappers from normal EFI applications, I decided to make these wrappers looks like plain Windows resource-only DLLs (no entry point, and subsystem tag is set to Windows GUI instead of EFI Application). Currently, shim, tianocore, and my patched GRUB will reject these wrappers while trying to use them as executables. However, I'm not sure whether in-market UEFI firmwares will reject them. So I think the best workaround is to forbid keys available in firmware from signing these wrappers, and only use keys in shim to sign wrappers (this seems like exactly what we are doing for GRUB itself).

Best Regards,
Zhang Boyang