Commit 991e893c authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Luis Henriques

arm64/efi: map the entire UEFI vendor string before reading it

commit f91b1fea upstream.

At boot, the UTF-16 UEFI vendor string is copied from the system
table into a char array with a size of 100 bytes. However, this
size of 100 bytes is also used for memremapping() the source,
which may not be sufficient if the vendor string exceeds 50
UTF-16 characters, and the placement of the vendor string inside
a 4 KB page happens to leave the end unmapped.

So use the correct '100 * sizeof(efi_char16_t)' for the size of
the mapping.
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Fixes: f84d0275 ("arm64: add EFI runtime services")
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent c433ad7a
...@@ -98,7 +98,7 @@ static int __init uefi_init(void) ...@@ -98,7 +98,7 @@ static int __init uefi_init(void)
/* Show what we know for posterity */ /* Show what we know for posterity */
c16 = early_memremap(efi.systab->fw_vendor, c16 = early_memremap(efi.systab->fw_vendor,
sizeof(vendor)); sizeof(vendor) * sizeof(efi_char16_t));
if (c16) { if (c16) {
for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i) for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
vendor[i] = c16[i]; vendor[i] = c16[i];
...@@ -113,7 +113,7 @@ static int __init uefi_init(void) ...@@ -113,7 +113,7 @@ static int __init uefi_init(void)
if (retval == 0) if (retval == 0)
set_bit(EFI_CONFIG_TABLES, &efi.flags); set_bit(EFI_CONFIG_TABLES, &efi.flags);
early_memunmap(c16, sizeof(vendor)); early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t));
early_memunmap(efi.systab, sizeof(efi_system_table_t)); early_memunmap(efi.systab, sizeof(efi_system_table_t));
return retval; return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment