|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] x86/EFI: don't let the EDD disk counter wrap
efi_arch_edd() increments the u8 boot_edd_info_nr once per candidate
disk, without bound. Disks past EDD_INFO_MAX are meant to be skipped by
the "boot_edd_info_nr > EDD_INFO_MAX" checks in the device path
handling, but with 256 or more disks the counter wraps to zero. For the
256th disk "info" and "params" then point at boot_edd_info[255], about
20KiB past the end of the array, while the checks pass, so its details
are written there. With xen.efi that is currently the alternatives
table, and Xen panics with "Unable to apply alternatives". Later disks
overwrite the first entries. "edd=" can't avoid this, as it is ignored
when booting via EFI.
Saturate the counter at EDD_INFO_MAX + 1 instead.
Fixes: 51f03ec421fb ("x86-64/EFI: construct EDD data from device path protocol
information")
Signed-off-by: Anandu Padinhare <Anandu.Padinhare@xxxxxxxxxxxxxx>
---
Reproduced in QEMU/OVMF with 256 and 260 whole disks (NVMe namespaces):
xen.efi panics; via GRUB/multiboot2 Xen boots, but Dom0 gets wrong EDD
entries. With this patch both boot with the first 6 disks, and with 5,
15 and 255 disks Dom0's EDD data is unchanged.
The only other use of the counter in the loop is the fake device number
of MBR signatures, now 0x87 rather than 0x88 and up for the 8th and
later disks. Neither matches an EDD entry, and Linux ignores it. If
the old values should be kept, a separate disk counter can do that.
xen/arch/x86/efi/efi-boot.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 8bca03a66b..b255b01fa3 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -398,7 +398,9 @@ static void __init efi_arch_edd(void)
params->bytes_per_sector = bio->Media->BlockSize;
params->dpte_ptr = ~0;
}
- ++boot_edd_info_nr;
+ /* Don't wrap, or the checks below would stop skipping extra disks. */
+ if ( boot_edd_info_nr <= EDD_INFO_MAX )
+ ++boot_edd_info_nr;
status = efi_bs->HandleProtocol(handles[i], &devp_guid,
(void **)&devp);
if ( EFI_ERROR(status) )
base-commit: 77ff75d3244faa2bc083c0ba8686830f8de30d9e
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |