Bug#898553: grub-legacy 0.97-73 segfaults

Bernhard Übelacker bernhardu at mailbox.org
Fri Jul 6 18:32:46 BST 2018


tags 897390 = patch
quit


Hello Eugene,
I am not sure if gcc is here to blame as grub is here doing something
unusual.
Also there might be some (yet unknown) command line switch to gcc to
restore old behaviour...

Nevertheless I was curious on getting that working again ...

Attached patch is not relying on having the static variables accessible
after the stack got switched by putting pointer to them on the new stack.

Tested so far:
- i386/amd64: /usr/sbin/grub works.
- amd64: grub-install works with a ext2 boot partition [1]. Booting the
  system after that worked too.
  For some reason it did not want to install to a ext4 system partition,
  but this might be a different problem (probably #748793).

Kind regards,
Bernhard

PS.: You might leave 898553 at bugs.debian.org always in CC, so your emails
are added to the Debian bug.



[1] Output of grub-install without the patch:
    # LANG=C grub-install /dev/sda
    Searching for GRUB installation directory ... found: /boot/grub
    Segmentation fault
    cmp: EOF on /tmp/grubJw13E3 which is empty
    Segmentation fault
    cmp: EOF on /tmp/grubJw13E3 which is empty
    Segmentation fault
    cmp: EOF on /tmp/grubJw13E3 which is empty
    Segmentation fault
    cmp: EOF on /tmp/grubJw13E3 which is empty
    Segmentation fault
    cmp: EOF on /tmp/grubJw13E3 which is empty
    The file /boot/grub/stage1 not read correctly.

[2] Output of grub-install with the patch:
    # LANG=C grub-install /dev/sda
    Searching for GRUB installation directory ... found: /boot/grub
    Installation finished. No error reported.
    This is the contents of the device map /boot/grub/device.map.
    Check if this is correct or not. If any of the lines is incorrect,
    fix it and re-run the script `grub-install'.

    (fd0)   /dev/fd0
    (hd0)   /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001
    (hd1)   /dev/disk/by-id/ata-QEMU_HARDDISK_QM00002



Am 05.07.2018 um 21:09 schrieb Eugene Berdnikov:
>   Hello Bernhard.
>   
> On Thu, Jul 05, 2018 at 06:10:44PM +0200, Bernhard Übelacker wrote:
>> Hello Eugene,
>> I just tried to reproduce the issue and collect some more information.
>> Unfortunately grub-legacy has not yet a dbgsym package.
>> But is also crashing with a self built package.
> ...
>> Unfortunately gcc-7 generates this sequence:
>>         mov    0xc(%esp),%eax
>>         mov    %eax,%ebx
>>         movl   $0x0,0xee8(%eax)
>>
>> So i guess gcc-7 relies to have the address of some area holding the static variables
>> at the stack "0xc(%esp)", but as we switched stacks some lines before we get
>> just a 0 into register $eax.
> 
>  Thank you very mush for this excellent job!
>  Unfortunately I can't help anymore, because I am sysadmin, not a programmer,
>  and have no skills and resources for communication with gcc developers.
> 
>  Grub-legacy is very good software, much more convinient and useful then
>  grub2. I use old builds in my environment. and hope this situation
>  will be resolved in the future...
> 
>  Have a good luck, and thanks again!
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Put-pointers-to-static-variables-as-arguments-on-the.patch
Type: text/x-patch
Size: 2935 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-grub-devel/attachments/20180706/ca19f815/attachment.bin>


More information about the Pkg-grub-devel mailing list