--- ../../grub2/kern/powerpc/ieee1275/init.c 2008-01-14 15:30:59.000000000 +0100 +++ kern/powerpc/ieee1275/init.c 2008-01-20 15:20:23.000000000 +0100 @@ -143,6 +143,17 @@ (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. */