rhboot / efibootmgr

efibootmgr development tree
GNU General Public License v2.0
519 stars 98 forks source link

--index argument not respected and IOT instruction #206

Open Nowa-Ammerlaan opened 7 months ago

Nowa-Ammerlaan commented 7 months ago

This is my starting configuration:

BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0002,0001,0006,0007,0008
Boot0001* Windows Boot Manager  HD(1,GPT,3bed0f92-bec1-11ec-9467-98b2f623c3c1,0x800,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d000000ffff0100000010000000040000007fff0400
Boot0002* UEFI OS       HD(1,GPT,7ae430c6-07e8-3b4e-a796-b2a28706b3fb,0x800,0x100800)/File(\EFI\BOOT\BOOTX64.EFI)0000424f
Boot0006* Windows Boot Manager  HD(1,GPT,7ae430c6-07e8-3b4e-a796-b2a28706b3fb,0x800,0x100800)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)0000424f
Boot0007* UEFI: PXE IP4 Realtek PCIe GBE Family Controller      PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(309c23aebbb1,0)/IPv4(0.0.0.00.0.0.0,0,0)0000424f
Boot0008* UEFI: PXE IP6 Realtek PCIe GBE Family Controller      PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(309c23aebbb1,0)/IPv6([::]:<->[::]:,0,0)0000424f

The aim here is to add an entry at a specific index, and then save this index so it can be removed again later (https://github.com/projg2/installkernel-gentoo/issues/19).

However, the -I argument causes complaints, even though it is valid according to the --help:

efibootmgr: invalid option -- 'I'
efibootmgr version 18

Writing it out in full as --index causes the argument to be recognized, but entries are still added to the first available index (0000):

andrew-gentoo-pc EFI # efibootmgr -C -L "systemd-boot" --index 0009 -l '\EFI\systemd\systemd-bootx64.efi'
BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0002,0001,0006,0007,0008
Boot0001* Windows Boot Manager  HD(1,GPT,3bed0f92-bec1-11ec-9467-98b2f623c3c1,0x800,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d000000ffff0100000010000000040000007fff0400
Boot0002* UEFI OS       HD(1,GPT,7ae430c6-07e8-3b4e-a796-b2a28706b3fb,0x800,0x100800)/File(\EFI\BOOT\BOOTX64.EFI)0000424f
Boot0006* Windows Boot Manager  HD(1,GPT,7ae430c6-07e8-3b4e-a796-b2a28706b3fb,0x800,0x100800)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)0000424f
Boot0007* UEFI: PXE IP4 Realtek PCIe GBE Family Controller      PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(309c23aebbb1,0)/IPv4(0.0.0.00.0.0.0,0,0)0000424f
Boot0008* UEFI: PXE IP6 Realtek PCIe GBE Family Controller      PciRoot(0x0)/Pci(0x1c,0x3)/Pci(0x0,0x0)/MAC(309c23aebbb1,0)/IPv6([::]:<->[::]:,0,0)0000424f
Boot0000* systemd-boot  HD(1,GPT,06c47652-831b-8a43-8feb-d83e9600a7d3,0x800,0xe8e08000)/File(\EFI\systemd\systemd-bootx64.efi)

Using -c instead of -C, causes IOT instruction:

andrew-gentoo-pc EFI # efibootmgr -c -L "systemd-boot" --index 0009 -l '\EFI\systemd\systemd-bootx64.efi'
double free or corruption (out)
zsh: IOT instruction  efibootmgr -c -L "systemd-boot" --index 0009 -l
Nowa-Ammerlaan commented 7 months ago

Oops, it seems I misunderstood the manual here. --index is supposed to modify the bootorder of the new entry, not the hex. The --bootnum argument is what I was looking for.

That being said, the IOT instruction problem is something that should probably still be fixed.