efi/linux: set the loaded image device path when it is missing
authorMate Kukri <mate.kukri@canonical.com>
Tue, 23 Jun 2026 14:19:15 +0000 (15:19 +0100)
committerMate Kukri <mate.kukri@canonical.com>
Tue, 23 Jun 2026 15:04:12 +0000 (16:04 +0100)
commit2d65decb22cf1b720e222c13cd43eeaeb7998b09
tree8455ae201835b07cee49169995fa606a3899f5c7
parente064a6c935d58e7f1caac84db48f37e91e19afab
efi/linux: set the loaded image device path when it is missing

Under Secure Boot grub verifies the kernel in its verifier framework
(grub-core/kern/efi/sb.c). The verifier loads it through the shim image loader
protocol, passing only the image buffer and a NULL device path, because the
device path is not available at that point. The verified image handle, which
linux reuses, is therefore left with no device path: both
loaded_image->file_path and the LOADED_IMAGE_DEVICE_PATH protocol are NULL.

This is a consequence of grub loading the image inside the verifier, separate
from where the device path is built. The kernel should see the same memory
mapped path it would get from a normal load.

A memory mapped device path is already built for grub_efi_load_image(). Also
point loaded_image->file_path and the LOADED_IMAGE_DEVICE_PATH protocol at it.
The image's loader owns those fields and frees them with the EFI pool
allocator, so save the originals and restore them before unloading the image if
it returns.

Signed-off-by: Mate Kukri <mate.kukri@canonical.com>
Gbp-Pq: Topic upstream
Gbp-Pq: Name efi-linux-set-loaded-image-device-path.patch
grub-core/loader/efi/linux.c