Blame SOURCES/0001-Initialized-initrd_ctx-so-we-don-t-free-a-random-poi.patch

0dc71c
From 3cb3d2a07b11c95b3f8a908ae9d43eabef4dcf62 Mon Sep 17 00:00:00 2001
0dc71c
From: Peter Jones <pjones@redhat.com>
0dc71c
Date: Wed, 17 Sep 2014 15:13:14 -0500
0dc71c
Subject: [PATCH 1/2] Initialized initrd_ctx so we don't free a random pointer
0dc71c
 from the stack.
0dc71c
0dc71c
Currently, if "linux" fails, the "goto fail;" in grub_cmd_initrd sends us
0dc71c
into grub_initrd_close() without grub_initrd_init() being called, and thus
0dc71c
it never clears initrd_ctx->components.  grub_initrd_close() then frees that
0dc71c
address, which is stale data from the stack.  If the stack happens to have a
0dc71c
stale *address* there that matches a recent allocation, then you'll get a
0dc71c
double free later.
0dc71c
0dc71c
So initialize the memory up front.
0dc71c
0dc71c
Signed-off-by: Peter Jones <pjones@redhat.com>
0dc71c
---
0dc71c
 grub-core/loader/arm/linux.c              | 2 +-
0dc71c
 grub-core/loader/arm64/linux.c            | 2 +-
0dc71c
 grub-core/loader/i386/linux.c             | 2 +-
0dc71c
 grub-core/loader/i386/pc/linux.c          | 2 +-
0dc71c
 grub-core/loader/ia64/efi/linux.c         | 2 +-
0dc71c
 grub-core/loader/mips/linux.c             | 2 +-
0dc71c
 grub-core/loader/powerpc/ieee1275/linux.c | 2 +-
0dc71c
 grub-core/loader/sparc64/ieee1275/linux.c | 2 +-
0dc71c
 8 files changed, 8 insertions(+), 8 deletions(-)
0dc71c
0dc71c
diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
0dc71c
index e6770d9..62cbe75 100644
0dc71c
--- a/grub-core/loader/arm/linux.c
0dc71c
+++ b/grub-core/loader/arm/linux.c
0dc71c
@@ -396,7 +396,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
 {
0dc71c
   grub_file_t file;
0dc71c
   grub_size_t size = 0;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
0dc71c
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
0dc71c
index f1d10a1..0dc144e 100644
0dc71c
--- a/grub-core/loader/arm64/linux.c
0dc71c
+++ b/grub-core/loader/arm64/linux.c
0dc71c
@@ -328,7 +328,7 @@ static grub_err_t
0dc71c
 grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
 		 int argc, char *argv[])
0dc71c
 {
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
   int initrd_size, initrd_pages;
0dc71c
   void *initrd_mem = NULL;
0dc71c
 
0dc71c
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
0dc71c
index 31fb91e..2ae1763 100644
0dc71c
--- a/grub-core/loader/i386/linux.c
0dc71c
+++ b/grub-core/loader/i386/linux.c
0dc71c
@@ -1050,7 +1050,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
   grub_addr_t addr_min, addr_max;
0dc71c
   grub_addr_t addr;
0dc71c
   grub_err_t err;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     {
0dc71c
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
0dc71c
index 672c013..b481e46 100644
0dc71c
--- a/grub-core/loader/i386/pc/linux.c
0dc71c
+++ b/grub-core/loader/i386/pc/linux.c
0dc71c
@@ -388,7 +388,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
   grub_uint8_t *initrd_chunk;
0dc71c
   grub_addr_t initrd_addr;
0dc71c
   grub_err_t err;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     {
0dc71c
diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c
0dc71c
index 87ac49f..eb78e6e 100644
0dc71c
--- a/grub-core/loader/ia64/efi/linux.c
0dc71c
+++ b/grub-core/loader/ia64/efi/linux.c
0dc71c
@@ -568,7 +568,7 @@ static grub_err_t
0dc71c
 grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
 		 int argc, char *argv[])
0dc71c
 {
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     {
0dc71c
diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c
0dc71c
index ef64a5b..4a3e8c5 100644
0dc71c
--- a/grub-core/loader/mips/linux.c
0dc71c
+++ b/grub-core/loader/mips/linux.c
0dc71c
@@ -415,7 +415,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
   void *initrd_src;
0dc71c
   grub_addr_t initrd_dest;
0dc71c
   grub_err_t err;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
0dc71c
diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
0dc71c
index 4a14f66..787d7dc 100644
0dc71c
--- a/grub-core/loader/powerpc/ieee1275/linux.c
0dc71c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
0dc71c
@@ -333,7 +333,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
   grub_size_t size = 0;
0dc71c
   grub_addr_t first_addr;
0dc71c
   grub_addr_t addr;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     {
0dc71c
diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c
0dc71c
index de6ee2f..c5e8dfa 100644
0dc71c
--- a/grub-core/loader/sparc64/ieee1275/linux.c
0dc71c
+++ b/grub-core/loader/sparc64/ieee1275/linux.c
0dc71c
@@ -373,7 +373,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
0dc71c
   grub_addr_t paddr;
0dc71c
   grub_addr_t addr;
0dc71c
   int ret;
0dc71c
-  struct grub_linux_initrd_context initrd_ctx;
0dc71c
+  struct grub_linux_initrd_context initrd_ctx = { 0, };
0dc71c
 
0dc71c
   if (argc == 0)
0dc71c
     {
0dc71c
-- 
0dc71c
1.9.3
0dc71c