grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nested functions used by multiboot2 loader corrupt stack


From: Robert Millan
Subject: Re: nested functions used by multiboot2 loader corrupt stack
Date: Mon, 21 Jan 2008 00:47:30 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On Thu, Jan 17, 2008 at 11:47:50PM +0800, Bean wrote:
> 
> Embedded function used %ecx to store the pointer to it's parent's
> stack. However, the program is compiled using option -mregparm=3,
> which means it can use up to 3 registry to pass parameter.In
> grub_elf32_load_segment, there are three parameter elf, phdr and hook,
> which will take up %eax, %edx and %ecx. The value of %ecx, hook, will
> be overwritten. Use NESTED_FUNC_ATTR ensure that only the first two
> parameter will be passed using registry
> 
> This problem can occur when the following conditions are true:
> 
> 1, Use embedded function as callback.
> 2, The embedded function use local variable in it's parent's stack.
> 3, The embedded function has at least three parameters.

Thanks for the explanation, I think I got the idea now.

I reviewed all GRUB code for other instances of this bug, and only found
the equivalent 64-bit versions of the functions you fixed to be affected.

Just committed a fix based on your patch (plus the 64-bit ones).

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]