mbox series

[0/5,v9] KASan for Arm

Message ID 20200515114028.135674-1-linus.walleij@linaro.org (mailing list archive)
Headers show
Series KASan for Arm | expand

Message

Linus Walleij May 15, 2020, 11:40 a.m. UTC
I fixed and debugged kasan so it is time to post it again!

It can also be picked from my evolving branch which include
the prerequisite commit:
https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git/log/?h=kasan

ChangeLog v8->v9:

- Use Drop the custom CP15 manipulation and cache flushing for swapping
  TTBR0 and instead just use cpu_switch_mm() in the initialization
  code (smarter and probably better tested code path).
- Found the bug that was making KASan fail on ARMv4 and ARMv5, see
  the separate patch:
  https://lore.kernel.org/linux-arm-kernel/20200514135737.309146-1-linus.walleij@linaro.org/
- Tested extensively on a whole bunch of ARM systems, both QEMU and
  real hardware: it is quite solid. On the D-Link DNS-313 that has
  only 64 MB of memory, the OOM killer gets upset and start killing
  off processes with a default OpenWrt install but otherwise debugs
  nicely with KASan!

Caveat:

- One remaining issue: if the kernel is booted with attached device
  tree on an odd address, you can get crashes in the DT parser.
  Example: on the Qualcomm APQ8060 DragonBoard the first piece
  of physical address space that can be used by the kernel is at
  0x40200000 so you boot like this:
  fastboot --base 40200000 --cmdline "console=ttyMSM0,115200,n8" boot zImage
  This does *NOT* work but crashes in the DT parser.
  But if you boot on 0x50000000 instead:
  fastboot --base 50000000 --cmdline "console=ttyMSM0,115200,n8" boot zImage
  KASan works fine.
  So something is off when booting with KASan and odd physical memory
  configurations. I am digging into this.

Abbott Liu (1):
  ARM: Define the virtual space of KASan's shadow region

Andrey Ryabinin (4):
  ARM: Disable KASan instrumentation for some code
  ARM: Replace string mem* functions for KASan
  ARM: Initialize the mapping of KASan shadow memory
  ARM: Enable KASan for ARM

 Documentation/arm/memory.rst                  |   5 +
 Documentation/dev-tools/kasan.rst             |   4 +-
 .../features/debug/KASAN/arch-support.txt     |   2 +-
 arch/arm/Kconfig                              |  10 +
 arch/arm/boot/compressed/Makefile             |   1 +
 arch/arm/boot/compressed/string.c             |  19 ++
 arch/arm/include/asm/kasan.h                  |  32 ++
 arch/arm/include/asm/kasan_def.h              |  81 +++++
 arch/arm/include/asm/memory.h                 |   5 +
 arch/arm/include/asm/pgalloc.h                |   9 +-
 arch/arm/include/asm/string.h                 |  21 ++
 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                      |   6 +-
 arch/arm/lib/memcpy.S                         |   3 +
 arch/arm/lib/memmove.S                        |   5 +-
 arch/arm/lib/memset.S                         |   3 +
 arch/arm/mm/Makefile                          |   5 +
 arch/arm/mm/kasan_init.c                      | 294 ++++++++++++++++++
 arch/arm/mm/mmu.c                             |  18 ++
 arch/arm/mm/pgd.c                             |  15 +-
 arch/arm/vdso/Makefile                        |   2 +
 25 files changed, 552 insertions(+), 15 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