[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <4b6df6db-2f2e-4128-a969-c9dff3345c84@app.fastmail.com>
Date: Wed, 30 Oct 2024 09:05:38 +0000
From: "Jiaxun Yang" <jiaxun.yang@...goat.com>
To: "Huacai Chen" <chenhuacai@...ngson.cn>,
"Huacai Chen" <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, "Xuefeng Li" <lixuefeng@...ngson.cn>,
"Guo Ren" <guoren@...nel.org>, "Xuerui Wang" <kernel@...0n.name>,
linux-kernel@...r.kernel.org, loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] LoongArch: Disable KASAN if PGDIR_SIZE is too large for cpu_vabits
在2024年10月30日十月 上午8:11,Huacai Chen写道:
> If PGDIR_SIZE is too large for cpu_vabits, KASAN_SHADOW_END will
> overflow UINTPTR_MAX because KASAN_SHADOW_START/KASAN_SHADOW_END are
> aligned up by PGDIR_SIZE. And then the overflowed KASAN_SHADOW_END looks
> like a user space address.
>
> For example, PGDIR_SIZE of CONFIG_4KB_4LEVEL is 2^39, which is too large
> for Loongson-2K series whose cpu_vabits = 39.
>
> Since CONFIG_4KB_4LEVEL is completely legal for CPUs with cpu_vabits <=
> 39, we just disable KASAN via early return in kasan_init(). Otherwise we
> get a boot failure.
>
> Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
Reviewed-by: Jiaxun Yang <jiaxun.yang@...goat.com>
I was hit by this issue as well.
Thanks
- Jiaxun
> ---
> arch/loongarch/mm/kasan_init.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/arch/loongarch/mm/kasan_init.c b/arch/loongarch/mm/kasan_init.c
> index 4a0d1880dd71..6bdcc8751d4e 100644
> --- a/arch/loongarch/mm/kasan_init.c
> +++ b/arch/loongarch/mm/kasan_init.c
> @@ -262,6 +262,17 @@ void __init kasan_init(void)
> u64 i;
> phys_addr_t pa_start, pa_end;
>
> + /*
> + * If PGDIR_SIZE is too large for cpu_vabits, KASAN_SHADOW_END will
> + * overflow UINTPTR_MAX and then looks like a user space address.
> + * For example, PGDIR_SIZE of CONFIG_4KB_4LEVEL is 2^39, which is too
> + * large for Loongson-2K series whose cpu_vabits = 39.
> + */
> + if (KASAN_SHADOW_END < vm_map_base) {
> + pr_warn("PGDIR_SIZE too large for cpu_vabits, KernelAddressSanitizer
> disabled.\n");
> + return;
> + }
> +
> /*
> * PGD was populated as invalid_pmd_table or invalid_pud_table
> * in pagetable_init() which depends on how many levels of page
> --
> 2.43.5
--
- Jiaxun
Powered by blists - more mailing lists