diff --git a/ChangeLog b/ChangeLog index 08d3bcc7f..ea293f27a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-01-22 Robert Millan + + * kern/powerpc/ieee1275/init.c (grub_claim_heap): Add sanity check to + avoid claiming over our own code. + 2008-01-22 Bean * conf/i386-pc.rmk (pkglib_MODULES): Add `jpeg.mod'. diff --git a/kern/powerpc/ieee1275/init.c b/kern/powerpc/ieee1275/init.c index c86ff79e3..bf57fd685 100644 --- a/kern/powerpc/ieee1275/init.c +++ b/kern/powerpc/ieee1275/init.c @@ -1,7 +1,7 @@ /* init.c -- Initialize GRUB on the newworld mac (PPC). */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. + * Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -143,6 +143,17 @@ static void grub_claim_heap (void) (total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */ len = HEAP_MAX_ADDR - addr; + /* In theory, firmware should already prevent this from happening by not + listing our own image in /memory/available. The check below is intended + as a safegard in case that doesn't happen. It does, however, not protect + us from corrupting our module area, which extends up to a + yet-undetermined region above _end. */ + if ((addr < _end) && ((addr + len) > _start)) + { + grub_printf ("Warning: attempt to claim over our own code!\n"); + len = 0; + } + if (len) { /* Claim and use it. */