Skip to content

Commit 4a9c146

Browse files
Ard BiesheuvelAlex Shi
authored andcommitted
efi: stub: use high allocation for converted command line
Before we can move the command line processing before the allocation of the kernel, which is required for detecting the 'nokaslr' option which controls that allocation, move the converted command line higher up in memory, to prevent it from interfering with the kernel itself. Since x86 needs the address to fit in 32 bits, use UINT_MAX as the upper bound there. Otherwise, use ULONG_MAX (i.e., no limit) Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> (cherry picked from commit 48fcb2d0216103d15306caa4814e2381104df6d8) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 0f01a86 commit 4a9c146

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

arch/x86/include/asm/efi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define EFI32_LOADER_SIGNATURE "EL32"
2626
#define EFI64_LOADER_SIGNATURE "EL64"
2727

28+
#define MAX_CMDLINE_ADDRESS UINT_MAX
29+
2830
#ifdef CONFIG_X86_32
2931

3032

drivers/firmware/efi/libstub/efi-stub-helper.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,10 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n)
649649
return dst;
650650
}
651651

652+
#ifndef MAX_CMDLINE_ADDRESS
653+
#define MAX_CMDLINE_ADDRESS ULONG_MAX
654+
#endif
655+
652656
/*
653657
* Convert the unicode UEFI command line to ASCII to pass to kernel.
654658
* Size of memory allocated return in *cmd_line_len.
@@ -684,7 +688,8 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
684688

685689
options_bytes++; /* NUL termination */
686690

687-
status = efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr);
691+
status = efi_high_alloc(sys_table_arg, options_bytes, 0,
692+
&cmdline_addr, MAX_CMDLINE_ADDRESS);
688693
if (status != EFI_SUCCESS)
689694
return NULL;
690695

0 commit comments

Comments
 (0)