Rework the code that loads the initrd via LoadFile2 so that it looks for the protocol on the loaded image handle first, and only if it doesn't find it here, on the global singleton device path. This works around reported issues where intermediate loader stages are providing an initrd via this mechanism, and subsequently loading another intermediate boot stage that does the same. Changes since v1: - pass 'end of device path' to LoadFile2() when grabbing the protocol from the loaded image instead of from the initrd global device path - add Ilias's tags Link: https://github.com/systemd/systemd/issues/26723 Cc: Michael Brown <mcb30@xxxxxxxx> Cc: Ilias Apalodimas <ilias.apalodimas@xxxxxxxxxx> Ard Biesheuvel (3): efi/libstub: Use const qualified device path protocol pointers efi/libstub: Pass loaded image EFI handle to efi_load_initrd() efi/libstub: Look for initrd LoadFile2 protocol on image handle drivers/firmware/efi/libstub/efi-stub-helper.c | 56 ++++++++++++-------- drivers/firmware/efi/libstub/efi-stub.c | 4 +- drivers/firmware/efi/libstub/efistub.h | 7 +-- drivers/firmware/efi/libstub/file.c | 2 +- drivers/firmware/efi/libstub/x86-stub.c | 4 +- include/linux/efi.h | 1 + include/linux/pe.h | 2 +- 7 files changed, 46 insertions(+), 30 deletions(-) -- 2.39.2