dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0233-loader-linux-Make-trailer-initrd-entry-aligned-again.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernhardu@vr-web.de>
f725e3
Date: Mon, 20 Jul 2015 14:06:45 +0200
f725e3
Subject: [PATCH] loader/linux: Make trailer initrd entry aligned again.
f725e3
f725e3
Regression from commit:
f725e3
  loader/linux: do not pad initrd with zeroes at the end
f725e3
  a8c473288d3f0a5e17a903a5121dea1a695dda3b
f725e3
f725e3
Wimboot fails since the change above because it expects the "trailer"
f725e3
initrd element on an aligned address.
f725e3
This issue shows only when newc_name is used and the last initrd
f725e3
entry has a not aligned size.
f725e3
---
f725e3
 grub-core/loader/linux.c | 7 ++++++-
f725e3
 1 file changed, 6 insertions(+), 1 deletion(-)
f725e3
f725e3
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
f725e3
index d2cd591f604..be6fa0f4d45 100644
f725e3
--- a/grub-core/loader/linux.c
f725e3
+++ b/grub-core/loader/linux.c
f725e3
@@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[],
f725e3
 
f725e3
   if (newc)
f725e3
     {
f725e3
+      initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
f725e3
       initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
f725e3
 				    + sizeof ("TRAILER!!!") - 1, 4);
f725e3
       free_dir (root);
f725e3
@@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
f725e3
       ptr += cursize;
f725e3
     }
f725e3
   if (newc)
f725e3
-    ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
f725e3
+    {
f725e3
+      grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
f725e3
+      ptr += ALIGN_UP_OVERHEAD (cursize, 4);
f725e3
+      ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
f725e3
+    }
f725e3
   free_dir (root);
f725e3
   root = 0;
f725e3
   return GRUB_ERR_NONE;