From: Catalin Marinas <catalin.marinas@arm.com>
To: Breno Leitao <leitao@debian.org>
Cc: andreyknvl@gmail.com, kasan-dev@googlegroups.com,
linux-arm-kernel@lists.infradead.org, will@kernel.org,
song@kernel.org, mark.rutland@arm.com, usamaarif642@gmail.com,
Ard Biesheuvel <ardb@kernel.org>,
rmikey@meta.com
Subject: Re: arm64: BUG: KASAN: invalid-access in arch_stack_walk
Date: Tue, 24 Jun 2025 10:00:38 +0100 [thread overview]
Message-ID: <aFppNmkSrdsbwhed@arm.com> (raw)
In-Reply-To: <aFmHQbpwX4WnR/5p@gmail.com>
On Mon, Jun 23, 2025 at 09:56:33AM -0700, Breno Leitao wrote:
> arm64: Use arch_alloc_vmap_stack for EFI runtime stack allocation
>
> Refactor vmap stack allocation by moving the CONFIG_VMAP_STACK check
> from BUILD_BUG_ON to a runtime return of NULL if the config is not set.
> The side effect of this is that _init_sdei_stack() might NOT fail in
> build time if _VMAP_STACK, but in runtime. It shifts error
> detection from compile-time to runtime
_init_sdei_stack() is only called from init_sdei_stacks() if
CONFIG_VMAP_STACK is enabled.
> Then, reuse arch_alloc_vmap_stack() to allocate the ACPI stack
> memory in the arm64_efi_rt_init().
>
> Suggested-by: Andrey Konovalov <andreyknvl@gmail.com>
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Breno Leitao <leitao@debian.org>
>
> diff --git a/arch/arm64/include/asm/vmap_stack.h b/arch/arm64/include/asm/vmap_stack.h
> index 20873099c035c..8380af4507d01 100644
> --- a/arch/arm64/include/asm/vmap_stack.h
> +++ b/arch/arm64/include/asm/vmap_stack.h
> @@ -19,7 +19,8 @@ static inline unsigned long *arch_alloc_vmap_stack(size_t stack_size, int node)
> {
> void *p;
>
> - BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
> + if (!IS_ENABLED(CONFIG_VMAP_STACK))
> + return NULL;
>
> p = __vmalloc_node(stack_size, THREAD_ALIGN, THREADINFO_GFP, node,
> __builtin_return_address(0));
We can leave this unchanged to catch possible misuses in the future.
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 3857fd7ee8d46..6c371b158b99f 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -15,6 +15,7 @@
>
> #include <asm/efi.h>
> #include <asm/stacktrace.h>
> +#include <asm/vmap_stack.h>
>
> static bool region_is_misaligned(const efi_memory_desc_t *md)
> {
> @@ -214,9 +215,8 @@ static int __init arm64_efi_rt_init(void)
> if (!efi_enabled(EFI_RUNTIME_SERVICES))
> return 0;
>
> - p = __vmalloc_node(THREAD_SIZE, THREAD_ALIGN, GFP_KERNEL,
> - NUMA_NO_NODE, &&l);
> -l: if (!p) {
> + p = arch_alloc_vmap_stack(THREAD_SIZE, NUMA_NO_NODE);
and bail out earlier here similar to init_sdei_stacks():
if (!IS_ENABLED(CONFIG_VMAP_STACK))
return -ENOMEM;
> + if (!p) {
> pr_warn("Failed to allocate EFI runtime stack\n");
> clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
> return -ENOMEM;
--
Catalin
prev parent reply other threads:[~2025-06-24 9:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 12:33 arm64: BUG: KASAN: invalid-access in arch_stack_walk Breno Leitao
2025-06-22 12:57 ` Andrey Konovalov
2025-06-23 11:56 ` Catalin Marinas
2025-06-23 16:56 ` Breno Leitao
2025-06-24 9:00 ` Catalin Marinas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFppNmkSrdsbwhed@arm.com \
--to=catalin.marinas@arm.com \
--cc=andreyknvl@gmail.com \
--cc=ardb@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=leitao@debian.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=rmikey@meta.com \
--cc=song@kernel.org \
--cc=usamaarif642@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).