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

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