All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] safety check in claim_heap()
@ 2008-01-20 14:22 Robert Millan
  2008-01-21 18:07 ` Marco Gerards
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Millan @ 2008-01-20 14:22 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]


Hi!

What do you think of adding this kind of checks?  I know it's not a
perfect safegard, but it can save your day in some situations (it helped
me during i386/ieee1275 port, when link address was 0x100000).

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)

[-- Attachment #2: claim_safety.diff --]
[-- Type: text/x-diff, Size: 884 bytes --]

--- ../../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.  */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-22 20:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-20 14:22 [PATCH] safety check in claim_heap() Robert Millan
2008-01-21 18:07 ` Marco Gerards
2008-01-21 21:01   ` Robert Millan
2008-01-21 21:11     ` Marco Gerards
2008-01-22 20:09       ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.