From 17f8cda505e344381cb3c52f6e15b65dbe5be6d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Thu, 15 Jul 2021 15:31:42 +0200 Subject: [PATCH] efi_loader: set partition GUID in device path for SIG_TYPE_GUID MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Previously, the GPT device GUID was being used instead of the partition, which was incorrect. Signed-off-by: Alfonso Sánchez-Beato Let EFI_LOADER select CONFIG_PARTITION_UUIDS. Use log_warning() instead of printf() for warning. Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/Kconfig | 1 + lib/efi_loader/efi_device_path.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 156b391521..a135d2f709 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -12,6 +12,7 @@ config EFI_LOADER depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 select LIB_UUID + select PARTITION_UUIDS select HAVE_BLOCK_DEVICE select REGEX imply CFB_CONSOLE_ANSI diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 76c2f82fe6..9c3ac712fe 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -5,6 +5,8 @@ * (C) Copyright 2017 Rob Clark */ +#define LOG_CATEGORY LOGC_EFI + #include #include #include @@ -16,6 +18,7 @@ #include #include #include +#include #include #include /* U16_MAX */ @@ -851,8 +854,11 @@ static void *dp_part_node(void *buf, struct blk_desc *desc, int part) break; case SIG_TYPE_GUID: hddp->signature_type = 2; - memcpy(hddp->partition_signature, &desc->guid_sig, - sizeof(hddp->partition_signature)); + if (uuid_str_to_bin(info.uuid, + hddp->partition_signature, 1)) + log_warning( + "Partition no. %d: invalid guid: %s\n", + part, info.uuid); break; } -- 2.39.5