|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/EFI: fix padding of EDD strings
commit a6bc1a68b0d00d656cf42aabb4d619c95b38fa90
Author: Anandu Padinhare <Anandu.Padinhare@xxxxxxxxxxxxxx>
AuthorDate: Tue Nov 10 09:46:13 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Nov 10 09:46:13 2026 +0100
x86/EFI: fix padding of EDD strings
edd_put_string() decrements n in its copy loop condition even when the
loop terminates because the end of the source string was reached. The
padding loop then writes one space too few, leaving the final byte of
the field untouched (zero, as boot_edd_info[] lives in .bss). On an EFI
boot this yields e.g. a host bus type of "PCI\0" and an interface type
of "ATAPI \0", whereas BIOSes space-pad these fields (SeaBIOS reports
"PCI " and "ATA ").
Furthermore, if the string exactly filled the field, n would wrap to
SIZE_MAX after the copy loop and the padding loop would write past the
end of the field. No caller currently passes such a string.
Only decrement n when a character was actually copied. While touching
the function, also correct its indentation.
Fixes: 51f03ec421fb ("x86-64/EFI: construct EDD data from device path
protocol information")
Assisted-by: Claude
Signed-off-by: Anandu Padinhare <Anandu.Padinhare@xxxxxxxxxxxxxx>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
---
xen/arch/x86/efi/efi-boot.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 757b2b529b..17aa273cdb 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -30,13 +30,13 @@ static module_t __initdata mb_modules[5];
static void __init edd_put_string(u8 *dst, size_t n, const char *src)
{
- while ( n-- && *src )
- *dst++ = *src++;
+ for ( ; n && *src; --n )
+ *dst++ = *src++;
if ( *src )
- PrintErrMesg(L"Internal error populating EDD info",
- EFI_BUFFER_TOO_SMALL);
+ PrintErrMesg(L"Internal error populating EDD info",
+ EFI_BUFFER_TOO_SMALL);
while ( n-- )
- *dst++ = ' ';
+ *dst++ = ' ';
}
#define edd_put_string(d, s) edd_put_string(d, ARRAY_SIZE(d), s)
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |