diff mbox

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

Message ID 1437915540-7553-1-git-send-email-ard.biesheuvel@linaro.org
State Accepted
Commit f91b1feada0b6f0a4d33648155b3ded2c4e0707e
Headers show

Commit Message

Ard Biesheuvel July 26, 2015, 12:59 p.m. UTC
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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
Hello Catalin,

I think this should go into v4.2 with a cc: stable.

Thanks,
Ard.

 arch/arm64/kernel/efi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ard Biesheuvel July 27, 2015, 12:16 p.m. UTC | #1
On 27 July 2015 at 14:14, Catalin Marinas <catalin.marinas@arm.com> wrote:
> On Sun, Jul 26, 2015 at 02:59:00PM +0200, Ard Biesheuvel wrote:
>> 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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> Hello Catalin,
>>
>> I think this should go into v4.2 with a cc: stable.
>
> If it's cc stable, do you have a Fixes: tag? (it saves me some
> searching).
>

Ah sure, I forgot.

Fixes: f84d02755f5a ("arm64: add EFI runtime services")
diff mbox

Patch

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 9d4aa18f2a82..e8ca6eaedd02 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -122,12 +122,12 @@  static int __init uefi_init(void)
 
 	/* Show what we know for posterity */
 	c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor),
-			     sizeof(vendor));
+			     sizeof(vendor) * sizeof(efi_char16_t));
 	if (c16) {
 		for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
 			vendor[i] = c16[i];
 		vendor[i] = '\0';
-		early_memunmap(c16, sizeof(vendor));
+		early_memunmap(c16, sizeof(vendor) * sizeof(efi_char16_t));
 	}
 
 	pr_info("EFI v%u.%.02u by %s\n",