From 30a231dcce0b4daf6102cffcdc5c81db8ddaaa48 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 23 Feb 2019 11:20:23 +0100 Subject: [PATCH 1/4] efi_loader: do not add \ in efi_fs_from_name() In the `efidebug boot add` command we do not want an unsolicited leading backslash added to the file name. There is no good reason to mark a loaded file with a backslash as absolute. Anyway when reading files the file name will be interpreted as relative to root directory of the device. So let's get rid of this backslash. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_device_path.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 98c36e798f..53b40c8c3c 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -985,12 +985,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, if (!path) return EFI_SUCCESS; - if (!is_net) { - /* Add leading / to fs paths, because they're absolute */ - snprintf(filename, sizeof(filename), "/%s", path); - } else { - snprintf(filename, sizeof(filename), "%s", path); - } + snprintf(filename, sizeof(filename), "%s", path); /* DOS style file path: */ s = filename; while ((s = strchr(s, '/'))) From fdef298338e4e775d41ab77b25edb695b2d8e1c0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Feb 2019 23:07:00 +0100 Subject: [PATCH 2/4] efi_loader: HII protocols: fix new_package_list() In new_package_list() we call new_packagelist() to create a new package list. Next we try to add the packages which fails for form packages. Due to this error we call free_packagelist(). Now in free_packagelist() list_del() is called for an uninitialized field hii->link. This leads to changing random memory addresses. To solve the problem move the initialization of hii->link to new_packagelist(). Signed-off-by: Heinrich Schuchardt Reviewed-by: AKASHI Takahiro --- lib/efi_loader/efi_hii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index d63d2d8418..0ed4b19633 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -343,6 +343,7 @@ static struct efi_hii_packagelist *new_packagelist(void) struct efi_hii_packagelist *hii; hii = malloc(sizeof(*hii)); + list_add_tail(&hii->link, &efi_package_lists); hii->max_string_id = 0; INIT_LIST_HEAD(&hii->string_tables); INIT_LIST_HEAD(&hii->guid_list); @@ -465,7 +466,6 @@ new_package_list(const struct efi_hii_database_protocol *this, } hii->driver_handle = driver_handle; - list_add_tail(&hii->link, &efi_package_lists); *handle = hii; return EFI_EXIT(EFI_SUCCESS); From 1fa442ed4330a7c489479a3e3c333239ca6441ec Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Feb 2019 20:41:58 +0100 Subject: [PATCH 3/4] efi_loader: error handling for `efidebug boot add` In `efidebug boot add iPXE scsi 0:1 snp-arm64.efi --foo` a parameter is missing. Hence the command should not silently return as if everything were ok but should display the usage info. Signed-off-by: Heinrich Schuchardt Reviewed-by: Alexander Graf --- cmd/efidebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 5072a7b39b..db96682c5a 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -491,7 +491,7 @@ static int do_efi_boot_add(cmd_tbl_t *cmdtp, int flag, id = (int)simple_strtoul(argv[1], &endp, 16); if (*endp != '\0' || id > 0xffff) - return CMD_RET_FAILURE; + return CMD_RET_USAGE; sprintf(var_name, "Boot%04X", id); p = var_name16; From 1a9fce50393d2e7b7c3adb70764ab22a9267d815 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Feb 2019 23:56:35 +0100 Subject: [PATCH 4/4] efi_loader: HII protocols: debug messages When package types are not supported by our implementation of the HII database protocol supported error messages are displayed. Essentially the output is only needed for debugging. By using EFI_PRINT() the messages are only written for in debug mode and with correct indentation. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_hii.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index 0ed4b19633..3a966fa4df 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -388,7 +388,7 @@ add_packages(struct efi_hii_packagelist *hii, (struct efi_hii_guid_package *)package); break; case EFI_HII_PACKAGE_FORMS: - printf("\tForm package not supported\n"); + EFI_PRINT("Form package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_STRINGS: @@ -396,19 +396,19 @@ add_packages(struct efi_hii_packagelist *hii, (struct efi_hii_strings_package *)package); break; case EFI_HII_PACKAGE_FONTS: - printf("\tFont package not supported\n"); + EFI_PRINT("Font package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_IMAGES: - printf("\tImage package not supported\n"); + EFI_PRINT("Image package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_SIMPLE_FONTS: - printf("\tSimple font package not supported\n"); + EFI_PRINT("Simple font package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_DEVICE_PATH: - printf("\tDevice path package not supported\n"); + EFI_PRINT("Device path package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_KEYBOARD_LAYOUT: @@ -416,7 +416,7 @@ add_packages(struct efi_hii_packagelist *hii, (struct efi_hii_keyboard_package *)package); break; case EFI_HII_PACKAGE_ANIMATIONS: - printf("\tAnimation package not supported\n"); + EFI_PRINT("Animation package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_END: @@ -522,33 +522,33 @@ update_package_list(const struct efi_hii_database_protocol *this, remove_guid_package(hii); break; case EFI_HII_PACKAGE_FORMS: - printf("\tForm package not supported\n"); + EFI_PRINT("Form package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_STRINGS: remove_strings_package(hii); break; case EFI_HII_PACKAGE_FONTS: - printf("\tFont package not supported\n"); + EFI_PRINT("Font package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_IMAGES: - printf("\tImage package not supported\n"); + EFI_PRINT("Image package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_SIMPLE_FONTS: - printf("\tSimple font package not supported\n"); + EFI_PRINT("Simple font package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_DEVICE_PATH: - printf("\tDevice path package not supported\n"); + EFI_PRINT("Device path package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_KEYBOARD_LAYOUT: remove_keyboard_package(hii); break; case EFI_HII_PACKAGE_ANIMATIONS: - printf("\tAnimation package not supported\n"); + EFI_PRINT("Animation package not supported\n"); ret = EFI_INVALID_PARAMETER; break; case EFI_HII_PACKAGE_END: @@ -609,7 +609,7 @@ list_package_lists(const struct efi_hii_database_protocol *this, break; continue; case EFI_HII_PACKAGE_FORMS: - printf("\tForm package not supported\n"); + EFI_PRINT("Form package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_STRINGS: @@ -617,19 +617,19 @@ list_package_lists(const struct efi_hii_database_protocol *this, break; continue; case EFI_HII_PACKAGE_FONTS: - printf("\tFont package not supported\n"); + EFI_PRINT("Font package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_IMAGES: - printf("\tImage package not supported\n"); + EFI_PRINT("Image package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_SIMPLE_FONTS: - printf("\tSimple font package not supported\n"); + EFI_PRINT("Simple font package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_DEVICE_PATH: - printf("\tDevice path package not supported\n"); + EFI_PRINT("Device path package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_KEYBOARD_LAYOUT: @@ -637,7 +637,7 @@ list_package_lists(const struct efi_hii_database_protocol *this, break; continue; case EFI_HII_PACKAGE_ANIMATIONS: - printf("\tAnimation package not supported\n"); + EFI_PRINT("Animation package not supported\n"); ret = EFI_INVALID_PARAMETER; continue; case EFI_HII_PACKAGE_END: