Initialized initrd_ctx so we don't free a random pointer from the stack.

Currently, if "linux" fails, the "goto fail;" in grub_cmd_initrd sends us
into grub_initrd_close() without grub_initrd_init() being called, and thus
it never clears initrd_ctx->components.  grub_initrd_close() then frees that
address, which is stale data from the stack.  If the stack happens to have a
stale *address* there that matches a recent allocation, then you'll get a
double free later.

So initialize the memory up front.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2014-09-17 16:30:11 -04:00 committed by Andrei Borzenkov
parent 60049a0e72
commit 631a820038
9 changed files with 20 additions and 8 deletions

View file

@ -1,3 +1,15 @@
2014-21-15 Peter Jones <pjones@redhat.com>
* grub-core/loader/arm/linux.c: Initialized initrd_ctx so
we don't free a random pointer from the stack.
* grub-core/loader/arm64/linux.c: Likewise.
* grub-core/loader/i386/linux.c: Likewise.
* grub-core/loader/i386/pc/linux.c: Likewise.
* grub-core/loader/ia64/efi/linux.c: Likewise.
* grub-core/loader/mips/linux.c: Likewise.
* grub-core/loader/powerpc/ieee1275/linux.c: Likewise.
* grub-core/loader/sparc64/ieee1275/linux.c: Likewise.
2014-09-15 Khem Raj <raj.khem@gmail.com>
* grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to