Bug#632048: segfault in grub-setup
Quoted 9 lines · Stephane Chazelas
I do get a segfault as well when doing a grub-setup/grub-install on a mdraid with 1.2 metadata.
The segv is in:
grub_util_biosdisk_is_floppy()because thedisk->idfor the root device is not a bios disk id, but a big number that is the "array id". The patch below seems to fix it for me, though I can't tell it's the right fix or not (probably not).
This fix makes sense to me; calling grub_util_biosdisk_is_floppy on disks that aren't GRUB_DISK_DEVICE_BIOSDISK_ID doesn't make sense. grub-devel, second opinion?
util/grub-setup.c line 321
Quoted 11 lines
util/grub-setup.c +1
-1@@ -315,7 +315,7 @@/* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ -if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)) +if (!allow_floppy && dest_dev->disk->dev->id ==GRUB_DISK_DEVICE_BIOSDISK_ID && !grub_util_biosdisk_is_floppy (dest_dev->disk))/* Replace the jmp (2 bytes) with double nop's. */ *boot_drive_check =0x9090 ; }
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
2011-09-06 09:18:57 +0100, Colin Watson:
Quoted 15 lines · Stephane Chazelas
Quoted 9 lines
I do get a segfault as well when doing a grub-setup/grub-install on a mdraid with 1.2 metadata.
The segv is in:
grub_util_biosdisk_is_floppy()because thedisk->idfor the root device is not a bios disk id, but a big number that is the "array id". The patch below seems to fix it for me, though I can't tell it's the right fix or not (probably not).This fix makes sense to me; calling
grub_util_biosdisk_is_floppyon disks that aren'tGRUB_DISK_DEVICE_BIOSDISK_IDdoesn't make sense. grub-devel, second opinion?
Quoted 11 lines
util/grub-setup.c line 321
Quoted 11 lines
util/grub-setup.c +1
-1@@ -315,7 +315,7 @@/* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ -if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)) +if (!allow_floppy && dest_dev->disk->dev->id ==GRUB_DISK_DEVICE_BIOSDISK_ID && !grub_util_biosdisk_is_floppy (dest_dev->disk))/* Replace the jmp (2 bytes) with double nop's. */ *boot_drive_check =0x9090 ; }
[...]
The fact that the problem doesn't occur with mdraid-0.9 makes me think the problem might be somewhere else though (like that dest_dev->disk should be a biosdisk above)..
Signature · 1 line
Stephane
2011-09-06 09:18:57 +0100, Colin Watson:
Quoted 15 lines · Stephane Chazelas
Quoted 9 lines
I do get a segfault as well when doing a grub-setup/grub-install on a mdraid with 1.2 metadata.
The segv is in:
grub_util_biosdisk_is_floppy()because thedisk->idfor the root device is not a bios disk id, but a big number that is the "array id". The patch below seems to fix it for me, though I can't tell it's the right fix or not (probably not).This fix makes sense to me; calling
grub_util_biosdisk_is_floppyon disks that aren'tGRUB_DISK_DEVICE_BIOSDISK_IDdoesn't make sense. grub-devel, second opinion?
Quoted 11 lines
util/grub-setup.c line 321
Quoted 11 lines
util/grub-setup.c +1
-1@@ -315,7 +315,7 @@/* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ -if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)) +if (!allow_floppy && dest_dev->disk->dev->id ==GRUB_DISK_DEVICE_BIOSDISK_ID && !grub_util_biosdisk_is_floppy (dest_dev->disk))/* Replace the jmp (2 bytes) with double nop's. */ *boot_drive_check =0x9090 ; }
[...]
Well, anyway, even after that patch, it still doesn't work
grub-install /dev/md0
reports success for nothing is written to any disk.
grub-install /dev/sda
or /dev/sdb
doesn't work because it complains about a partition-less disk.
Looks like it's not supported. Strange, as when started, grub can happily see files on 1.2 raids (using mdraid1x). Or did I miss something.
I'll have to revert to 0.9 metadata for now.
Signature · 1 line
Stephane
Quoted 28 lines · Stephane Chazelas
2011-09-06 09:18:57 +0100, Colin Watson:Quoted 25 lines · Stephane Chazelas
Quoted 9 lines
I do get a segfault as well when doing a grub-setup/grub-install on a mdraid with 1.2 metadata.
The segv is in:
grub_util_biosdisk_is_floppy()because thedisk->idfor the root device is not a bios disk id, but a big number that is the "array id". The patch below seems to fix it for me, though I can't tell it's the right fix or not (probably not).This fix makes sense to me; calling
grub_util_biosdisk_is_floppyon disks that aren'tGRUB_DISK_DEVICE_BIOSDISK_IDdoesn't make sense. grub-devel, second opinion?Quoted 11 lines
util/grub-setup.c +1
-1@@ -315,7 +315,7 @@/* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ -if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)) +if (!allow_floppy && dest_dev->disk->dev->id ==GRUB_DISK_DEVICE_BIOSDISK_ID && !grub_util_biosdisk_is_floppy (dest_dev->disk))/* Replace the jmp (2 bytes) with double nop's. */ *boot_drive_check =0x9090 ; }[...]
Quoted 5 lines
Well, anyway, even after that patch, it still doesn't work
grub-install
/dev/md0
reports success for nothing is written to any disk.
This command supposes that md0 is used as a disk for a VM
Quoted 5 lines
grub-install
/dev/sda
or/dev/sdbdoesn't work because it complains about a partition-less disk.
Because you can't use RAID on disks for booting (except some cases but it's not recommended even if they apply). Make a RAID of partitions and leave 1M before the start of the single partition on the disk. GRUB has done its job in telling that your setup is unbootable.
Quoted 6 lines
Looks like it's not supported. Strange, as when started, grub can happily see files on 1.2 raids (using mdraid1x). Or did I miss something.
I'll have to revert to 0.9 metadata for now.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
The problem with floppy part was fixed and the attempt to install on partionless disk was a user error. Closing
Quoted 44 lines · Stephane Chazelas
2011-09-06 09:18:57 +0100, Colin Watson:Quoted 14 lines · Stephane Chazelas
Quoted 9 lines
I do get a segfault as well when doing a grub-setup/grub-install on a mdraid with 1.2 metadata.
The segv is in:
grub_util_biosdisk_is_floppy()because thedisk->idfor the root device is not a bios disk id, but a big number that is the "array id". The patch below seems to fix it for me, though I can't tell it's the right fix or not (probably not).This fix makes sense to me; calling
grub_util_biosdisk_is_floppyon disks that aren'tGRUB_DISK_DEVICE_BIOSDISK_IDdoesn't make sense. grub-devel, second opinion?Quoted 11 lines
util/grub-setup.c line 321
Quoted 11 lines
util/grub-setup.c +1
-1@@ -315,7 +315,7 @@/* If DEST_DRIVE is a hard disk, enable the workaround, which is for buggy BIOSes which don't pass boot drive correctly. Instead, they pass 0x00 or 0x01 even when booted from 0x80. */ -if (!allow_floppy&& !grub_util_biosdisk_is_floppy (dest_dev->disk)) +if (!allow_floppy&& dest_dev->disk->dev->id ==GRUB_DISK_DEVICE_BIOSDISK_ID && !grub_util_biosdisk_is_floppy (dest_dev->disk))/* Replace the jmp (2 bytes) with double nop's. */ *boot_drive_check =0x9090 ; }[...]
Well, anyway, even after that patch, it still doesn't work
grub-install
/dev/md0
reports success for nothing is written to any disk.grub-install
/dev/sda
or/dev/sdbdoesn't work because it complains about a partition-less disk.
Looks like it's not supported. Strange, as when started, grub can happily see files on 1.2 raids (using mdraid1x). Or did I miss something.
I'll have to revert to 0.9 metadata for now.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko