lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aGaxZHLnDQc_kSur@arm.com>
Date: Thu, 3 Jul 2025 17:35:48 +0100
From: Catalin Marinas <catalin.marinas@....com>
To: Breno Leitao <leitao@...ian.org>
Cc: Will Deacon <will@...nel.org>, usamaarif642@...il.com,
	Ard Biesheuvel <ardb@...nel.org>, rmikey@...a.com,
	andreyknvl@...il.com, kasan-dev@...glegroups.com,
	linux-efi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org, kernel-team@...a.com
Subject: Re: [PATCH] arm64: efi: Fix KASAN false positive for EFI runtime
 stack

On Tue, Jun 24, 2025 at 05:55:53AM -0700, Breno Leitao wrote:
> 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/aFVVEgD0236LdrL6@gmail.com/ [1]
> Suggested-by: Andrey Konovalov <andreyknvl@...il.com>
> Suggested-by: Catalin Marinas <catalin.marinas@....com>
> Signed-off-by: Breno Leitao <leitao@...ian.org>
> ---
>  arch/arm64/kernel/efi.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 3857fd7ee8d46..d2af881a48290 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,11 @@ 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) {
> +	if (!IS_ENABLED(CONFIG_VMAP_STACK))
> +		return -ENOMEM;

Mark Rutland pointed out in a private chat that this should probably
clear the EFI_RUNTIME_SERVICES flag as well.

> +
> +	p = arch_alloc_vmap_stack(THREAD_SIZE, NUMA_NO_NODE);
> +	if (!p) {
>  		pr_warn("Failed to allocate EFI runtime stack\n");
>  		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  		return -ENOMEM;
> 

With that:

Reviewed-by: Catalin Marinas <catalin.marinas@....com>

(but let's see if Ard has a different opinion on the approach)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ