]> git.ipfire.org Git - thirdparty/grub.git/commit
commands/bli: Fix crash in get_part_uuid()
authorMichael Chang <mchang@suse.com>
Wed, 17 Jul 2024 06:46:46 +0000 (14:46 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 5 Sep 2024 14:08:17 +0000 (16:08 +0200)
commit9537f4403dd836d5a8a1c4e57b165837fc7239cf
tree36c354081324e371e915626d5116fa865a5237bb
parentb53ec06a1d6f22ffc1139cbfc0f292e4ca2da9cd
commands/bli: Fix crash in get_part_uuid()

The get_part_uuid() function made an assumption that the target GRUB
device is a partition device and accessed device->disk->partition
without checking for NULL. There are four situations where this
assumption is problematic:

1. The device is a net device instead of a disk.
2. The device is an abstraction device, like LVM, RAID, or CRYPTO, which
   is mostly logical "disk" ((lvmid/<UUID>) and so on).
3. Firmware RAID may present the ESP to GRUB as an EFI disk (hd0) device
   if it is contained within a Linux software RAID.
4. When booting from a CD-ROM, the ESP is a VFAT image indexed by the El
   Torito boot catalog. The boot device is set to (cd0), corresponding
   to the CD-ROM image mounted as an ISO 9660 filesystem.

As a result, get_part_uuid() could lead to a NULL pointer dereference
and trigger a synchronous exception during boot if the ESP falls into
one of these categories. This patch fixes the problem by adding the
necessary checks to handle cases where the ESP is not a partition device.

Additionally, to avoid disrupting the boot process, this patch relaxes
the severity of the errors in this context to non-critical. Errors will
be logged, but they will not prevent the boot process from continuing.

Fixes: e0fa7dc84 (bli: Add a module for the Boot Loader Interface)
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-By: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/bli.c