KASan for arm
Subsystems (5)
v6 cover KASan for arm
Hi all,
Abbott submitted a v5 about a year ago here:
and the series was not picked up since then, so I rebased it against v5.2-rc4 and re-tested it on a Brahma-B53 (ARMv8 running AArch32 mode) and Brahma-B15, both LPAE and test-kasan is consistent with the ARM64 counter part.
We were in a fairly good shape last time with a few different people having tested it, so I am hoping we can get that included for 5.4 if everything goes well.
Changelog:
v6 - v5
- Resolve conflicts during rebase, and updated to make use of kasan_early_shadow_pte instead of kasan_zero_pte
v5 - v4
- Modify Andrey Ryabinin's email address.
v4 - v3
- Remove the fix of type conversion in kasan_cache_create because it has been fix in the latest version in:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
- Change some Reviewed-by tag into Reported-by tag to avoid misleading. ---Reported by: Marc Zyngier <[email protected]> Russell King - ARM Linux <[email protected]>
- Disable instrumentation for arch/arm/mm/physaddr.c
v3 - v2
- Remove this patch: 2 1-byte checks more safer for memory_is_poisoned_16 because a unaligned load/store of 16 bytes is rare on arm, and this patch is very likely to affect the performance of modern CPUs. ---Acked by: Russell King - ARM Linux <[email protected]>
- Fixed some link error which kasan_pmd_populate,kasan_pte_populate and kasan_pud_populate are in section .meminit.text but the function kasan_alloc_block which is called by kasan_pmd_populate, kasan_pte_populate and kasan_pud_populate is in section .init.text. So we need change kasan_pmd_populate,kasan_pte_populate and kasan_pud_populate into the section .init.text.
---Reported by: Florian Fainelli <[email protected]>
- Fixed some compile error which caused by the wrong access instruction in arch/arm/kernel/entry-common.S.
---Reported by: kbuild test robot <[email protected]>
- Disable instrumentation for arch/arm/kvm/hyp/*.
---Acked by: Marc Zyngier <[email protected]>
- Update the set of supported architectures in Documentation/dev-tools/kasan.rst.
---Acked by:Dmitry Vyukov <[email protected]>
- The version 2 is tested by:
Florian Fainelli <[email protected]> (compile test)
kbuild test robot <[email protected]> (compile test)
Joel Stanley <[email protected]> (on ASPEED ast2500(ARMv5))
v2 - v1
- Fixed some compiling error which happens on changing kernel compression mode to lzma/xz/lzo/lz4.
---Reported by: Florian Fainelli <[email protected]>,
Russell King - ARM Linux <[email protected]>
- Fixed a compiling error cause by some older arm instruction set(armv4t) don't suppory movw/movt which is reported by kbuild.
- Changed the pte flag from _L_PTE_DEFAULT | L_PTE_DIRTY | L_PTE_XN to pgprot_val(PAGE_KERNEL).
---Reported by: Russell King - ARM Linux <[email protected]>
- Moved Enable KASan patch as the last one.
---Reported by: Florian Fainelli <[email protected]>,
Russell King - ARM Linux <[email protected]>
- Moved the definitions of cp15 registers from arch/arm/include/asm/kvm_hyp.h to arch/arm/include/asm/cp15.h. ---Asked by: Mark Rutland <[email protected]>
- Merge the following commits into the commit
Define the virtual space of KASan's shadow region:
1) Define the virtual space of KASan's shadow region;
2) Avoid cleaning the KASan shadow area's mapping table;
3) Add KASan layout;
- Merge the following commits into the commit
Initialize the mapping of KASan shadow memory:
1) Initialize the mapping of KASan shadow memory;
2) Add support arm LPAE;
3) Don't need to map the shadow of KASan's shadow memory; ---Reported by: Russell King - ARM Linux <[email protected]>
4) Change mapping of kasan_zero_page int readonly.
- The version 1 is tested by Florian Fainelli <[email protected]> on a Cortex-A5 (no LPAE).
Hi,all:
These patches add arch specific code for kernel address sanitizer
(see Documentation/kasan.txt).
1/8 of kernel addresses reserved for shadow memory. There was no
big enough hole for this, so virtual addresses for shadow were stolen from user space.
At early boot stage the whole shadow region populated with just
one physical page (kasan_zero_page). Later, this page reused as readonly zero shadow for some memory that KASan currently don't track (vmalloc).
After mapping the physical memory, pages for shadow memory are
allocated and mapped.
KASan's stack instrumentation significantly increases stack's
consumption, so CONFIG_KASAN doubles THREAD_SIZE.
Functions like memset/memmove/memcpy do a lot of memory accesses.
If bad pointer passed to one of these function it is important to catch this. Compiler's instrumentation cannot do this since these functions are written in assembly.
KASan replaces memory functions with manually instrumented variants.
Original functions declared as weak symbols so strong definitions in mm/kasan/kasan.c could replace them. Original functions have aliases with '__' prefix in name, so we could call non-instrumented variant if needed.
Some files built without kasan instrumentation (e.g. mm/slub.c).
Original mem* function replaced (via #define) with prefixed variants to disable memory access checks for such files.
On arm LPAE architecture, the mapping table of KASan shadow memory(ifPAGE_OFFSET is 0xc0000000, the KASan shadow memory's virtual space is 0xb6e000000~0xbf000000) can't be filled in do_translation_fault function, because kasan instrumentation maybe cause do_translation_fault function accessing KASan shadow memory. The accessing of KASan shadow memory in do_translation_fault function maybe cause dead circle. So the mapping table of KASan shadow memory need be copyed in pgd_alloc function.
Most of the code comes from:
https://github.com/aryabinin/linux/commit/0b54f17e70ff50a902c4af05bb92716eb95acefe
These patches are tested on vexpress-ca15, vexpress-ca9
Abbott Liu (2):
ARM: Add TTBR operator for kasan_init
ARM: Define the virtual space of KASan's shadow region
Andrey Ryabinin (4):
ARM: Disable instrumentation for some code
ARM: Replace memory function for kasan
ARM: Initialize the mapping of KASan shadow memory
ARM: Enable KASan for arm
Documentation/dev-tools/kasan.rst | 4 +- arch/arm/Kconfig | 1 + arch/arm/boot/compressed/Makefile | 1 + arch/arm/boot/compressed/decompress.c | 2 + arch/arm/boot/compressed/libfdt_env.h | 2 + arch/arm/include/asm/cp15.h | 106 +++++++++ arch/arm/include/asm/kasan.h | 35 +++ arch/arm/include/asm/kasan_def.h | 64 ++++++ arch/arm/include/asm/kvm_hyp.h | 54 ----- arch/arm/include/asm/memory.h | 5 + arch/arm/include/asm/pgalloc.h | 7 +- arch/arm/include/asm/string.h | 17 ++ arch/arm/include/asm/thread_info.h | 4 + arch/arm/kernel/entry-armv.S | 5 +- arch/arm/kernel/entry-common.S | 9 +- arch/arm/kernel/head-common.S | 7 +- arch/arm/kernel/setup.c | 2 + arch/arm/kernel/unwind.c | 3 +- arch/arm/kvm/hyp/cp15-sr.c | 12 +- arch/arm/kvm/hyp/switch.c | 6 +- arch/arm/lib/memcpy.S | 3 + arch/arm/lib/memmove.S | 5 +- arch/arm/lib/memset.S | 3 + arch/arm/mm/Makefile | 4 + arch/arm/mm/kasan_init.c | 301 ++++++++++++++++++++++++++ arch/arm/mm/mmu.c | 7 +- arch/arm/mm/pgd.c | 14 ++ arch/arm/vdso/Makefile | 2 + 28 files changed, 608 insertions(+), 77 deletions(-) create mode 100644 arch/arm/include/asm/kasan.h create mode 100644 arch/arm/include/asm/kasan_def.h create mode 100644 arch/arm/mm/kasan_init.c
Signature · 1 line
2.17.1
PATCH v6 1/6 ARM: Add TTBR operator for kasan_init
From: Abbott Liu <[email protected]>
The purpose of this patch is to provide set_ttbr0/get_ttbr0 to kasan_init function. The definitions of cp15 registers should be in arch/arm/include/asm/cp15.h rather than arch/arm/include/asm/kvm_hyp.h, so move them.
--- arch/arm/include/asm/cp15.h | 106 +++++++++++++++++++++++++++++++++ arch/arm/include/asm/kvm_hyp.h | 54 ----------------- arch/arm/kvm/hyp/cp15-sr.c | 12 ++-- arch/arm/kvm/hyp/switch.c | 6 +- 4 files changed, 115 insertions(+), 63 deletions(-)
arch/arm/include/asm/cp15.h +106 -0
@@ -3,6 +3,7 @@#define __ASM_ARM_CP15_H#include <asm/barrier.h> +#include <linux/stringify.h> /* * CR1 bits (CP#15 CR1)
@@ -70,8 +71,113 @@#define CNTVCT __ACCESS_CP15_64(1, c14) +#define TTBR0_32 __ACCESS_CP15(c2, 0, c0, 0) +#define TTBR1_32 __ACCESS_CP15(c2, 0, c0, 1) +#define PAR_32 __ACCESS_CP15(c7, 0, c4, 0) +#define TTBR0_64 __ACCESS_CP15_64(0, c2) +#define TTBR1_64 __ACCESS_CP15_64(1, c2) +#define PAR_64 __ACCESS_CP15_64(0, c7) +#define VTTBR __ACCESS_CP15_64(6, c2) +#define CNTP_CVAL __ACCESS_CP15_64(2, c14) +#define CNTV_CVAL __ACCESS_CP15_64(3, c14) +#define CNTVOFF __ACCESS_CP15_64(4, c14) + +#define MIDR __ACCESS_CP15(c0, 0, c0, 0) +#define CSSELR __ACCESS_CP15(c0, 2, c0, 0) +#define VPIDR __ACCESS_CP15(c0, 4, c0, 0) +#define VMPIDR __ACCESS_CP15(c0, 4, c0, 5) +#define SCTLR __ACCESS_CP15(c1, 0, c0, 0) +#define CPACR __ACCESS_CP15(c1, 0, c0, 2) +#define HCR __ACCESS_CP15(c1, 4, c1, 0) +#define HDCR __ACCESS_CP15(c1, 4, c1, 1) +#define HCPTR __ACCESS_CP15(c1, 4, c1, 2) +#define HSTR __ACCESS_CP15(c1, 4, c1, 3) +#define TTBCR __ACCESS_CP15(c2, 0, c0, 2) +#define HTCR __ACCESS_CP15(c2, 4, c0, 2) +#define VTCR __ACCESS_CP15(c2, 4, c1, 2) +#define DACR __ACCESS_CP15(c3, 0, c0, 0) +#define DFSR __ACCESS_CP15(c5, 0, c0, 0) +#define IFSR __ACCESS_CP15(c5, 0, c0, 1) +#define ADFSR __ACCESS_CP15(c5, 0, c1, 0) +#define AIFSR __ACCESS_CP15(c5, 0, c1, 1) +#define HSR __ACCESS_CP15(c5, 4, c2, 0) +#define DFAR __ACCESS_CP15(c6, 0, c0, 0) +#define IFAR __ACCESS_CP15(c6, 0, c0, 2) +#define HDFAR __ACCESS_CP15(c6, 4, c0, 0) +#define HIFAR __ACCESS_CP15(c6, 4, c0, 2) +#define HPFAR __ACCESS_CP15(c6, 4, c0, 4) +#define ICIALLUIS __ACCESS_CP15(c7, 0, c1, 0) +#define BPIALLIS __ACCESS_CP15(c7, 0, c1, 6) +#define ICIMVAU __ACCESS_CP15(c7, 0, c5, 1) +#define ATS1CPR __ACCESS_CP15(c7, 0, c8, 0) +#define TLBIALLIS __ACCESS_CP15(c8, 0, c3, 0) +#define TLBIALL __ACCESS_CP15(c8, 0, c7, 0) +#define TLBIALLNSNHIS __ACCESS_CP15(c8, 4, c3, 4) +#define PRRR __ACCESS_CP15(c10, 0, c2, 0) +#define NMRR __ACCESS_CP15(c10, 0, c2, 1) +#define AMAIR0 __ACCESS_CP15(c10, 0, c3, 0) +#define AMAIR1 __ACCESS_CP15(c10, 0, c3, 1) +#define VBAR __ACCESS_CP15(c12, 0, c0, 0) +#define CID __ACCESS_CP15(c13, 0, c0, 1) +#define TID_URW __ACCESS_CP15(c13, 0, c0, 2) +#define TID_URO __ACCESS_CP15(c13, 0, c0, 3) +#define TID_PRIV __ACCESS_CP15(c13, 0, c0, 4) +#define HTPIDR __ACCESS_CP15(c13, 4, c0, 2) +#define CNTKCTL __ACCESS_CP15(c14, 0, c1, 0) +#define CNTP_CTL __ACCESS_CP15(c14, 0, c2, 1) +#define CNTV_CTL __ACCESS_CP15(c14, 0, c3, 1) +#define CNTHCTL __ACCESS_CP15(c14, 4, c1, 0) +extern unsigned long cr_alignment;/* defined in entry-armv.S */ +static inline void set_par (u64 val) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +write_sysreg (val,PAR_64 ); +else +write_sysreg (val,PAR_32 ); +} + +static inline u64 get_par (void ) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +return read_sysreg (PAR_64 ); +else +return read_sysreg (PAR_32 ); +} + +static inline void set_ttbr0 (u64 val) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +write_sysreg (val,TTBR0_64 ); +else +write_sysreg (val,TTBR0_32 ); +} + +static inline u64 get_ttbr0 (void ) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +return read_sysreg (TTBR0_64 ); +else +return read_sysreg (TTBR0_32 ); +} + +static inline void set_ttbr1 (u64 val) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +write_sysreg (val,TTBR1_64 ); +else +write_sysreg (val,TTBR1_32 ); +} + +static inline u64 get_ttbr1 (void ) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +return read_sysreg (TTBR1_64 ); +else +return read_sysreg (TTBR1_32 ); +} +static inline unsigned long get_cr (void ) {unsigned long val;
arch/arm/include/asm/kvm_hyp.h +0 -54
60 lines not on this page · raw message
arch/arm/kvm/hyp/cp15-sr.c +6 -6
@@ -30,8 +30,8 @@ void __hyp_text __sysreg_save_state(struct kvm_cpu_context *ctxt) ctxt->cp15[c0_CSSELR] =read_sysreg (CSSELR ); ctxt->cp15[c1_SCTLR] =read_sysreg (SCTLR ); ctxt->cp15[c1_CPACR] =read_sysreg (CPACR ); - *cp15_64 (ctxt, c2_TTBR0) =read_sysreg (TTBR0 ); - *cp15_64 (ctxt, c2_TTBR1) =read_sysreg (TTBR1 ); + *cp15_64 (ctxt, c2_TTBR0) =read_sysreg (TTBR0_64 ); + *cp15_64 (ctxt, c2_TTBR1) =read_sysreg (TTBR1_64 ); ctxt->cp15[c2_TTBCR] =read_sysreg (TTBCR ); ctxt->cp15[c3_DACR] =read_sysreg (DACR ); ctxt->cp15[c5_DFSR] =read_sysreg (DFSR );
@@ -40,7 +40,7 @@ void __hyp_text __sysreg_save_state(struct kvm_cpu_context *ctxt) ctxt->cp15[c5_AIFSR] =read_sysreg (AIFSR ); ctxt->cp15[c6_DFAR] =read_sysreg (DFAR ); ctxt->cp15[c6_IFAR] =read_sysreg (IFAR ); - *cp15_64 (ctxt, c7_PAR) =read_sysreg (PAR ); + *cp15_64 (ctxt, c7_PAR) =read_sysreg (PAR_64 ); ctxt->cp15[c10_PRRR] =read_sysreg (PRRR ); ctxt->cp15[c10_NMRR] =read_sysreg (NMRR ); ctxt->cp15[c10_AMAIR0] =read_sysreg (AMAIR0 );
@@ -59,8 +59,8 @@ void __hyp_text __sysreg_restore_state(struct kvm_cpu_context *ctxt)write_sysreg (ctxt->cp15[c0_CSSELR],CSSELR );write_sysreg (ctxt->cp15[c1_SCTLR],SCTLR );write_sysreg (ctxt->cp15[c1_CPACR],CPACR ); -write_sysreg (*cp15_64 (ctxt, c2_TTBR0),TTBR0 ); -write_sysreg (*cp15_64 (ctxt, c2_TTBR1),TTBR1 ); +write_sysreg (*cp15_64 (ctxt, c2_TTBR0),TTBR0_64 ); +write_sysreg (*cp15_64 (ctxt, c2_TTBR1),TTBR1_64 );write_sysreg (ctxt->cp15[c2_TTBCR],TTBCR );write_sysreg (ctxt->cp15[c3_DACR],DACR );write_sysreg (ctxt->cp15[c5_DFSR],DFSR );
@@ -69,7 +69,7 @@ void __hyp_text __sysreg_restore_state(struct kvm_cpu_context *ctxt)write_sysreg (ctxt->cp15[c5_AIFSR],AIFSR );write_sysreg (ctxt->cp15[c6_DFAR],DFAR );write_sysreg (ctxt->cp15[c6_IFAR],IFAR ); -write_sysreg (*cp15_64 (ctxt, c7_PAR),PAR ); +write_sysreg (*cp15_64 (ctxt, c7_PAR),PAR_64 );write_sysreg (ctxt->cp15[c10_PRRR],PRRR );write_sysreg (ctxt->cp15[c10_NMRR],NMRR );write_sysreg (ctxt->cp15[c10_AMAIR0],AMAIR0 );
arch/arm/kvm/hyp/switch.c +3 -3
@@ -134,12 +134,12 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)if (!(hsr &HSR_DABT_S1PTW ) && (hsr &HSR_FSC_TYPE ) ==FSC_PERM ) {u64 par, tmp; - par =read_sysreg (PAR ); + par =read_sysreg (PAR_64 );write_sysreg (far,ATS1CPR );isb (); - tmp =read_sysreg (PAR ); -write_sysreg (par,PAR ); + tmp =read_sysreg (PAR_64 ); +write_sysreg (par,PAR_64 );if (unlikely (tmp &1 ))return false;/* Translation failed, back to guest */
Signature · 1 line
2.17.1
PATCH v6 2/6 ARM: Disable instrumentation for some code
In reply to Florian FainelliFrom: Andrey Ryabinin <[email protected]>
Disable instrumentation for arch/arm/boot/compressed/* and arch/arm/vdso/* because those code won't linkd with kernel image.
Disable instrumentation for arch/arm/kvm/hyp/*. See commit a6cdf1c08cbf ("kvm: arm64: Disable compiler instrumentation for hypervisor code") for more details.
Disable instrumentation for arch/arm/mm/physaddr.c. See commit ec6d06efb0ba ("arm64: Add support for CONFIG_DEBUG_VIRTUAL") for more details.
Disable kasan check in the function unwind_pop_register because it doesn't matter that kasan checks failed when unwind_pop_register read stack memory of task.
--- arch/arm/boot/compressed/Makefile | 1 + arch/arm/kernel/unwind.c | 3 ++- arch/arm/mm/Makefile | 1 + arch/arm/vdso/Makefile | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/boot/compressed/Makefile +1 -0
@@ -24,6 +24,7 @@ OBJS += hyp-stub.o endif GCOV_PROFILE := n +KASAN_SANITIZE := n # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n
arch/arm/kernel/unwind.c +2 -1
@@ -236,7 +236,8 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl,if (*vsp >= (unsigned long *)ctrl->sp_high)return -URC_FAILURE ; - ctrl->vrs[reg] = *(*vsp)++; + ctrl->vrs[reg] =READ_ONCE_NOCHECK (*(*vsp)); + (*vsp)++;return URC_OK ; }
arch/arm/mm/Makefile +1 -0
@@ -16,6 +16,7 @@ endif obj-$(CONFIG_ARM_PTDUMP_CORE) += dump.o obj-$(CONFIG_ARM_PTDUMP_DEBUGFS) += ptdump_debugfs.o obj-$(CONFIG_MODULES) += proc-syms.o +KASAN_SANITIZE_physaddr.o := n obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o
arch/arm/vdso/Makefile +2 -0
@@ -33,6 +33,8 @@ GCOV_PROFILE := n # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n +KASAN_SANITIZE := n + # Force dependency $(obj)/vdso.o : $(obj)/vdso.so
Signature · 1 line
2.17.1
PATCH v6 3/6 ARM: Replace memory function for kasan
In reply to Florian FainelliFrom: Andrey Ryabinin <[email protected]>
Functions like memset/memmove/memcpy do a lot of memory accesses. If bad pointer passed to one of these function it is important to catch this. Compiler's instrumentation cannot do this since these functions are written in assembly.
KASan replaces memory functions with manually instrumented variants. Original functions declared as weak symbols so strong definitions in mm/kasan/kasan.c could replace them. Original functions have aliases with '__' prefix in name, so we could call non-instrumented variant if needed.
We must use __memcpy/__memset to replace memcpy/memset when we copy .data to RAM and when we clear .bss, because kasan_early_init can't be called before the initialization of .data and .bss.
--- arch/arm/boot/compressed/decompress.c | 2 ++ arch/arm/boot/compressed/libfdt_env.h | 2 ++ arch/arm/include/asm/string.h | 17 +++++++++++++++++ arch/arm/kernel/head-common.S | 4 ++-- arch/arm/lib/memcpy.S | 3 +++ arch/arm/lib/memmove.S | 5 ++++- arch/arm/lib/memset.S | 3 +++ 7 files changed, 33 insertions(+), 3 deletions(-)
arch/arm/boot/compressed/decompress.c +2 -0
@@ -47,8 +47,10 @@ extern char * strchrnul(const char *, int);#endif #ifdef CONFIG_KERNEL_XZ +#ifndef CONFIG_KASAN #define memmove memmove#define memcpy memcpy +#endif #include "../../../../lib/decompress_unxz.c" #endif
arch/arm/boot/compressed/libfdt_env.h +2 -0
@@ -19,4 +19,6 @@ typedef __be64 fdt64_t;#define fdt64_to_cpu (x) be64_to_cpu(x)#define cpu_to_fdt64 (x) cpu_to_be64(x) +#undef memset +#endif
arch/arm/include/asm/string.h +17 -0
@@ -15,15 +15,18 @@ extern char * strchr(const char * s, int c);#define __HAVE_ARCH_MEMCPYextern void *memcpy (void *,const void *,__kernel_size_t ); +extern void *__memcpy (void *dest,const void *src,__kernel_size_t n);#define __HAVE_ARCH_MEMMOVEextern void *memmove (void *,const void *,__kernel_size_t ); +extern void *__memmove (void *dest,const void *src,__kernel_size_t n);#define __HAVE_ARCH_MEMCHRextern void *memchr (const void *,int ,__kernel_size_t );#define __HAVE_ARCH_MEMSETextern void *memset (void *,int ,__kernel_size_t ); +extern void *__memset (void *s,int c,__kernel_size_t n);#define __HAVE_ARCH_MEMSET32extern void *__memset32 (uint32_t *,uint32_t v,__kernel_size_t );
@@ -39,4 +42,18 @@ static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n) return __memset64(p, v, n * 8, v >> 32); } + + +#if defined(CONFIG_KASAN ) && !defined(__SANITIZE_ADDRESS__) + +/* +* For files that not instrumented (e.g. mm/slub.c) we +* should use not instrumented version of mem* functions. +*/ + +#define memcpy (dst, src, len) __memcpy(dst, src, len) +#define memmove (dst, src, len) __memmove(dst, src, len) +#define memset (s, c, n) __memset(s, c, n) +#endif +#endif
arch/arm/kernel/head-common.S +2 -2
@@ -99,7 +99,7 @@ __mmap_switched: THUMB( ldmia r4!, {r0, r1, r2, r3} ) THUMB( mov sp, r3 ) sub r2, r2, r1 - bl memcpy @ copy .data to RAM + bl __memcpy @ copy .data to RAM #endif ARM( ldmia r4!, {r0, r1, sp} )
@@ -107,7 +107,7 @@ __mmap_switched: THUMB( mov sp, r3 ) sub r2, r1, r0 mov r1, #0 - bl memset @ clear .bss + bl __memset @ clear .bss ldmia r4, {r0, r1, r2, r3} str r9, [r0] @ Save processor ID
arch/arm/lib/memcpy.S +3 -0
@@ -61,6 +61,8 @@ /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ +.weak memcpy +ENTRY(__memcpy) ENTRY(mmiocpy) ENTRY(memcpy)
@@ -68,3 +70,4 @@ ENTRY(memcpy) ENDPROC(memcpy) ENDPROC(mmiocpy) +ENDPROC(__memcpy)
arch/arm/lib/memmove.S +4 -1
@@ -27,12 +27,14 @@ * occurring in the opposite direction. */ +.weak memmove +ENTRY(__memmove) ENTRY(memmove) UNWIND( .fnstart ) subs ip, r0, r1 cmphi r2, ip - bls memcpy + bls __memcpy stmfd sp!, {r0, r4, lr} UNWIND( .fnend )
@@ -225,3 +227,4 @@ ENTRY(memmove) 18: backward_copy_shift push=24 pull=8 ENDPROC(memmove) +ENDPROC(__memmove)
arch/arm/lib/memset.S +3 -0
@@ -16,6 +16,8 @@ .text .align 5 +.weak memset +ENTRY(__memset) ENTRY(mmioset) ENTRY(memset) UNWIND( .fnstart )
@@ -135,6 +137,7 @@ UNWIND( .fnstart ) UNWIND( .fnend ) ENDPROC(memset) ENDPROC(mmioset) +ENDPROC(__memset) ENTRY(__memset32) UNWIND( .fnstart )
Signature · 6 lines
2.17.1 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v6 5/6 ARM: Initialize the mapping of KASan shadow memory
In reply to Florian FainelliFrom: Andrey Ryabinin <[email protected]>
This patch initializes KASan shadow region's page table and memory. There are two stage for KASan initializing:
1. At early boot stage the whole shadow region is mapped to just one physical page (kasan_zero_page). It's finished by the function kasan_early_init which is called by __mmap_switched(arch/arm/kernel/ head-common.S)
---Andrey Ryabinin <[email protected]>
2. After the calling of paging_init, we use kasan_zero_page as zero shadow for some memory that KASan don't need to track, and we alloc new shadow space for the other memory that KASan need to track. These issues are finished by the function kasan_init which is call by setup_arch.
---Andrey Ryabinin <[email protected]>
3. Add support arm LPAE
If LPAE is enabled, KASan shadow region's mapping table need be copyed in pgd_alloc function.
---Abbott Liu <[email protected]>
4. Change kasan_pte_populate,kasan_pmd_populate,kasan_pud_populate, kasan_pgd_populate from .meminit.text section to .init.text section. ---Reported by: Florian Fainelli <[email protected]> ---Signed off by: Abbott Liu <[email protected]>
--- arch/arm/include/asm/kasan.h | 35 ++++ arch/arm/include/asm/pgalloc.h | 7 +- arch/arm/include/asm/thread_info.h | 4 + arch/arm/kernel/head-common.S | 3 + arch/arm/kernel/setup.c | 2 + arch/arm/mm/Makefile | 3 + arch/arm/mm/kasan_init.c | 301 +++++++++++++++++++++++++++++ arch/arm/mm/pgd.c | 14 ++ 8 files changed, 367 insertions(+), 2 deletions(-) create mode 100644 arch/arm/include/asm/kasan.h create mode 100644 arch/arm/mm/kasan_init.c
arch/arm/include/asm/kasan.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* arch/arm/include/asm/kasan.h +* +* Copyright (c) 2015 Samsung Electronics Co., Ltd. +* Author: Andrey Ryabinin <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +*/ + +#ifndef __ASM_KASAN_H +#define __ASM_KASAN_H + +#ifdef CONFIG_KASAN + +#include <asm/kasan_def.h> + +#define KASAN_SHADOW_SCALE_SHIFT 3 + +/* +* Compiler uses shadow offset assuming that addresses start +* from 0. Kernel addresses don't start from 0, so shadow +* for kernel really starts from 'compiler's shadow offset' + +* ('kernel address space start' >> KASAN_SHADOW_SCALE_SHIFT) +*/ + +extern void kasan_init (void ); + +#else +static inline void kasan_init (void ) { } +#endif + +#endif
arch/arm/include/asm/pgalloc.h +5 -2
@@ -50,8 +50,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)*/ #define pmd_alloc_one (mm,addr) ({ BUG(); ((pmd_t *)2); })#define pmd_free (mm, pmd) do { } while (0) -#define pud_populate (mm,pmd,pte) BUG() - +#ifndef CONFIG_KASAN +#define pud_populate (mm, pmd, pte) BUG() +#else +#define pud_populate (mm, pmd, pte) do { } while (0) +#endif #endif /* CONFIG_ARM_LPAE */ extern pgd_t *pgd_alloc (struct mm_struct *mm);
arch/arm/include/asm/thread_info.h +4 -0
@@ -16,7 +16,11 @@#include <asm/fpstate.h> #include <asm/page.h> +#ifdef CONFIG_KASAN +#define THREAD_SIZE_ORDER 2 +#else #define THREAD_SIZE_ORDER 1 +#endif #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)#define THREAD_START_SP (THREAD_SIZE - 8)
arch/arm/kernel/head-common.S +3 -0
@@ -115,6 +115,9 @@ __mmap_switched: str r8, [r2] @ Save atags pointer cmp r3, #0 strne r10, [r3] @ Save control register values +#ifdef CONFIG_KASAN + bl kasan_early_init +#endif mov lr, #0 b start_kernel ENDPROC(__mmap_switched)
arch/arm/kernel/setup.c +2 -0
@@ -61,6 +61,7 @@#include <asm/unwind.h> #include <asm/memblock.h> #include <asm/virt.h> +#include <asm/kasan.h> #include "atags.h"
@@ -1133,6 +1134,7 @@ void __init setup_arch(char **cmdline_p)early_ioremap_reset ();paging_init (mdesc); +kasan_init ();request_standard_resources (mdesc);if (mdesc->restart)
arch/arm/mm/Makefile +3 -0
@@ -112,3 +112,6 @@ obj-$(CONFIG_CACHE_L2X0_PMU) += cache-l2x0-pmu.o obj-$(CONFIG_CACHE_XSC3L2) += cache-xsc3l2.o obj-$(CONFIG_CACHE_TAUROS2) += cache-tauros2.o obj-$(CONFIG_CACHE_UNIPHIER) += cache-uniphier.o + +KASAN_SANITIZE_kasan_init.o := n +obj-$(CONFIG_KASAN) += kasan_init.o
arch/arm/mm/kasan_init.c new file +301 -0
301 lines not on this page · raw message
arch/arm/mm/pgd.c +14 -0
@@ -64,6 +64,20 @@ pgd_t *pgd_alloc(struct mm_struct *mm) new_pmd =pmd_alloc (mm, new_pud,0 );if (!new_pmd) goto no_pmd; +#ifdef CONFIG_KASAN +/* +*Copy PMD table for KASAN shadow mappings. +*/ + init_pgd =pgd_offset_k (TASK_SIZE ); + init_pud =pud_offset (init_pgd,TASK_SIZE ); + init_pmd =pmd_offset (init_pud,TASK_SIZE ); + new_pmd =pmd_offset (new_pud,TASK_SIZE ); +memcpy (new_pmd, init_pmd, + (pmd_index (MODULES_VADDR )-pmd_index (TASK_SIZE )) + *sizeof (pmd_t)); +clean_dcache_area (new_pmd,PTRS_PER_PMD *sizeof (pmd_t)); +#endif +#endif if (!vectors_high ()) {
Signature · 6 lines
2.17.1 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v6 6/6 ARM: Enable KASan for arm
In reply to Florian FainelliFrom: Andrey Ryabinin <[email protected]>
This patch enable kernel address sanitizer for ARM.
--- Documentation/dev-tools/kasan.rst | 4 ++-- arch/arm/Kconfig | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
Documentation/dev-tools/kasan.rst +2 -2
@@ -21,8 +21,8 @@ global variables yet. Tag-based KASAN is only supported in Clang and requires version 7.0.0 or later. -Currently generic KASAN is supported for the x86_64, arm64, xtensa and s390 -architectures, and tag-based KASAN is supported only for arm64. +Currently generic KASAN is supported for the x86_64, arm, arm64, xtensa and +s390 architectures, and tag-based KASAN is supported only for arm64. Usage -----
arch/arm/Kconfig +1 -0
@@ -59,6 +59,7 @@ config ARM select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU + select HAVE_ARCH_KASAN if MMU select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_SECCOMP_FILTER if AEABI && !OABI_COMPAT select HAVE_ARCH_THREAD_STRUCT_WHITELIST
Signature · 6 lines
2.17.1 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH v6 4/6 ARM: Define the virtual space of KASan's shadow region
In reply to Florian FainelliFrom: Abbott Liu <[email protected]>
Define KASAN_SHADOW_OFFSET,KASAN_SHADOW_START and KASAN_SHADOW_END for arm kernel address sanitizer.
+----+ 0xffffffff
| |
| |
| |
+----+ CONFIG_PAGE_OFFSET
| | | | |-> module virtual address space area.
| |/
+----+ MODULE_VADDR = KASAN_SHADOW_END
| | | | |-> the shadow area of kernel virtual address.
| |/
+----+ TASK_SIZE(start of kernel space) = KASAN_SHADOW_START the
| |\ shadow address of MODULE_VADDR
| | ---------------------+
| | |
+ + KASAN_SHADOW_OFFSET |-> the user space area. Kernel address
| | | sanitizer do not use this space.
| | ---------------------+
| |/
------ 01)KASAN_SHADOW_OFFSET:
This value is used to map an address to the corresponding shadow
address by the following formula:shadow_addr = (address >> 3) + KASAN_SHADOW_OFFSET;
2)KASAN_SHADOW_START
This value is the MODULE_VADDR's shadow address. It is the start
of kernel virtual space.
3)KASAN_SHADOW_END
This value is the 0x100000000's shadow address. It is the end of
kernel addresssanitizer's shadow area. It is also the start of the module area.
When enable kasan, the definition of TASK_SIZE is not an an 8-bit rotated constant, so we need to modify the TASK_SIZE access code in the *.s file.
--- arch/arm/include/asm/kasan_def.h | 64 ++++++++++++++++++++++++++++++++ arch/arm/include/asm/memory.h | 5 +++ arch/arm/kernel/entry-armv.S | 5 ++- arch/arm/kernel/entry-common.S | 9 +++-- arch/arm/mm/mmu.c | 7 +++- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 arch/arm/include/asm/kasan_def.h
arch/arm/include/asm/kasan_def.h new file +64 -0
@@ -0,0 +1,64 @@ +/* +* arch/arm/include/asm/kasan_def.h +* +* Copyright (c) 2018 Huawei Technologies Co., Ltd. +* +* Author: Abbott Liu <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __ASM_KASAN_DEF_H +#define __ASM_KASAN_DEF_H + +#ifdef CONFIG_KASAN + +/* +* +----+ 0xffffffff +* | | +* | | +* | | +* +----+ CONFIG_PAGE_OFFSET +* | |\ +* | | |-> module virtual address space area. +* | |/ +* +----+ MODULE_VADDR = KASAN_SHADOW_END +* | |\ +* | | |-> the shadow area of kernel virtual address. +* | |/ +* +----+ TASK_SIZE(start of kernel space) = KASAN_SHADOW_START the +* | |\ shadow address of MODULE_VADDR +* | | ---------------------+ +* | | | +* + + KASAN_SHADOW_OFFSET |-> the user space area. Kernel address +* | | | sanitizer do not use this space. +* | | ---------------------+ +* | |/ +* ------ 0 +* +*1)KASAN_SHADOW_OFFSET: +* This value is used to map an address to the corresponding shadow +* address by the following formula: +* shadow_addr = (address >> 3) + KASAN_SHADOW_OFFSET; +* +* 2)KASAN_SHADOW_START +* This value is the MODULE_VADDR's shadow address. It is the start +* of kernel virtual space. +* +* 3) KASAN_SHADOW_END +* This value is the 0x100000000's shadow address. It is the end of +* kernel addresssanitizer's shadow area. It is also the start of the +* module area. +* +*/ + +#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1<<29)) + +#define KASAN_SHADOW_START ((KASAN_SHADOW_END >> 3) + KASAN_SHADOW_OFFSET) + +#define KASAN_SHADOW_END (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) + +#endif +#endif
arch/arm/include/asm/memory.h +5 -0
@@ -21,6 +21,7 @@#ifdef CONFIG_NEED_MACH_MEMORY_H #include <mach/memory.h> #endif +#include <asm/kasan_def.h> /* PAGE_OFFSET - the virtual address of the start of the kernel image */ #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
@@ -31,7 +32,11 @@* TASK_SIZE - the maximum size of a user space task. * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area */ +#ifndef CONFIG_KASAN #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) +#else +#define TASK_SIZE (KASAN_SHADOW_START) +#endif #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M)/*
arch/arm/kernel/entry-armv.S +3 -2
@@ -183,7 +183,7 @@ ENDPROC(__und_invalid) get_thread_info tsk ldr r0, [tsk, #TI_ADDR_LIMIT] - mov r1, #TASK_SIZE + ldr r1, =TASK_SIZE str r1, [tsk, #TI_ADDR_LIMIT] str r0, [sp, #SVC_ADDR_LIMIT]
@@ -437,7 +437,8 @@ ENDPROC(__fiq_abt) @ if it was interrupted in a critical region. Here we @ perform a quick test inline since it should be false @ 99.9999% of the time. The rest is done out of line. - cmp r4, #TASK_SIZE + ldr r0, =TASK_SIZE + cmp r4, r0 blhs kuser_cmpxchg64_fixup #endif #endif
arch/arm/kernel/entry-common.S +6 -3
@@ -53,7 +53,8 @@ __ret_fast_syscall: UNWIND(.cantunwind ) disable_irq_notrace @ disable interrupts ldr r2, [tsk, #TI_ADDR_LIMIT] - cmp r2, #TASK_SIZE + ldr r1, =TASK_SIZE + cmp r2, r1 blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
@@ -90,7 +91,8 @@ __ret_fast_syscall: #endif disable_irq_notrace @ disable interrupts ldr r2, [tsk, #TI_ADDR_LIMIT] - cmp r2, #TASK_SIZE + ldr r1, =TASK_SIZE + cmp r2, r1 blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
@@ -131,7 +133,8 @@ ret_slow_syscall: disable_irq_notrace @ disable interrupts ENTRY(ret_to_user_from_irq) ldr r2, [tsk, #TI_ADDR_LIMIT] - cmp r2, #TASK_SIZE + ldr r1, =TASK_SIZE + cmp r2, r1 blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] tst r1, #_TIF_WORK_MASK
arch/arm/mm/mmu.c +6 -1
@@ -1256,9 +1256,14 @@ static inline void prepare_page_table(void)/* * Clear out all the mappings below the kernel image. */ -for (addr =0 ; addr <MODULES_VADDR ; addr +=PMD_SIZE ) +for (addr =0 ; addr <TASK_SIZE ; addr +=PMD_SIZE )pmd_clear (pmd_off_k (addr)); +#ifdef CONFIG_KASAN +/*TASK_SIZE ~ MODULES_VADDR is the KASAN's shadow area -- skip over it*/ + addr =MODULES_VADDR ; +#endif +#ifdef CONFIG_XIP_KERNEL /* The XIP kernel is mapped in the module area -- skip over it */ addr = ((unsigned long )_exiprom +PMD_SIZE -1 ) &PMD_MASK ;
Signature · 1 line
2.17.1
Re: [PATCH v6 1/6] ARM: Add TTBR operator for kasan_init
In reply to Florian FainelliHi Florian!
thanks for your patch!
Quoted 7 lines · Florian Fainelli
From: Abbott Liu <[email protected]>
The purpose of this patch is to provide set_ttbr0/get_ttbr0 to
kasan_initfunction. The definitions of cp15 registers should be inarch/arm/include/asm/cp15.hrather thanarch/arm/include/asm/kvm_hyp.h, so move them.
Quoted 6 lines
Cc Andrey Ryabinin <[email protected]>Reported-by Marc Zyngier <[email protected]>Signed-off-by Abbott Liu <[email protected]>Signed-off-by Florian Fainelli <[email protected]>+#include <
linux/stringify.h>
What is this for? I think it can be dropped.
This stuff adding a whole bunch of accessors:
arch/arm/include/asm/cp15.h line 139
Quoted 7 lines
arch/arm/include/asm/cp15.h +7
-0+static inline void set_par (u64 val) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +write_sysreg (val,PAR_64 ); +else +write_sysreg (val,PAR_32 ); +}
Can we put that in a separate patch since it is not adding any users, so this is a pure refactoring patch for the current code?
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Florian,
Quoted 10 lines · Florian Fainelli
Abbott submitted a v5 about a year ago here:
and the series was not picked up since then, so I rebased it against v5.2-rc4 and re-tested it on a Brahma-B53 (ARMv8 running AArch32 mode) and Brahma-B15, both LPAE and test-kasan is consistent with the ARM64 counter part.
We were in a fairly good shape last time with a few different people having tested it, so I am hoping we can get that included for 5.4 if everything goes well.
Thanks for picking this up. I was trying out KASan in the past, got sidetracked and honestly lost interest a bit because it was boring. But I do realize that it is really neat, so I will try to help out with some review and test on a bunch of hardware I have.
At one point I even had this running on the ARMv4 SA1100 (no joke!) and if I recall correctly, I got stuck because of things that might very well have been related to using a very fragile Arm testchip that later broke down completely in the l2cache when we added the spectre/meltdown fixes.
I start reviewing and testing.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v6 2/6] ARM: Disable instrumentation for some code
In reply to Florian Fainelliarch/arm/kernel/unwind.c static int unwind_pop_register(struct unwind_ctrl_block *ctrl, · line 240
Quoted 7 lines · Florian Fainelli
arch/arm/kernel/unwind.c +2
-1@@ -236,7 +236,8 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl,if (*vsp >= (unsigned long *)ctrl->sp_high)return -URC_FAILURE ; - ctrl->vrs[reg] = *(*vsp)++; + ctrl->vrs[reg] =READ_ONCE_NOCHECK (*(*vsp)); + (*vsp)++;
I would probably even put in a comment here so it is clear why we do this. Passers-by may not know that READ_ONCE_NOCHECK() is even related to KASan.
Other than that,
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v6 2/6] ARM: Disable instrumentation for some code
Quoted 6 lines · Linus Walleij
Quoted 4 lines · Florian Fainelli
arch/arm/kernel/unwind.c +0
-0@@ -236,7 +236,8 @@ static int unwind_pop_register(struct unwind_ctrl_block *ctrl,if (*vsp >= (unsigned long *)ctrl->sp_high)return -URC_FAILURE ;
Quoted 7 lines
arch/arm/kernel/unwind.c static int unwind_pop_register(struct unwind_ctrl_block *ctrl, · line 240
Quoted 3 lines
arch/arm/kernel/unwind.c +2
-1- ctrl->vrs[reg] = *(*vsp)++; + ctrl->vrs[reg] =READ_ONCE_NOCHECK (*(*vsp)); + (*vsp)++;I would probably even put in a comment here so it is clear why we do this. Passers-by may not know that
READ_ONCE_NOCHECK()is even related to KASan.
Makes sense, I will add that, thanks!
Quoted 7 lines
Other than that,
Reviewed-by Linus Walleij <[email protected]>Yours,
Linus Walleij
Signature · 1 line
Florian
Re: [PATCH v6 1/6] ARM: Add TTBR operator for kasan_init
In reply to Linus WalleijQuoted 13 lines · Linus Walleij
Hi Florian!
thanks for your patch!
Quoted 7 lines · Florian Fainelli
From: Abbott Liu <[email protected]>
The purpose of this patch is to provide set_ttbr0/get_ttbr0 to
kasan_initfunction. The definitions of cp15 registers should be inarch/arm/include/asm/cp15.hrather thanarch/arm/include/asm/kvm_hyp.h, so move them.
Quoted 8 lines
Quoted 6 lines
Cc Andrey Ryabinin <[email protected]>Reported-by Marc Zyngier <[email protected]>Signed-off-by Abbott Liu <[email protected]>Signed-off-by Florian Fainelli <[email protected]>+#include <
linux/stringify.h>What is this for? I think it can be dropped.
Indeed, that can be dropped came from an earlier version of the patch.
Quoted 14 lines
This stuff adding a whole bunch of accessors:
arch/arm/include/asm/cp15.h line 139
Quoted 7 lines
arch/arm/include/asm/cp15.h +7
-0+static inline void set_par (u64 val) +{ +if (IS_ENABLED (CONFIG_ARM_LPAE )) +write_sysreg (val,PAR_64 ); +else +write_sysreg (val,PAR_32 ); +}Can we put that in a separate patch since it is not adding any users, so this is a pure refactoring patch for the current code?
Sure, that makes sense, first move all definitions, then add helper functions, finally make use of them.
Signature · 1 line
Florian
Quoted 20 lines · Linus Walleij
Hi Florian,
Quoted 10 lines · Florian Fainelli
Abbott submitted a v5 about a year ago here:
and the series was not picked up since then, so I rebased it against v5.2-rc4 and re-tested it on a Brahma-B53 (ARMv8 running AArch32 mode) and Brahma-B15, both LPAE and test-kasan is consistent with the ARM64 counter part.
We were in a fairly good shape last time with a few different people having tested it, so I am hoping we can get that included for 5.4 if everything goes well.
Thanks for picking this up. I was trying out KASan in the past, got sidetracked and honestly lost interest a bit because it was boring. But I do realize that it is really neat, so I will try to help out with some review and test on a bunch of hardware I have.
Quoted 5 lines
At one point I even had this running on the ARMv4 SA1100 (no joke!) and if I recall correctly, I got stuck because of things that might very well have been related to using a very fragile Arm testchip that later broke down completely in the l2cache when we added the spectre/meltdown fixes.
A blast from the past!
Quoted 2 lines
I start reviewing and testing.
Great, thanks a lot for taking a look. FYI, I will be on holiday from July 19th till August 12th, if you think you have more feedback between now and then, I can try to pick it up and submit a v7 with that feedback addressed, or it will happen when I return, or you can pick it up if you refer, all options are possible!
@Arnd, should we squash your patches in as well?
Signature · 1 line
Florian
Quoted 10 lines · Florian Fainelli
On 7/2/19 2:06 PM, Linus Walleij wrote:
Great, thanks a lot for taking a look. FYI, I will be on holiday from July 19th till August 12th, if you think you have more feedback between now and then, I can try to pick it up and submit a v7 with that feedback addressed, or it will happen when I return, or you can pick it up if you refer, all options are possible!
@Arnd, should we squash your patches in as well?
Yes, please do. I don't remember if I sent you all of them already, here is the list of patches that I have applied locally on top of your series to get a clean randconfig build:
123c3262f872 KASAN: push back KASAN_STACK to clang-10 d63dd9e2afd9 [HACK] ARM: disable KASAN+XIP_KERNEL 879eb3c22240 kasan: increase 32-bit stack frame warning limit 053555034bdf kasan: disable CONFIG_KASAN_STACK with clang on arm32 6c1a78a448c2 ARM: fix kasan link failures
Arnd
Quoted 11 lines · Arnd Bergmann
Quoted 9 lines · Florian Fainelli
On 7/2/19 2:06 PM, Linus Walleij wrote:
Great, thanks a lot for taking a look. FYI, I will be on holiday from July 19th till August 12th, if you think you have more feedback between now and then, I can try to pick it up and submit a v7 with that feedback addressed, or it will happen when I return, or you can pick it up if you refer, all options are possible!
Quoted 7 lines
Quoted 1 line
@Arnd, should we squash your patches in as well?
Yes, please do. I don't remember if I sent you all of them already, here is the list of patches that I have applied locally on top of your series to get a clean randconfig build:
123c3262f872KASAN: push backKASAN_STACKto clang-10
This one seems to have received some feedback, not sure if it was addressed or not in a subsequent patch?
Quoted 1 line
d63dd9e2afd9[HACK] ARM: disable KASAN+XIP_KERNEL
That one has been squashed, we could always lift the XIP_KERNEL restriction later once someone with suitable hardware confirms it works.
Quoted 1 line
879eb3c22240kasan: increase 32-bit stack frame warning limit
That one should be pushed separately.
Quoted 1 line
053555034bdfkasan: disableCONFIG_KASAN_STACKwith clang on arm32
This one I did not take based on Linus' feedback that is breaks booting on his RealView board.
Quoted 1 line
6c1a78a448c2ARM: fix kasan link failures
This one was squashed relevant and will be sent out as v7.
Signature · 5 lines
Florian _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 15 lines · Florian Fainelli
Quoted 13 lines · Arnd Bergmann
Quoted 10 lines · Florian Fainelli
On 7/2/19 2:06 PM, Linus Walleij wrote:
Great, thanks a lot for taking a look. FYI, I will be on holiday from July 19th till August 12th, if you think you have more feedback between now and then, I can try to pick it up and submit a v7 with that feedback addressed, or it will happen when I return, or you can pick it up if you refer, all options are possible!
@Arnd, should we squash your patches in as well?
Quoted 8 lines
Quoted 5 lines
Yes, please do. I don't remember if I sent you all of them already, here is the list of patches that I have applied locally on top of your series to get a clean randconfig build:
123c3262f872KASAN: push backKASAN_STACKto clang-10This one seems to have received some feedback, not sure if it was addressed or not in a subsequent patch?
ebb6d35a74ce ("kasan: remove clang version check for KASAN_STACK")
got applied, it seems clang will remain broken with KASAN_STACK for a while.
Quoted 4 lines
Quoted 1 line
053555034bdfkasan: disableCONFIG_KASAN_STACKwith clang on arm32This one I did not take based on Linus' feedback that is breaks booting on his RealView board.
That likely means that there is still a bigger problem somewhere.
Arnd
Quoted 8 lines · Arnd Bergmann
Quoted 4 lines · Florian Fainelli
Quoted 1 line
053555034bdfkasan: disableCONFIG_KASAN_STACKwith clang on arm32This one I did not take based on Linus' feedback that is breaks booting on his RealView board.
That likely means that there is still a bigger problem somewhere.
I will try to look into it. I got pretty puzzled by this, it makes no sense.
One possible problem is that some of the test chips on the RealViews are not that stable, especially with caches. The plan is to test in QEMU and hardware in parallel.
Yours,
Linus Walleij
Hi Florian,
first of all, many thanks for your work on this series =) I picked your and Arnd patches to make it compilable. Now it's compiling but my imx6q board didn't boot anymore. I debugged the code and found that the branch to 'start_kernel' won't be reached
8<------- arch/arm/kernel/head-common.S -------
....
#ifdef CONFIG_KASAN
bl kasan_early_init
#endif
mov lr, #0
b start_kernelENDPROC(__mmap_switched)
....
8<----------------------------------------------
Now, I found also that 'KASAN_SHADOW_OFFSET' isn't set due to missing 'CONFIG_KASAN_SHADOW_OFFSET' and so no '-fasan-shadow-offset=xxxxx' is added. Can that be the reason why my board isn't booted anymore?
Thanks for your reply.
Regards,
Marco
Quoted 187 lines · Florian Fainelli
Hi all,
Abbott submitted a v5 about a year ago here:
and the series was not picked up since then, so I rebased it against v5.2-rc4 and re-tested it on a Brahma-B53 (ARMv8 running AArch32 mode) and Brahma-B15, both LPAE and test-kasan is consistent with the ARM64 counter part.
We were in a fairly good shape last time with a few different people having tested it, so I am hoping we can get that included for 5.4 if everything goes well.
Changelog:
v6 - v5
- Resolve conflicts during rebase, and updated to make use ofkasan_early_shadow_pteinstead ofkasan_zero_ptev5 - v4
- Modify Andrey Ryabinin's email address.v4 - v3
- Remove the fix of type conversion inkasan_cache_createbecause it has been fix in the latest version in:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
- Change some Reviewed-by tag into Reported-by tag to avoid misleading. ---Reported by: Marc Zyngier <[email protected]> Russell King - ARM Linux <[email protected]>
- Disable instrumentation forarch/arm/mm/physaddr.cv3 - v2
- Remove this patch: 2 1-byte checks more safer formemory_is_poisoned_16because a unaligned load/store of 16 bytes is rare on arm, and this patch is very likely to affect the performance of modern CPUs. ---Acked by: Russell King - ARM Linux <[email protected]>
- Fixed some link error which kasan_pmd_populate,kasan_pte_populate andkasan_pud_populateare in section .meminit.text but the functionkasan_alloc_blockwhich is called bykasan_pmd_populate,kasan_pte_populateandkasan_pud_populateis in section .init.text. So we need change kasan_pmd_populate,kasan_pte_populate andkasan_pud_populateinto the section .init.text.
---Reported by: Florian Fainelli <[email protected]>
- Fixed some compile error which caused by the wrong access instruction inarch/arm/kernel/entry-common.S.
---Reported by: kbuild test robot <[email protected]>
- Disable instrumentation forarch/arm/kvm/hyp/*.
---Acked by: Marc Zyngier <[email protected]>
- Update the set of supported architectures inDocumentation/dev-tools/kasan.rst.
---Acked by:Dmitry Vyukov <[email protected]>
- The version 2 is tested by:
Florian Fainelli <[email protected]> (compile test)
kbuild test robot <[email protected]> (compile test)
Joel Stanley <[email protected]> (on ASPEED ast2500(ARMv5))v2 - v1
- Fixed some compiling error which happens on changing kernel compression mode to lzma/xz/lzo/lz4.
---Reported by: Florian Fainelli <[email protected]>,
Russell King - ARM Linux <[email protected]>
- Fixed a compiling error cause by some older arm instruction set(armv4t) don't suppory movw/movt which is reported by kbuild.
- Changed the pte flag from_L_PTE_DEFAULT|L_PTE_DIRTY|L_PTE_XNtopgprot_val(PAGE_KERNEL).
---Reported by: Russell King - ARM Linux <[email protected]>
- Moved Enable KASan patch as the last one.
---Reported by: Florian Fainelli <[email protected]>,
Russell King - ARM Linux <[email protected]>
- Moved the definitions of cp15 registers fromarch/arm/include/asm/kvm_hyp.htoarch/arm/include/asm/cp15.h. ---Asked by: Mark Rutland <[email protected]>
- Merge the following commits into the commit
Define the virtual space of KASan's shadow region:
1) Define the virtual space of KASan's shadow region;
2) Avoid cleaning the KASan shadow area's mapping table;
3) Add KASan layout;
- Merge the following commits into the commit
Initialize the mapping of KASan shadow memory:
1) Initialize the mapping of KASan shadow memory;
2) Add support arm LPAE;
3) Don't need to map the shadow of KASan's shadow memory; ---Reported by: Russell King - ARM Linux <[email protected]>
4) Change mapping ofkasan_zero_pageint readonly.
- The version 1 is tested by Florian Fainelli <[email protected]> on a Cortex-A5 (no LPAE).Hi,all:
These patches add arch specific code for kernel address sanitizer
(seeDocumentation/kasan.txt).1/8 of kernel addresses reserved for shadow memory. There was no
big enough hole for this, so virtual addresses for shadow were stolen from user space.At early boot stage the whole shadow region populated with just
one physical page (kasan_zero_page). Later, this page reused as readonly zero shadow for some memory that KASan currently don't track (vmalloc).After mapping the physical memory, pages for shadow memory are
allocated and mapped.KASan's stack instrumentation significantly increases stack's
consumption, soCONFIG_KASANdoublesTHREAD_SIZE.Functions like memset/memmove/memcpy do a lot of memory accesses.
If bad pointer passed to one of these function it is important to catch this. Compiler's instrumentation cannot do this since these functions are written in assembly.KASan replaces memory functions with manually instrumented variants.
Original functions declared as weak symbols so strong definitions inmm/kasan/kasan.ccould replace them. Original functions have aliases with '__' prefix in name, so we could call non-instrumented variant if needed.Some files built without kasan instrumentation (e.g.
mm/slub.c).
Original mem* function replaced (via #define) with prefixed variants to disable memory access checks for such files.On arm LPAE architecture, the mapping table of KASan shadow memory(if
PAGE_OFFSETis0xc0000000, the KASan shadow memory's virtual space is 0xb6e000000~0xbf000000) can't be filled indo_translation_faultfunction, because kasan instrumentation maybe causedo_translation_faultfunction accessing KASan shadow memory. The accessing of KASan shadow memory indo_translation_faultfunction maybe cause dead circle. So the mapping table of KASan shadow memory need be copyed inpgd_allocfunction.Most of the code comes from:
https://github.com/aryabinin/linux/commit/0b54f17e70ff50a902c4af05bb92716eb95acefeThese patches are tested on vexpress-ca15, vexpress-ca9
Abbott Liu (2):
ARM: Add TTBR operator forkasan_init
ARM: Define the virtual space of KASan's shadow regionAndrey Ryabinin (4):
ARM: Disable instrumentation for some code
ARM: Replace memory function for kasan
ARM: Initialize the mapping of KASan shadow memory
ARM: Enable KASan for armDocumentation/dev-tools/kasan.rst | 4 +- arch/arm/Kconfig | 1 + arch/arm/boot/compressed/Makefile | 1 + arch/arm/boot/compressed/decompress.c | 2 + arch/arm/boot/compressed/libfdt_env.h | 2 + arch/arm/include/asm/cp15.h | 106 +++++++++ arch/arm/include/asm/kasan.h | 35 +++ arch/arm/include/asm/kasan_def.h | 64 ++++++ arch/arm/include/asm/kvm_hyp.h | 54 ----- arch/arm/include/asm/memory.h | 5 + arch/arm/include/asm/pgalloc.h | 7 +- arch/arm/include/asm/string.h | 17 ++ arch/arm/include/asm/thread_info.h | 4 + arch/arm/kernel/entry-armv.S | 5 +- arch/arm/kernel/entry-common.S | 9 +- arch/arm/kernel/head-common.S | 7 +- arch/arm/kernel/setup.c | 2 + arch/arm/kernel/unwind.c | 3 +- arch/arm/kvm/hyp/cp15-sr.c | 12 +- arch/arm/kvm/hyp/switch.c | 6 +- arch/arm/lib/memcpy.S | 3 + arch/arm/lib/memmove.S | 5 +- arch/arm/lib/memset.S | 3 + arch/arm/mm/Makefile | 4 + arch/arm/mm/kasan_init.c | 301 ++++++++++++++++++++++++++ arch/arm/mm/mmu.c | 7 +- arch/arm/mm/pgd.c | 14 ++ arch/arm/vdso/Makefile | 2 + 28 files changed, 608 insertions(+), 77 deletions(-) create mode 100644 arch/arm/include/asm/kasan.h create mode 100644 arch/arm/include/asm/kasan_def.h create mode 100644 arch/arm/mm/kasan_init.cSignature · 7 lines
2.17.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello Marco,
Quoted 17 lines · Marco Felsch
Hi Florian,
first of all, many thanks for your work on this series =) I picked your and Arnd patches to make it compilable. Now it's compiling but my imx6q board didn't boot anymore. I debugged the code and found that the branch to '
start_kernel' won't be reached8<-------
arch/arm/kernel/head-common.S-------
....#ifdef
CONFIG_KASAN
blkasan_early_init
#endif
mov lr, #0
bstart_kernelENDPROC(__mmap_switched)
Quoted 6 lines
....
8<----------------------------------------------Now, I found also that '
KASAN_SHADOW_OFFSET' isn't set due to missing 'CONFIG_KASAN_SHADOW_OFFSET' and so no '-fasan-shadow-offset=xxxxx' is added. Can that be the reason why my board isn't booted anymore?
The latest that I have is here, though not yet submitted since I needed to solve one issue on a specific platform with a lot of memory:
https://github.com/ffainelli/linux/pull/new/kasan-v7
Can you share your branch as well? I did not pick all of Arnd's patches since some appeared to be seemingly independent from KASan on ARM. This is the KASAN related options that are set in my configuration:
grep KASAN build/linux-custom/.configCONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
# CONFIG_KASAN_INLINE is not setCONFIG_KASAN_STACK=1CONFIG_TEST_KASAN=m
are you using something different by any chance?
Signature · 1 line
Florian
***SPAM*** Re: [PATCH v6 0/6] KASan for arm
[::1]:2869 hp-PC:53166 ios 2.1.2 I sign on it
Dne petek, 15. november 2019 00:01:38 GMT+1 je uporabnik Florian Fainelli <[email protected]> napisal:
Hello Marco,
Quoted 17 lines · Marco Felsch
Hi Florian,
first of all, many thanks for your work on this series =) I picked your and Arnd patches to make it compilable. Now it's compiling but my imx6q board didn't boot anymore. I debugged the code and found that the branch to '
start_kernel' won't be reached8<-------
arch/arm/kernel/head-common.S-------
....#ifdef
CONFIG_KASAN
blkasan_early_init
#endif
mov lr, #0
bstart_kernelENDPROC(__mmap_switched)
Quoted 6 lines
....
8<----------------------------------------------Now, I found also that '
KASAN_SHADOW_OFFSET' isn't set due to missing 'CONFIG_KASAN_SHADOW_OFFSET' and so no '-fasan-shadow-offset=xxxxx' is added. Can that be the reason why my board isn't booted anymore?
The latest that I have is here, though not yet submitted since I needed to solve one issue on a specific platform with a lot of memory:
https://github.com/ffainelli/linux/pull/new/kasan-v7
Can you share your branch as well? I did not pick all of Arnd's patches since some appeared to be seemingly independent from KASan on ARM. This is the KASAN related options that are set in my configuration:
grep KASAN build/linux-custom/.configCONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
# CONFIG_KASAN_INLINE is not setCONFIG_KASAN_STACK=1CONFIG_TEST_KASAN=m
are you using something different by any chance?
Signature · 5 lines
Florian _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Hi Florian,
Quoted 23 lines · Florian Fainelli
Hello Marco,
Quoted 20 lines · Marco Felsch
Hi Florian,
first of all, many thanks for your work on this series =) I picked your and Arnd patches to make it compilable. Now it's compiling but my imx6q board didn't boot anymore. I debugged the code and found that the branch to '
start_kernel' won't be reached8<-------
arch/arm/kernel/head-common.S-------
....#ifdef
CONFIG_KASAN
blkasan_early_init
#endif
mov lr, #0
bstart_kernelENDPROC(__mmap_switched)....
8<----------------------------------------------
Quoted 8 lines
Quoted 3 lines
Now, I found also that '
KASAN_SHADOW_OFFSET' isn't set due to missing 'CONFIG_KASAN_SHADOW_OFFSET' and so no '-fasan-shadow-offset=xxxxx' is added. Can that be the reason why my board isn't booted anymore?The latest that I have is here, though not yet submitted since I needed to solve one issue on a specific platform with a lot of memory:
Thanks for that hint, I will try this series too :) I read that you wanna prepare a v7 but didn't found it ^^
Quoted 3 lines
Can you share your branch as well? I did not pick all of Arnd's patches since some appeared to be seemingly independent from KASan on ARM. This is the KASAN related options that are set in my configuration:
Of course I will push it to github and inform you shortly.
Quoted 9 lines
grep KASAN build/linux-custom/.config
CONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
#CONFIG_KASAN_INLINEis not setCONFIG_KASAN_STACK=1CONFIG_TEST_KASAN=m
My config is:
CONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
# CONFIG_KASAN_INLINE is not setCONFIG_KASAN_STACK=1
# CONFIG_TEST_KASAN is not set
Quoted 1 line
are you using something different by any chance?
Unfortunately not.
Regards,
Marco
Quoted 3 lines
Signature · 1 line
Florian
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Florian,
Quoted 35 lines · Marco Felsch
Hi Florian,
Quoted 23 lines · Florian Fainelli
Hello Marco,
Quoted 20 lines · Marco Felsch
Hi Florian,
first of all, many thanks for your work on this series =) I picked your and Arnd patches to make it compilable. Now it's compiling but my imx6q board didn't boot anymore. I debugged the code and found that the branch to '
start_kernel' won't be reached8<-------
arch/arm/kernel/head-common.S-------
....#ifdef
CONFIG_KASAN
blkasan_early_init
#endif
mov lr, #0
bstart_kernelENDPROC(__mmap_switched)....
8<----------------------------------------------Quoted 8 lines
Quoted 3 lines
Now, I found also that '
KASAN_SHADOW_OFFSET' isn't set due to missing 'CONFIG_KASAN_SHADOW_OFFSET' and so no '-fasan-shadow-offset=xxxxx' is added. Can that be the reason why my board isn't booted anymore?The latest that I have is here, though not yet submitted since I needed to solve one issue on a specific platform with a lot of memory:
Quoted 8 lines
Thanks for that hint, I will try this series too :) I read that you wanna prepare a v7 but didn't found it ^^
Quoted 3 lines
Can you share your branch as well? I did not pick all of Arnd's patches since some appeared to be seemingly independent from KASan on ARM. This is the KASAN related options that are set in my configuration:
Of course I will push it to github and inform you shortly.
Here comes the link:
https://github.com/medude/linux/tree/v5.4/topic/kasan-arm.v7
I just applied Arnds Patche which you didn't added into your v7.
Quoted 21 lines
Quoted 9 lines
grep KASAN build/linux-custom/.config
CONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
#CONFIG_KASAN_INLINEis not setCONFIG_KASAN_STACK=1CONFIG_TEST_KASAN=mMy config is:
CONFIG_HAVE_ARCH_KASAN=yCONFIG_CC_HAS_KASAN_GENERIC=yCONFIG_KASAN=yCONFIG_KASAN_GENERIC=yCONFIG_KASAN_OUTLINE=y
#CONFIG_KASAN_INLINEis not setCONFIG_KASAN_STACK=1
#CONFIG_TEST_KASANis not set
Quoted 3 lines
Quoted 1 line
are you using something different by any chance?
Unfortunately not.
With your v7 it is working on my imx6 but unfortunately I can't run my gstreamer testcase. My CPU load goes to 100% after starting gstreamer and nothing happens.. But the test_kasan module works =) So I decided to check a imx6quadplus but this target did not boot.. I used another toolchain for the imx6quadplus gcc-9 instead of gcc-8. So it seems that something went wrong during compilation. Because you didn't changed something within the logic.
I wonder why we must not define the CONFIG_KASAN_SHADOW_OFFSET for arm.
Regards,
Marco
Quoted 7 lines
Regards,
MarcoQuoted 3 lines
Signature · 1 line
Florian
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 10 lines · Marco Felsch
With your v7 it is working on my imx6 but unfortunately I can't run my gstreamer testcase. My CPU load goes to 100% after starting gstreamer and nothing happens.. But the
test_kasanmodule works =) So I decided to check a imx6quadplus but this target did not boot.. I used another toolchain for the imx6quadplus gcc-9 instead of gcc-8. So it seems that something went wrong during compilation. Because you didn't changed something within the logic.I wonder why we must not define the
CONFIG_KASAN_SHADOW_OFFSETfor arm.
That is was oversight. I have pushed updates to the branch here:
https://github.com/ffainelli/linux/pull/new/kasan-v7
which defines CONFIG_KASAN_SHADOW_OFFSET from the PAGE_OFFSET value directly, and recalculate KASAN_SHADOW_START/END accordingly using the same formula as ARM64.
can you try them out? If that still does not work, can you detail the imx6qdp memory layout a little more? Any chance of running a kernel with DEBUG_LL/EARLYPRINTK turned on so we can see where the problem could be?
Signature · 1 line
Florian
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Marco Felsch
With your v7 it is working on my imx6 but unfortunately I can't run my gstreamer testcase. My CPU load goes to 100% after starting gstreamer and nothing happens.. But the
test_kasanmodule works =) So I decided to check a imx6quadplus but this target did not boot.. I used another toolchain for the imx6quadplus gcc-9 instead of gcc-8. So it seems that something went wrong during compilation. Because you didn't changed something within the logic.
Quoted 5 lines
Quoted 1 line
I wonder why we must not define the
CONFIG_KASAN_SHADOW_OFFSETfor arm.That is was oversight. I have pushed updates to the branch here:
I just git Kasan back on my radar because it needs to be fixed some day.
I took this branch for a ride on some QEMU and some real hardware. Here I use the test module and just hacked it into the kernel instead of as a module, it then crashes predictably but performs all the KASan tests first and it works file, as in provokes the right warnings from KASan.
Tested systems:
QEMU ARM RealView PBA8
QEMU ARM RealView PBX A9
QEMU ARM Versatile AB
Hardware Integrator CP
Hardware Versatile AB with IB2
Can we start to submit these patches to Russell's patch tracker? Any more testing I should be doing?
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 27 lines · Linus Walleij
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Marco Felsch
With your v7 it is working on my imx6 but unfortunately I can't run my gstreamer testcase. My CPU load goes to 100% after starting gstreamer and nothing happens.. But the
test_kasanmodule works =) So I decided to check a imx6quadplus but this target did not boot.. I used another toolchain for the imx6quadplus gcc-9 instead of gcc-8. So it seems that something went wrong during compilation. Because you didn't changed something within the logic.Quoted 5 lines
Quoted 1 line
I wonder why we must not define the
CONFIG_KASAN_SHADOW_OFFSETfor arm.That is was oversight. I have pushed updates to the branch here:
I just git Kasan back on my radar because it needs to be fixed some day.
I took this branch for a ride on some QEMU and some real hardware. Here I use the test module and just hacked it into the kernel instead of as a module, it then crashes predictably but performs all the KASan tests first and it works file, as in provokes the right warnings from KASan.
Tested systems:
Quoted 8 lines
QEMU ARM RealView PBA8
QEMU ARM RealView PBX A9
QEMU ARM Versatile AB
Hardware Integrator CP
Hardware Versatile AB with IB2Can we start to submit these patches to Russell's patch tracker? Any more testing I should be doing?
Let me submit and rebase v7 get the auto builders some days to see if it exposes a new build issue and then we toss it to RMK's patch tracker and fix bugs from there?
Signature · 1 line
Florian
Quoted 7 lines · Florian Fainelli
[Me]
Quoted 2 lines
Can we start to submit these patches to Russell's patch tracker? Any more testing I should be doing?
Let me submit and rebase v7 get the auto builders some days to see if it exposes a new build issue and then we toss it to RMK's patch tracker and fix bugs from there?
OK you can add my Tested-by: Linus Walleij <[email protected]> to the patches.
Thanks,
Linus Walleij
Hi Florian,
Quoted 3 lines · Florian Fainelli
Let me submit and rebase v7 get the auto builders some days to see if it exposes a new build issue and then we toss it to RMK's patch tracker and fix bugs from there?
Sorry for hammering, can we get some initial patches going into Russell's patch tracker here? I can sign them off and put them in if you don't have time.
Thanks,
Linus Walleij
Quoted 11 lines · Linus Walleij
Hi Florian,
Quoted 3 lines · Florian Fainelli
Let me submit and rebase v7 get the auto builders some days to see if it exposes a new build issue and then we toss it to RMK's patch tracker and fix bugs from there?
Sorry for hammering, can we get some initial patches going into Russell's patch tracker here? I can sign them off and put them in if you don't have time.
I've tested the branch on several imx6 based boards with different toolchains. Some boards booting normal and some of them are lost in space... I didn't debugged it yet just wanted to inform you.
Regards,
Marco
Quoted 2 lines
Thanks,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Marco Felsch
Quoted 8 lines · Linus Walleij
Hi Florian,
Quoted 3 lines · Florian Fainelli
Let me submit and rebase v7 get the auto builders some days to see if it exposes a new build issue and then we toss it to RMK's patch tracker and fix bugs from there?
Quoted 7 lines
Quoted 3 lines
Sorry for hammering, can we get some initial patches going into Russell's patch tracker here? I can sign them off and put them in if you don't have time.
I've tested the branch on several imx6 based boards with different toolchains. Some boards booting normal and some of them are lost in space... I didn't debugged it yet just wanted to inform you.
Hm. I will bring up the KASan stack on more boards.
If the system is anywhere close to being low on memory they will naturally crash, this is an unavoidable side effect of KASan or anything else that just chew of a big chunk of memory, that I ran into, as I was booting from initramfs on very memory
constrained systems.
Yours,
Linus Walleij