Skip to content

Commit 65fe9f3

Browse files
committed
boot: skip loading DTBs in type 1 when secure boot is enabled
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) (cherry picked from commit c1404ff) (cherry picked from commit 7844c65) (cherry picked from commit f381320) (cherry picked from commit 3c97ff5)
1 parent 53353de commit 65fe9f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/boot/efi/boot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,9 @@ static EFI_STATUS image_start(
21852185
if (EFI_ERROR(err))
21862186
return log_error_status_stall(err, L"Error loading %s: %r", entry->loader, err);
21872187

2188-
if (entry->devicetree) {
2188+
/* DTBs are loaded by the kernel before ExitBootServices, and they can be used to map and assign
2189+
* arbitrary memory ranges, so skip it when secure boot is enabled as the DTB here is unverified. */
2190+
if (entry->devicetree && !secure_boot_enabled()) {
21892191
err = devicetree_install(&dtstate, root_dir, entry->devicetree);
21902192
if (EFI_ERROR(err))
21912193
return log_error_status_stall(err, L"Error loading %s: %r", entry->devicetree, err);

0 commit comments

Comments
 (0)