dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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