[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXGBo_EBg+SYRd_cwPwQRq1NmRwJNyV6vjMMgA_S7Yff=A@mail.gmail.com>
Date: Sat, 9 Jan 2021 09:51:19 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Hailong liu <hailongliiu@...h.net>,
Linus Walleij <linus.walleij@...aro.org>
Cc: Andrey Ryabinin <aryabinin@...tuozzo.com>,
Ziliang Guo <guo.ziliang@....com.cn>,
Hailong Liu <liu.hailong6@....com.cn>,
kasan-dev <kasan-dev@...glegroups.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux Memory Management List <linux-mm@...ck.org>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
Russell King <linux@...linux.org.uk>
Subject: Re: [PATCH] arm/kasan:fix the arry size of kasan_early_shadow_pte
(+ Linus)
On Sat, 9 Jan 2021 at 05:50, Hailong liu <hailongliiu@...h.net> wrote:
>
> From: Hailong Liu <liu.hailong6@....com.cn>
>
> The size of kasan_early_shadow_pte[] now is PTRS_PER_PTE which defined to
> 512 for arm architecture. This means that it only covers the prev Linux pte
> entries, but not the HWTABLE pte entries for arm.
>
> The reason it works well current is that the symbol kasan_early_shadow_page
> immediately following kasan_early_shadow_pte in memory is page aligned,
> which makes kasan_early_shadow_pte look like a 4KB size array. But we can't
> ensure the order always right with different compiler/linker, nor more bss
> symbols be introduced.
>
> We had a test with QEMU + vexpress:put a 512KB-size symbol with attribute
> __section(".bss..page_aligned") after kasan_early_shadow_pte, and poison it
> after kasan_early_init(). Then enabled CONFIG_KASAN, it failed to boot up.
>
> Signed-off-by: Hailong Liu <liu.hailong6@....com.cn>
> Signed-off-by: Ziliang Guo <guo.ziliang@....com.cn>
> ---
> include/linux/kasan.h | 6 +++++-
> mm/kasan/init.c | 3 ++-
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> index 5e0655fb2a6f..fe1ae73ff8b5 100644
> --- a/include/linux/kasan.h
> +++ b/include/linux/kasan.h
> @@ -35,8 +35,12 @@ struct kunit_kasan_expectation {
> #define KASAN_SHADOW_INIT 0
> #endif
>
> +#ifndef PTE_HWTABLE_PTRS
> +#define PTE_HWTABLE_PTRS 0
> +#endif
> +
> extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
> -extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
> +extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS];
> extern pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD];
> extern pud_t kasan_early_shadow_pud[PTRS_PER_PUD];
> extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D];
> diff --git a/mm/kasan/init.c b/mm/kasan/init.c
> index bc0ad208b3a7..7ca0b92d5886 100644
> --- a/mm/kasan/init.c
> +++ b/mm/kasan/init.c
> @@ -64,7 +64,8 @@ static inline bool kasan_pmd_table(pud_t pud)
> return false;
> }
> #endif
> -pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss;
> +pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]
> + __page_aligned_bss;
>
> static inline bool kasan_pte_table(pmd_t pmd)
> {
> --
> 2.17.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Powered by blists - more mailing lists