From: Lennart Poettering Date: Fri, 29 Sep 2023 16:55:31 +0000 (+0200) Subject: pe-binary: actually check if PE binary is UEFI binary when determining if UKI X-Git-Tag: v255-rc1~382 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef2dbc9c40ee225aed426b82bf33f2bd31536dba;p=thirdparty%2Fsystemd.git pe-binary: actually check if PE binary is UEFI binary when determining if UKI If it's not a UEFI binary, then it's not a UKI. --- diff --git a/src/shared/pe-binary.c b/src/shared/pe-binary.c index 6a6b8adb86f..4c05323d951 100644 --- a/src/shared/pe-binary.c +++ b/src/shared/pe-binary.c @@ -231,6 +231,9 @@ bool pe_is_uki(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections) assert(pe_header); assert(sections || le16toh(pe_header->pe.NumberOfSections) == 0); + if (le16toh(pe_header->optional.Subsystem) != IMAGE_SUBSYSTEM_EFI_APPLICATION) + return false; + return pe_header_find_section(pe_header, sections, ".osrel") && pe_header_find_section(pe_header, sections, ".linux") && diff --git a/src/shared/pe-binary.h b/src/shared/pe-binary.h index 758bb1de83e..2ef44d7e492 100644 --- a/src/shared/pe-binary.h +++ b/src/shared/pe-binary.h @@ -123,6 +123,8 @@ typedef struct _packed_ _IMAGE_SECTION_HEADER { le32_t Characteristics; } IMAGE_SECTION_HEADER; +#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 + bool pe_header_is_64bit(const PeHeader *h); #define PE_HEADER_OPTIONAL_FIELD(h, field) \