Repository navigation
efi: error when the requested bootloader has no component - #1144
Conversation
|
Hi @LorbusChris. Thanks for your PR. I'm waiting for a coreos member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
Adds validation preventing EFI installation when the requested bootloader component is missing.
Changes:
- Validates the requested EFI bootloader component.
- Improves missing-component diagnostics.
- Adds Systemd bootloader discovery tests.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
get_efi_component_from_usr filters out components belonging to *other* bootloaders, but components belonging to no bootloader are never removed -- notably shim, which appears in no bootloader's to_remove set. A non-empty result therefore does not mean the requested bootloader was found. So with --bootloader systemd against an image whose systemd-boot payload is absent, or laid out somewhere other than <name>/<version>/EFI, discovery returns just [shim], install copies shim to the ESP, and the command reports success. The machine is left with a first stage and nothing behind it, and nothing in the output says so. That is not hypothetical. Fedora's systemd-boot package installs its binary at usr/lib/efi/systemd-boot/<evr>/grubx64.efi, one level above the EFI directory the walker matches on, so it is invisible today: https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4 Check explicitly that a component providing the requested bootloader survived the filter, and name the components that were found when it did not, so that a package shipping its payload at the wrong path is distinguishable from one shipping no payload at all. Discovering nothing at all is now also an error for a filtered request, where before it returned None. Only unfiltered discovery keeps that: None is how the caller learns the new layout is not in use and falls back to the legacy update directory, and that directory is copied wholesale with no way to honour a bootloader selection -- so reaching it with a request for one silently installs whatever it happens to contain. Assisted-by: AI
993818c to
c64357b
Compare
|
Could I get an ok-to-test on this? |
|
Hi @LorbusChris sorry about being slow to review this. WDYT about bootc-dev/bootc#2265 ? |
|
/ok-to-test |
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path. With Secure Boot enabled such an install does not boot unless the signing key is enrolled in db, and it also loses the shim-based path fwupd expects to find. bootupd already solves this for the other bootloaders: it installs shim alongside whichever bootloader is selected, since shim belongs to no bootloader and so is never filtered out, and distributions ship systemd-boot under the second-stage filename baked into shim. Routing Systemd through the same path Grub and GrubCC already take therefore yields shim + systemd-boot with no bootc-side special casing. Gate this on the image actually shipping bootupd, and on that bootupd understanding --bootloader, so images without it keep today's bare-bootctl behaviour rather than silently changing what lands on the ESP. A bootupd that is present but cannot even be probed is an error, as it already is on the GRUB path. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so write_autoenroll_keys is called on this path too. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's own signer would leave shim unverifiable, and systemd-boot enrolls a key set named `auto` on its own in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn rather than refuse. The remaining differences against `bootctl install` are loader/random-seed and loader/entries.srel, which bootupd does not write; neither is needed to boot. bootupd is trusted to find systemd-boot in the image. Releases up to 0.3.2 install shim alone and report success when the payload is not laid out as usr/lib/efi/<name>/<version>/EFI, which is how Fedora shipped it until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4 (merged for rawhide and fast-forwarded to F45); coreos/bootupd#1144 turns that into an error. Until both have landed, an image with bootupd and such a systemd-boot package goes from a shim-less systemd-boot install to a shim-only ESP with this change. Note this path is not exercised by CI: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so supports_bootupd() is false there and the fallback is taken. Compile- and unit-tested only; not boot-tested. Generated-by: AI
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path. With Secure Boot enabled such an install does not boot unless the signing key is enrolled in db, and it also loses the shim-based path fwupd expects to find. bootupd already solves this for the other bootloaders: it installs shim alongside whichever bootloader is selected, since shim belongs to no bootloader and so is never filtered out, and distributions ship systemd-boot under the second-stage filename baked into shim. Routing Systemd through the same path Grub and GrubCC already take therefore yields shim + systemd-boot with no bootc-side special casing. Gate this on the image actually shipping bootupd, and on that bootupd understanding --bootloader, so images without it keep today's bare-bootctl behaviour rather than silently changing what lands on the ESP. A bootupd that is present but cannot even be probed is an error, as it already is on the GRUB path. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so write_autoenroll_keys is called on this path too. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's own signer would leave shim unverifiable, and systemd-boot enrolls a key set named `auto` on its own in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn rather than refuse. The remaining differences against `bootctl install` are loader/random-seed and loader/entries.srel, which bootupd does not write; neither is needed to boot. bootupd is trusted to find systemd-boot in the image. Releases up to 0.3.2 install shim alone and report success when the payload is not laid out as usr/lib/efi/<name>/<version>/EFI, which is how Fedora shipped it until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4 (merged for rawhide and fast-forwarded to F45); coreos/bootupd#1144 turns that into an error. Until both have landed, an image with bootupd and such a systemd-boot package goes from a shim-less systemd-boot install to a shim-only ESP with this change. Note this path is not exercised by CI: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so supports_bootupd() is false there and the fallback is taken. Compile- and unit-tested only; not boot-tested. Generated-by: AI
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path. With Secure Boot enabled such an install does not boot unless the signing key is enrolled in db, and it also loses the shim-based path fwupd expects to find. bootupd already solves this for the other bootloaders: it installs shim alongside whichever bootloader is selected, since shim belongs to no bootloader and so is never filtered out, and distributions ship systemd-boot under the second-stage filename baked into shim. Routing Systemd through the same path Grub and GrubCC already take therefore yields shim + systemd-boot with no bootc-side special casing. Gate this on the image actually shipping bootupd, and on that bootupd understanding --bootloader, so images without it keep today's bare-bootctl behaviour rather than silently changing what lands on the ESP. A bootupd that is present but cannot even be probed is an error, as it already is on the GRUB path. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so write_autoenroll_keys is called on this path too. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's own signer would leave shim unverifiable, and systemd-boot enrolls a key set named `auto` on its own in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn rather than refuse. The remaining differences against `bootctl install` are loader/random-seed and loader/entries.srel, which bootupd does not write; neither is needed to boot. bootupd is trusted to find systemd-boot in the image. Releases up to 0.3.2 install shim alone and report success when the payload is not laid out as usr/lib/efi/<name>/<version>/EFI, which is how Fedora shipped it until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4 (merged for rawhide and fast-forwarded to F45); coreos/bootupd#1144 turns that into an error. Until both have landed, an image with bootupd and such a systemd-boot package goes from a shim-less systemd-boot install to a shim-only ESP with this change. Note this path is not exercised by CI: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so supports_bootupd() is false there and the fallback is taken. Compile- and unit-tested only; not boot-tested. Generated-by: AI Signed-off-by: Christian Glombek <[email protected]>
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path. With Secure Boot enabled such an install does not boot unless the signing key is enrolled in db, and it also loses the shim-based path fwupd expects to find. bootupd already solves this for the other bootloaders: it installs shim alongside whichever bootloader is selected, since shim belongs to no bootloader and so is never filtered out, and distributions ship systemd-boot under the second-stage filename baked into shim. Routing Systemd through the same path Grub and GrubCC already take therefore yields shim + systemd-boot with no bootc-side special casing. Do that only when choose_install_method, from the previous commit, finds that the image's bootupd can be asked for systemd-boot (0.2.36 or newer) and that its update metadata lists a systemd-boot component. Otherwise keep today's bare `bootctl install`, and say that shim is left out, rather than silently changing what lands on the ESP. The metadata check matters because a systemd-boot package laid out where bootupd does not look is invisible to it (Fedora shipped it that way until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4, merged for rawhide and fast-forwarded to F45), and bootupd up to 0.3.2 then installs shim alone and reports success; coreos/bootupd#1144 makes that an error on bootupd's side. A bootupd that is present but cannot even be probed is an error, as it already is on the GRUB path. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so write_autoenroll_keys is called on this path too. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's own signer would leave shim unverifiable, and systemd-boot enrolls a key set named `auto` on its own in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn rather than refuse. The remaining differences against `bootctl install` are loader/random-seed and loader/entries.srel, which bootupd does not write; neither is needed to boot. Note this path is not exercised by the pre-existing CI legs: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so the image ships no bootupd and the bootctl path is taken. A later commit adds a leg for it. Generated-by: AI Signed-off-by: Christian Glombek <[email protected]>
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path. With Secure Boot enabled such an install does not boot unless the signing key is enrolled in db, and it also loses the shim-based path fwupd expects to find. bootupd already solves this for the other bootloaders: it installs shim alongside whichever bootloader is selected, since shim belongs to no bootloader and so is never filtered out, and distributions ship systemd-boot under the second-stage filename baked into shim. Routing Systemd through the same path Grub and GrubCC already take therefore yields shim + systemd-boot with no bootc-side special casing. Do that only when choose_install_method, from the previous commit, finds that the image's bootupd can be asked for systemd-boot (0.2.36 or newer) and that its update metadata lists a systemd-boot component. Otherwise keep today's bare `bootctl install`, and say that shim is left out, rather than silently changing what lands on the ESP. The metadata check matters because a systemd-boot package laid out where bootupd does not look is invisible to it (Fedora shipped it that way until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4, merged for rawhide and fast-forwarded to F45), and bootupd up to 0.3.2 then installs shim alone and reports success; coreos/bootupd#1144 makes that an error on bootupd's side. A bootupd that is present but cannot even be probed is an error, as it already is on the GRUB path. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so write_autoenroll_keys is called on this path too. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's own signer would leave shim unverifiable, and systemd-boot enrolls a key set named `auto` on its own in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn rather than refuse. The remaining differences against `bootctl install` are loader/random-seed and loader/entries.srel, which bootupd does not write; neither is needed to boot. Note this path is not exercised by the pre-existing CI legs: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so the image ships no bootupd and the bootctl path is taken. A later commit adds a leg for it. Generated-by: AI Signed-off-by: Christian Glombek <[email protected]>
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path, even when the image ships bootupd and shim. Such an install boots under Secure Boot only if the firmware's db trusts systemd-boot's signer, and it loses the shim that fwupd chains its UEFI capsule updates through. bootupd installs shim alongside whichever bootloader it is asked for, and Fedora ships systemd-boot under the second-stage name baked into shim (systemd-boot-x64 since 262), so routing Systemd through the path GRUB already takes yields shim + systemd-boot with no bootc-side special casing. Shim then lets systemd-boot boot with the firmware's stock keys, provided shim trusts systemd-boot's signer. Fedora's shim does not yet: Fedora signs systemd-boot only with its 2025 CA, while its shim embeds the 2020 CA (rhbz#2268695), so for now that certificate has to be enrolled as a MOK; the docs show how. Take that route only when the decision from the previous commit finds that the image's bootupd accepts --bootloader systemd and its update metadata lists a systemd-boot component, and the target has a single ESP; otherwise keep today's bare `bootctl install` and say that shim is left out, rather than silently changing what lands on the ESP. The metadata check matters because a systemd-boot package laid out where bootupd does not look is invisible to it (Fedora shipped it that way until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4), and bootupd up to 0.3.2 then installs shim alone and reports success; coreos/bootupd#1144, still open, would make that an error on bootupd's side. Several ESPs stay with bootctl because bootupd installs on every ESP and points the firmware at the last one, while bootc writes the entries systemd-boot reads to the first one only. Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so the keys from usr/lib/bootc/install/secureboot-keys are staged on this path too. They are read before bootupd runs, so a malformed key directory still fails the install before anything is written. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's signer leaves shim unverifiable, and systemd-boot enrolls a key set named `auto` by itself in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn visibly rather than refuse, and say so in bootc-install(8). Other differences from `bootctl install`: bootupd writes no loader/random-seed, loader/entries.srel or loader/loader.conf, so UKI installs through bootupd get the 5-second menu timeout bootc writes when loader.conf is missing (UKI through bootupd is untested); and without --generic-image, bootupd replaces the firmware boot entries carrying the OS name with one for shim, where bootctl --root leaves EFI variables alone. Note this path is not exercised by the pre-existing CI legs: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so the bootctl path is taken. A later commit adds a leg for it. Generated-by: AI Signed-off-by: Christian Glombek <[email protected]>
|
Before continuing on with the sd-boot enablement work over in bootc, I'd ideally like to to see this get merged. Maintainers, PTAL. |
|
Thanks @LorbusChris, sorry for the delay |
Bootloader::Systemd fell through to install_systemd_boot(), which runs a plain `bootctl install`. That writes systemd-boot to EFI/BOOT/BOOT<arch>.EFI, so firmware loads it directly and shim is never in the boot path, even when the image ships bootupd and shim. Such an install boots under Secure Boot only if the firmware's db trusts systemd-boot's signer, and it loses the shim that fwupd chains its UEFI capsule updates through. bootupd installs shim alongside whichever bootloader it is asked for, and Fedora ships systemd-boot under the second-stage name baked into shim (systemd-boot-x64 since 262), so routing Systemd through the path GRUB already takes yields shim + systemd-boot with no bootc-side special casing. Shim then lets systemd-boot boot with the firmware's stock keys, provided shim trusts systemd-boot's signer. Fedora's shim does not yet: Fedora signs systemd-boot only with its 2025 CA, while its shim embeds the 2020 CA (rhbz#2268695), so for now that certificate has to be enrolled as a MOK; the docs show how. Take that route only when the decision from the previous commit finds that the image's bootupd accepts --bootloader systemd and can install systemd-boot from the image, and the target has a single ESP; otherwise keep today's bare `bootctl install` and say that shim is left out, rather than silently changing what lands on the ESP. The second check matters because a systemd-boot package laid out where bootupd does not look is invisible to it (Fedora shipped it that way until https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4), and bootupd up to 0.3.2 then installs shim alone and reports success; coreos/bootupd#1144 makes that an error on bootupd's side since 0.4.0. Several ESPs stay with bootctl because bootupd installs on every ESP and points the firmware at the last one, while bootc writes the entries systemd-boot reads only for the first one (on it, or on an XBOOTLDR partition next to it). Secure Boot key enrollment belongs to systemd-boot rather than to whatever installed it, so the keys from usr/lib/bootc/install/secureboot-keys are staged on this path too. They are read before bootupd runs, so a malformed key directory still fails the install before anything is written. Note this makes a new combination reachable: keys staged for an install that boots via shim. Enrolling a db without shim's signer leaves shim unverifiable, and systemd-boot enrolls a key set named `auto` by itself in a VM in setup mode. A db that keeps shim's signer is legitimate though, so warn visibly rather than refuse, and say so in bootc-install(8). Other differences from `bootctl install`: bootupd writes no loader/random-seed, loader/entries.srel or loader/loader.conf, so copy the image's loader.conf onto the ESP after it, as after bootctl, creating loader/ first (UKI through bootupd is untested); and without --generic-image, bootupd replaces the firmware boot entries carrying the OS name with one for shim, where bootctl --root leaves EFI variables alone. Note this path is not exercised by the pre-existing CI legs: contrib/packaging/switch-to-sdboot removes bootupd and shim from every bootloader=systemd test image, so the bootctl path is taken. A later commit adds a leg for it. Generated-by: AI Signed-off-by: Christian Glombek <[email protected]>
get_efi_component_from_usr filters out components belonging to other bootloaders, but components belonging to no bootloader are never removed -- notably shim, which appears in no bootloader's to_remove set. A non-empty result therefore does not mean the requested bootloader was found.
So with --bootloader systemd against an image whose systemd-boot payload is absent, or laid out somewhere other than //EFI, discovery returns just [shim], install copies shim to the ESP, and the command reports success. The machine is left with a first stage and nothing behind it, and nothing in the output says so.
That is not hypothetical. Fedora's systemd-boot package installs its binary at usr/lib/efi/systemd-boot//grubx64.efi, one level above the EFI directory the walker matches on, so it is invisible today:
https://src.fedoraproject.org/rpms/systemd-boot/pull-request/4
The same issue was also reported here: bootc-dev/bootc#2265
Check explicitly that a component providing the requested bootloader survived the filter, and name the components that were found when it did not, so that a package shipping its payload at the wrong path is distinguishable from one shipping no payload at all.
Assisted-by: AI