From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Cc: "Yoshinori K. Okuji" <okuji@enbug.org>
Subject: Re: loader modules jumping back to kernel
Date: Sun, 27 Jul 2008 23:39:49 +0200 [thread overview]
Message-ID: <20080727213949.GA24562@thorin> (raw)
In-Reply-To: <200807201109.03173.okuji@enbug.org>
On Sun, Jul 20, 2008 at 11:09:02AM +0200, Yoshinori K. Okuji wrote:
> > IIRC this causes trouble when the loadee chose an address that precisely
> > overwrites the loader, which is garanteed to happen when GRUB is loading
> > itself, AFAICT.
>
> Sure. My recommendation is, in case where you might overwrite that part, that
> you should write relocatable code (which is rather easy for simple code on
> i386) at anywhere (it could be in the startup), find out a safe region when
> loading an OS image, copy the code to the safe region, and finalize the
> bootstrap in that code (e.g. relocating the OS image, initializing registers,
> and jumping to it). On i386, we have a reserved region to temporarily load an
> OS image for the very reason, so this is not difficult.
Ok. I've been looking at grub_multiboot_load_elf32() which contains the
bound checks that make loading abort in first place; It seems that bounds
are checked for every segment in the ELF image, in:
/* Load every loadable segment in memory. */
for (i = 0; i < ehdr->e_phnum; i++)
so I'm wondering if it is safe to assume the segments are going to occupy
a single block of memory (which can be relocated in one run) or it is allowed
for them to be scattered.
As for the safe region, AFAICT the OS load area is our only choice, or maybe
the heap, but in both cases overlaps are a problem, as we don't want the
relocator code to overwrite itself. In case of the OS load area, we could
abort on situations where payload requested region overlaps with our area,
and in case of the heap, we could play some ugly tricks in order to obtain
a non-overlapped region from malloc.
TBH I don't like either of the options. Do you have any other suggestions?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
next prev parent reply other threads:[~2008-07-27 21:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-19 23:06 loader modules jumping back to kernel Robert Millan
2008-07-20 3:26 ` Bean
2008-07-20 9:09 ` Yoshinori K. Okuji
2008-07-27 21:39 ` Robert Millan [this message]
2008-07-30 19:15 ` loadee relocation (Re: loader modules jumping back to kernel) Robert Millan
2008-07-31 23:45 ` Robert Millan
2008-08-01 16:16 ` Robert Millan
2008-08-01 22:45 ` Robert Millan
2008-08-02 12:11 ` 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=20080727213949.GA24562@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
--cc=okuji@enbug.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.