Skip to contentSkip to conversation

Fix fwpath in efi netboot

PATCH In review Michael Chang 2 participants 2 messages Dec 19, 2016 – Dec 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix fwpath in efi netboot

The path returned by grub_efi_net_config has already been stripped for the directory part extracted from cached bootp packet. We should just return the result to avoild it be stripped again.

It fixed the problem that grub.efi as NBP image always looking for grub.cfg and platform directory in upper folder rather than current one it gets loaded while $prefix is empty. The behavior is inconsistent with other architecture and how we would expect empty $prefix going to be in general.

The only exception to the general rule of empty $prefix is that when loaded from platform directory itself, the platform part is stripped thus upper folder is used for looking up files. It meets the case for how grub-mknetdir lay out the files under tftp root directory, but also hide away this issue to be identified as it appears to be just works.

---
 grub-core/kern/efi/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
grub-core/kern/efi/init.c +4 -1
index e9c85de..dfa35a2 100644
@@ -61,7 +61,10 @@ grub_machine_get_bootlocation (char **device, char **path)
   *device = grub_efidisk_get_device_name (image->device_handle);
   *path = grub_efi_get_filename (image->file_path);
   if (!*device && grub_efi_net_config)
-    grub_efi_net_config (image->device_handle, device, path);
+    {
+      grub_efi_net_config (image->device_handle, device, path);
+      return;
+    }
 
   if (*path)
     {
Signature · 1 line
2.6.6
#1 lore raw

19.12.2016 12:09, Michael Chang пишет:

Quoted 9 lines

The path returned by grub_efi_net_config has already been stripped for the directory part extracted from cached bootp packet. We should just return the result to avoild it be stripped again.

It fixed the problem that grub.efi as NBP image always looking for grub.cfg and platform directory in upper folder rather than current one it gets loaded while $prefix is empty. The behavior is inconsistent with other architecture and how we would expect empty $prefix going to be in general.

Quoted 5 lines

The only exception to the general rule of empty $prefix is that when loaded from platform directory itself, the platform part is stripped thus upper folder is used for looking up files. It meets the case for how grub-mknetdir lay out the files under tftp root directory, but also hide away this issue to be identified as it appears to be just works.

Thanks! Committed with additional fix - move *path assignment after grub_efi_net_config. We may receive file_path from firmware (e.g. iPXE ROM does set it) and we leaked it this way.

Actually, iPXE ROMs, at least those shipped with Ubuntu 16.04, break grub2 netboot in interesting way, by passing "wrong" handle to image - the one for base interface instead of the child that has PXE protocol. It took me quite some time to understand why I cannot netboot anymore ...

Quoted 21 lines
---
 grub-core/kern/efi/init.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
grub-core/kern/efi/init.c +4 -1
index e9c85de..dfa35a2 100644
@@ -61,7 +61,10 @@ grub_machine_get_bootlocation (char **device, char **path)
   *device = grub_efidisk_get_device_name (image->device_handle);
   *path = grub_efi_get_filename (image->file_path);
   if (!*device && grub_efi_net_config)
-    grub_efi_net_config (image->device_handle, device, path);
+    {
+      grub_efi_net_config (image->device_handle, device, path);
+      return;
+    }
 
   if (*path)
     {