FS#77874 - [mkinitcpio] UKI sections aren't aligned
Attached to Project:
Arch Linux
Opened by Jan (medhefgo) - Thursday, 16 March 2023, 18:12 GMT
Last edited by Toolybird (Toolybird) - Thursday, 13 April 2023, 06:04 GMT
Opened by Jan (medhefgo) - Thursday, 16 March 2023, 18:12 GMT
Last edited by Toolybird (Toolybird) - Thursday, 13 April 2023, 06:04 GMT
|
Details
mkinitcpio master correctly adds PE sections with a
dynamically calculated offsets, but it fails to align the
offsets to the section alignment header field. Although, EFI
loaders are lenient about this, it is still in violation of
the PE format and future EFI firmware might reject such
images.
Ultimately, it would be better to use systemd-ukify as it does all the things and more, reducing duplication of effort and increasing support for more arches in the process. |
This task depends upon
Closed by Toolybird (Toolybird)
Thursday, 13 April 2023, 06:04 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in Arch GitLab
Thursday, 13 April 2023, 06:04 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in Arch GitLab
[1] https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio
Solution is simple: use ukify or extract alignment and do the math.
Yes we should be using ukify, but mkinitcpio isn't run only on systems with systemd. I'd like to keep a objcopy implementation around so we can support the super-old gummiboot stuff.
https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio/-/issues/171
> "Need to align them to the last byte."
This is just wrong. You have to align to the SectionAlignment as indicated in the PE header (of the stub, not the kernel). The PR hard-codes this value - which it should not (we don't want a repeat of hard-coded offsets).
The ukify output should be taken with a grain of salt: systemd-253 wrongly indicates an alignment of 0x200. Upstream is now correctly indicating 0x1000. Nevertheless, the value should be extracted from the PE header (you can scrape `objdump -p`).