Skip to contentSkip to conversation

loader/multiboot: do not add modules before successful download

PATCH In review Valentin Gehrke 2 participants 7 messages Aug 23, 2024 – Oct 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loader/multiboot: do not add modules before successful download

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, an attempt to retry a failed download is futile because the corrupted module will be forwarded either way.

---
 grub-core/loader/multiboot.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
grub-core/loader/multiboot.c +0 -0
index 94be512c4..36b27a906 100644
@@ -420,13 +420,6 @@ grub_cmd_module (grub_command_t cmd __attribute__
((unused)), target = 0;
     }

- err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
- if (err)
- {
- grub_file_close (file);
- return err;
- }
-
if (size && grub_file_read (file, module, size) != size)

     {
       grub_file_close (file);

@@ -437,7 +430,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), }

grub_file_close (file);
- return GRUB_ERR_NONE;
+
+ return GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1); }

static grub_command_t cmd_multiboot, cmd_module;

Signature · 12 lines
2.45.2

---
Valentin Gehrke
Software Engineer
Kernkonzept GmbH at Dresden, Germany,
HRB 31129, CEO Dr.-Ing. Michael Hohmuth

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Valentin Gehrke

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, an attempt to retry a failed download is futile because the corrupted module will be forwarded either way.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#2 lore raw
In reply to Valentin Gehrke
Quoted 10 lines · Valentin Gehrke

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, an attempt to retry a failed download is futile because the corrupted module will be forwarded either way.

Sorry, this patch does not apply to the upstream.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 3 lines

Sorry, this patch does not apply to the upstream.

Daniel

Oops. My bad. There was some unfortunate line wrapping in the diff in the @@ lines caused by my email client. This time it should work. I rebased the commit onto current master, just to be sure.

From: Valentin Gehrke <[email protected]>
Date: Fri, 23 Aug 2024 16:41:23 +0200
Subject: [PATCH] loader/multiboot: do not add modules before successful
download

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, an attempt to retry a failed download is futile because the corrupted module will be forwarded either way.

---
 grub-core/loader/multiboot.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
grub-core/loader/multiboot.c +2 -8
index 94be512c4..36b27a906 100644
@@ -420,13 +420,6 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
       target = 0;
     }
 
-  err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
-  if (err)
-    {
-      grub_file_close (file);
-      return err;
-    }
-
   if (size && grub_file_read (file, module, size) != size)
     {
       grub_file_close (file);
@@ -437,7 +430,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
     }
 
   grub_file_close (file);
-  return GRUB_ERR_NONE;
+
+  return GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
 }
 
 static grub_command_t cmd_multiboot, cmd_module;
Signature · 12 lines
2.46.0

---
Valentin Gehrke
Software Engineer
Kernkonzept GmbH at Dresden, Germany,
HRB 31129, CEO Dr.-Ing. Michael Hohmuth

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#4 lore raw

Hey Daniel,

did you have time yet to give the patch in my last email a try? I just want to make sure the email didn't get overlooked.

Best regards,
Valentin.

Quoted 17 lines · On Tue, 10 Sep 2024 16:10:47 +0200 Valentin Gehrke…
Quoted 3 lines

Sorry, this patch does not apply to the upstream.

Daniel

Oops. My bad. There was some unfortunate line wrapping in the diff in the @@ lines caused by my email client. This time it should work. I rebased the commit onto current master, just to be sure.

From: Valentin Gehrke <[email protected]>
Date: Fri, 23 Aug 2024 16:41:23 +0200
Subject: [PATCH] loader/multiboot: do not add modules before successful download

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

Quoted 6 lines

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, an attempt to retry a failed download is futile because the corrupted module will be forwarded either way.

---
 grub-core/loader/multiboot.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
grub-core/loader/multiboot.c +2 -8
index 94be512c4..36b27a906 100644
@@ -420,13 +420,6 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
       target = 0;
     }
 
-  err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
-  if (err)
-    {
-      grub_file_close (file);
-      return err;
-    }
-
   if (size && grub_file_read (file, module, size) != size)
     {
       grub_file_close (file);
@@ -437,7 +430,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
     }
 
   grub_file_close (file);
-  return GRUB_ERR_NONE;
+
+  return GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
 }
 
 static grub_command_t cmd_multiboot, cmd_module;
Signature · 12 lines
2.46.0

---
Valentin Gehrke
Software Engineer
Kernkonzept GmbH at Dresden, Germany,
HRB 31129, CEO Dr.-Ing. Michael Hohmuth

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#5 lore raw

Hey,

Quoted 5 lines · Valentin Gehrke

Hey Daniel,

did you have time yet to give the patch in my last email a try? I just want to make sure the email didn't get overlooked.

Sorry, it looks it fell through the cracks.

Anyway, I think I was going to ask you to use "git send-email" to send
the patch. So, please do. You can add Reviewed-by: Daniel Kiper <[email protected]> to the patch...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw

PATCH 1/1 loader/multiboot: do not add modules before successful download

Multiboot modules that could not be read successfully (e.g. via network) should not be added to the list of modules to forward to the operating system that is to be booted subsequently.

This patch is necessary because even if a grub.cfg checks whether or not a module was successfully downloaded, it is futile to retry a failed download as the corrupted module will be forwarded either way.

---
 grub-core/loader/multiboot.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
grub-core/loader/multiboot.c +2 -8
index 94be512c4..36b27a906 100644
@@ -420,13 +420,6 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
       target = 0;
     }
 
-  err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
-  if (err)
-    {
-      grub_file_close (file);
-      return err;
-    }
-
   if (size && grub_file_read (file, module, size) != size)
     {
       grub_file_close (file);
@@ -437,7 +430,8 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
     }
 
   grub_file_close (file);
-  return GRUB_ERR_NONE;
+
+  return GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1);
 }
 
 static grub_command_t cmd_multiboot, cmd_module;
Signature · 7 lines
2.46.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel