mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, ardb@kernel.org,
	aryabinin@virtuozzo.com, dvyukov@google.com, glider@google.com,
	guo.ziliang@zte.com.cn, linus.walleij@linaro.org,
	linux-mm@kvack.org, linux@armlinux.org.uk,
	liu.hailong6@zte.com.cn, mm-commits@vger.kernel.org,
	torvalds@linux-foundation.org
Subject: [patch 04/10] arm/kasan: fix the array size of kasan_early_shadow_pte[]
Date: Tue, 12 Jan 2021 15:49:14 -0800	[thread overview]
Message-ID: <20210112234914.NwudbAxXv%akpm@linux-foundation.org> (raw)
In-Reply-To: <20210112154839.abeb6e57de79480059fd9b0e@linux-foundation.org>

From: Hailong Liu <liu.hailong6@zte.com.cn>
Subject: arm/kasan: fix the array size of kasan_early_shadow_pte[]

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.

Link: https://lkml.kernel.org/r/20210109044622.8312-1-hailongliiu@yeah.net
Signed-off-by: Hailong Liu <liu.hailong6@zte.com.cn>
Signed-off-by: Ziliang Guo <guo.ziliang@zte.com.cn>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/kasan.h |    6 +++++-
 mm/kasan/init.c       |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

--- a/include/linux/kasan.h~arm-kasan-fix-the-arry-size-of-kasan_early_shadow_pte
+++ a/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];
--- a/mm/kasan/init.c~arm-kasan-fix-the-arry-size-of-kasan_early_shadow_pte
+++ a/mm/kasan/init.c
@@ -64,7 +64,8 @@ static inline bool kasan_pmd_table(pud_t
 	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)
 {
_

  parent reply	other threads:[~2021-01-13  0:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 23:48 incoming Andrew Morton
2021-01-12 23:49 ` [patch 01/10] mm, slub: consider rest of partial list if acquire_slab() fails Andrew Morton
2021-01-12 23:49 ` [patch 02/10] mm/page_alloc: add a missing mm_page_alloc_zone_locked() tracepoint Andrew Morton
2021-01-12 23:49 ` [patch 03/10] mm/memcontrol: fix warning in mem_cgroup_page_lruvec() Andrew Morton
2021-01-12 23:49 ` Andrew Morton [this message]
2021-01-12 23:49 ` [patch 05/10] mm/vmalloc.c: fix potential memory leak Andrew Morton
2021-01-12 23:49 ` [patch 06/10] mm: migrate: initialize err in do_migrate_pages Andrew Morton
2021-01-12 23:49 ` [patch 07/10] mm/hugetlb: fix potential missing huge page size info Andrew Morton
2021-01-12 23:49 ` [patch 08/10] MAINTAINERS: add Vlastimil as slab allocators maintainer Andrew Morton
2021-01-12 23:49 ` [patch 09/10] mm,hwpoison: fix printing of page flags Andrew Morton
2021-01-12 23:49 ` [patch 10/10] mm/process_vm_access.c: include compat.h Andrew Morton
2021-01-15 23:32 ` incoming Linus Torvalds

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=20210112234914.NwudbAxXv%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=guo.ziliang@zte.com.cn \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@armlinux.org.uk \
    --cc=liu.hailong6@zte.com.cn \
    --cc=mm-commits@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).