Skip to contentSkip to conversation

efi_loader: check device path in InstallMultipleProtocolInterfaces

PATCH New Heinrich Schuchardt 2 participants 2 messages May 16, 2019 – May 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi_loader: check device path in InstallMultipleProtocolInterfaces

According to the UEFI spec InstallMultipleProtocolInterfaces() must check if a device path has already been installed. In this case it must return EFI_ALREADY_STARTED.

Cf. UEFI SCT II 2.6 A (2017),
3.3.16 InstallMultipleProtocolInterfaces(), 5.1.3.16.1.

---
 lib/efi_loader/efi_boottime.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/efi_loader/efi_boottime.c +12 -0
index ec6f5758de..d3f21f15b7 100644
@@ -2334,6 +2334,7 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
 	efi_va_list argptr;
 	const efi_guid_t *protocol;
 	void *protocol_interface;
+	efi_handle_t old_handle;
 	efi_status_t r = EFI_SUCCESS;
 	int i = 0;
 
@@ -2346,6 +2347,17 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
 		if (!protocol)
 			break;
 		protocol_interface = efi_va_arg(argptr, void*);
+		/* Check that a device path has not been installed before */
+		if (!guidcmp(protocol, &efi_guid_device_path)) {
+			struct efi_device_path *dp = protocol_interface;
+
+			r = EFI_CALL(efi_locate_device_path(protocol, &dp,
+							    &old_handle));
+			if (r == EFI_SUCCESS) {
+				r = EFI_ALREADY_STARTED;
+				break;
+			}
+		}
 		r = EFI_CALL(efi_install_protocol_interface(
 						handle, protocol,
 						EFI_NATIVE_INTERFACE,

--
2.20.1

#1 lore raw

PATCH 1/1 efi_loader: check device path in InstallMultipleProtocolInterfaces

Quoted 8 lines · Heinrich Schuchardt

According to the UEFI spec InstallMultipleProtocolInterfaces() must check if a device path has already been installed. In this case it must return EFI_ALREADY_STARTED.

Cf. UEFI SCT II 2.6 A (2017),
3.3.16 InstallMultipleProtocolInterfaces(), 5.1.3.16.1.

This patch causes iPXE to fail. It hangs when executing the iPXE dhcp command. Some nice debugging ahead.

Best regards

Heinrich

Quoted 36 lines
---
 lib/efi_loader/efi_boottime.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
lib/efi_loader/efi_boottime.c +12 -1
index ec6f5758de..d3f21f15b7 100644
@@ -2334,6 +2334,7 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
 	efi_va_list argptr;
 	const efi_guid_t *protocol;
 	void *protocol_interface;
+	efi_handle_t old_handle;
 	efi_status_t r = EFI_SUCCESS;
 	int i = 0;
 
@@ -2346,6 +2347,17 @@ efi_status_t EFIAPI efi_install_multiple_protocol_interfaces
 		if (!protocol)
 			break;
 		protocol_interface = efi_va_arg(argptr, void*);
+		/* Check that a device path has not been installed before */
+		if (!guidcmp(protocol, &efi_guid_device_path)) {
+			struct efi_device_path *dp = protocol_interface;
+
+			r = EFI_CALL(efi_locate_device_path(protocol, &dp,
+							    &old_handle));
+			if (r == EFI_SUCCESS) {
+				r = EFI_ALREADY_STARTED;
+				break;
+			}
+		}
 		r = EFI_CALL(efi_install_protocol_interface(
 						handle, protocol,
 						EFI_NATIVE_INTERFACE,
--

2.20.1