Skip to content

Commit ef8923e

Browse files
leitaowilldeacon
authored andcommitted
arm64: efi: Fix KASAN false positive for EFI runtime stack
KASAN reports invalid accesses during arch_stack_walk() for EFI runtime services due to vmalloc tagging[1]. The EFI runtime stack must be allocated with KASAN tags reset to avoid false positives. This patch uses arch_alloc_vmap_stack() instead of __vmalloc_node() for EFI stack allocation, which internally calls kasan_reset_tag() The changes ensure EFI runtime stacks are properly sanitized for KASAN while maintaining functional consistency. Link: https://lore.kernel.org/all/[email protected]/ [1] Suggested-by: Andrey Konovalov <[email protected]> Suggested-by: Catalin Marinas <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Breno Leitao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 39dfc97 commit ef8923e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arch/arm64/kernel/efi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <asm/efi.h>
1717
#include <asm/stacktrace.h>
18+
#include <asm/vmap_stack.h>
1819

1920
static bool region_is_misaligned(const efi_memory_desc_t *md)
2021
{
@@ -214,9 +215,13 @@ static int __init arm64_efi_rt_init(void)
214215
if (!efi_enabled(EFI_RUNTIME_SERVICES))
215216
return 0;
216217

217-
p = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN, GFP_KERNEL,
218-
NUMA_NO_NODE, &&l);
219-
l: if (!p) {
218+
if (!IS_ENABLED(CONFIG_VMAP_STACK)) {
219+
clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
220+
return -ENOMEM;
221+
}
222+
223+
p = arch_alloc_vmap_stack(THREAD_SIZE, NUMA_NO_NODE);
224+
if (!p) {
220225
pr_warn("Failed to allocate EFI runtime stack\n");
221226
clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
222227
return -ENOMEM;

0 commit comments

Comments
 (0)