From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] safety check in claim_heap()
Date: Sun, 20 Jan 2008 15:22:38 +0100 [thread overview]
Message-ID: <20080120142238.GA11485@thorin> (raw)
[-- 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. */
next reply other threads:[~2008-01-20 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-20 14:22 Robert Millan [this message]
2008-01-21 18:07 ` [PATCH] safety check in claim_heap() Marco Gerards
2008-01-21 21:01 ` Robert Millan
2008-01-21 21:11 ` Marco Gerards
2008-01-22 20:09 ` Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080120142238.GA11485@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.