Skip to content

Commit

Permalink
boot: skip loading DTBs in type 1 when secure boot is enabled
Browse files Browse the repository at this point in the history
The kernel loads the DTB from EFI before ExitBootServices():

https://github.com/torvalds/linux/blob/v6.5/drivers/firmware/efi/libstub/fdt.c#L245

DTBs can map and assign arbitrary memory ranges. The kernel refuses
to load one from the dtb= kernel command line parameter when secure
boot is enabled, as it's not safe. Let's do the same for type 1
entries, as they are unverified.

This only affects arm64 and riscv64, firmwares do not support DTB
on x86.

(cherry picked from commit 4b4d612)
  • Loading branch information
bluca committed Sep 19, 2023
1 parent 8deca02 commit c1404ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/boot/efi/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,7 +2373,9 @@ static EFI_STATUS image_start(
if (err != EFI_SUCCESS)
return log_error_status(err, "Error loading %ls: %m", entry->loader);

if (entry->devicetree) {
/* DTBs are loaded by the kernel before ExitBootServices, and they can be used to map and assign
* arbitrary memory ranges, so skip it when secure boot is enabled as the DTB here is unverified. */
if (entry->devicetree && !secure_boot_enabled()) {
err = devicetree_install(&dtstate, image_root, entry->devicetree);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error loading %ls: %m", entry->devicetree);
Expand Down

0 comments on commit c1404ff

Please sign in to comment.