Bug 1108507 - grub2 efi boot overwrite device name when boot from cdrom
Summary: grub2 efi boot overwrite device name when boot from cdrom
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: grub2
Version: 20
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Jones
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-12 07:23 UTC by sTeeL
Modified: 2015-06-29 21:04 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-06-29 21:04:43 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
patch and test tool (21.38 KB, application/octet-stream)
2014-06-12 07:23 UTC, sTeeL
no flags Details

Description sTeeL 2014-06-12 07:23:06 UTC
Created attachment 907966 [details]
patch and test tool

Description of problem:

grub2 overwrite device data, when boot from cdrom

Version-Release number of selected component (if applicable):


How reproducible:
very easy

Steps to Reproduce:
1. make a ISO, set grub2(target=x86_64-efi) as bootloader
2. chainloader test program hello.efi (attachment)
3. hello.efi will print bootloader's device_handle, and device name
4. the device name is WRONG

Actual results:
image->DeviceHandle is [Acpi(PNP0A03,0)/Pci(7|1)/Ata(Primary,Master)]

Expected results:
image->DeviceHandle is [Acpi(PNP0A03,0)/Pci(7|1)/Ata(Primary,Master)/CDROM(Entry1)]

Additional info:
it'seems redhat use wrong patch which purpose is to solve buggy cdrom problem,
the name of patch is "0447-Add-support-for-crappy-cd-craparino.patch",
I've write a patch to fix it, see attachment ("0485-sTeeL.patch")

Comment 1 sTeeL 2014-06-12 07:24:20 UTC
From 8c62c84f2b85bebf0a3f5fe588aa19e9d113996a Mon Sep 17 00:00:00 2001
From: sTeeL Mental <steel.mental>
Date: Fri, 21 Jun 2013 14:44:08 -0400
Subject: [PATCH] Fix cd efi boot bug

Signed-off-by: Peter Jones <grub2-owner>
---
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 08c303e..1898c52 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -198,6 +198,8 @@ is_child (struct grub_efidisk_data *child,
 
 #define FOR_CHILDREN(p, dev) for (p = dev; p; p = p->next) if (is_child (p, d))
 
+#define DEBUG_NAMES 1
+
 /* Add a device into a list of devices in an ascending order.  */
 static void
 add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
@@ -799,16 +801,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
   if (! ldp)
     return 0;
 
-  if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE &&
-      (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE))
-    {
-      ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
-      ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
-      ldp->length[0] = 4;
-      ldp->length[1] = 0;
-      ldp = find_last_device_path(dp);
-    }
-
   if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
       && (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp)
 	  == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
@@ -870,7 +862,31 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
 
       return dev_name;
     }
-  else
+  else if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE &&
+      (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE))
+    {
+	  grub_efi_device_path_t *dup_dp, *dup_ldp;
+	  dup_dp = duplicate_device_path (dp);
+
+	  if (! dup_dp)
+		return 0;
+
+	  dup_ldp = find_last_device_path (dup_dp);
+	  dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+	  dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+	  dup_ldp->length[0] = 4;
+	  dup_ldp->length[1] = 0;
+
+	  if (!get_diskname_from_path (dup_dp, device_name))
+	  {
+		grub_free (dup_dp);
+		return 0;
+	  }
+
+	  grub_free (dup_dp);
+	  return grub_strdup (device_name);
+    }
+  else 
     {
       /* This should be an entire disk.  */
       if (!get_diskname_from_path (dp, device_name))

Comment 2 sTeeL 2014-06-12 07:24:55 UTC
From 8c62c84f2b85bebf0a3f5fe588aa19e9d113996a Mon Sep 17 00:00:00 2001
From: sTeeL Mental <steel.mental>
Date: Fri, 21 Jun 2013 14:44:08 -0400
Subject: [PATCH] Fix cd efi boot bug

Signed-off-by: Peter Jones <grub2-owner>
---
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 08c303e..1898c52 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -198,6 +198,8 @@ is_child (struct grub_efidisk_data *child,
 
 #define FOR_CHILDREN(p, dev) for (p = dev; p; p = p->next) if (is_child (p, d))
 
+#define DEBUG_NAMES 1
+
 /* Add a device into a list of devices in an ascending order.  */
 static void
 add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
@@ -799,16 +801,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
   if (! ldp)
     return 0;
 
-  if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE &&
-      (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE))
-    {
-      ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
-      ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
-      ldp->length[0] = 4;
-      ldp->length[1] = 0;
-      ldp = find_last_device_path(dp);
-    }
-
   if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
       && (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp)
 	  == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
@@ -870,7 +862,31 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
 
       return dev_name;
     }
-  else
+  else if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE &&
+      (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE))
+    {
+	  grub_efi_device_path_t *dup_dp, *dup_ldp;
+	  dup_dp = duplicate_device_path (dp);
+
+	  if (! dup_dp)
+		return 0;
+
+	  dup_ldp = find_last_device_path (dup_dp);
+	  dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
+	  dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
+	  dup_ldp->length[0] = 4;
+	  dup_ldp->length[1] = 0;
+
+	  if (!get_diskname_from_path (dup_dp, device_name))
+	  {
+		grub_free (dup_dp);
+		return 0;
+	  }
+
+	  grub_free (dup_dp);
+	  return grub_strdup (device_name);
+    }
+  else 
     {
       /* This should be an entire disk.  */
       if (!get_diskname_from_path (dp, device_name))

Comment 3 Fedora End Of Life 2015-05-29 12:05:30 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2015-06-29 21:04:43 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.