Commit 8479d7b5 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Linus Torvalds

kasan: documentation updates

Update KASAN documentation:

 - Bump Clang version requirement for HW_TAGS as ARM64_MTE depends on
   AS_HAS_LSE_ATOMICS as of commit 2decad92 ("arm64: mte: Ensure
   TIF_MTE_ASYNC_FAULT is set atomically"), which requires Clang 12.

 - Add description of the new kasan.vmalloc command line flag.

 - Mention that SW_TAGS and HW_TAGS modes now support vmalloc tagging.

 - Explicitly say that the "Shadow memory" section is only applicable to
   software KASAN modes.

 - Mention that shadow-based KASAN_VMALLOC is supported on arm64.

Link: https://lkml.kernel.org/r/a61189128fa3f9fbcfd9884ff653d401864b8e74.1643047180.git.andreyknvl@google.comSigned-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Acked-by: default avatarMarco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f6f37d93
...@@ -30,7 +30,7 @@ Software tag-based KASAN mode is only supported in Clang. ...@@ -30,7 +30,7 @@ Software tag-based KASAN mode is only supported in Clang.
The hardware KASAN mode (#3) relies on hardware to perform the checks but The hardware KASAN mode (#3) relies on hardware to perform the checks but
still requires a compiler version that supports memory tagging instructions. still requires a compiler version that supports memory tagging instructions.
This mode is supported in GCC 10+ and Clang 11+. This mode is supported in GCC 10+ and Clang 12+.
Both software KASAN modes work with SLUB and SLAB memory allocators, Both software KASAN modes work with SLUB and SLAB memory allocators,
while the hardware tag-based KASAN currently only supports SLUB. while the hardware tag-based KASAN currently only supports SLUB.
...@@ -206,6 +206,9 @@ additional boot parameters that allow disabling KASAN or controlling features: ...@@ -206,6 +206,9 @@ additional boot parameters that allow disabling KASAN or controlling features:
Asymmetric mode: a bad access is detected synchronously on reads and Asymmetric mode: a bad access is detected synchronously on reads and
asynchronously on writes. asynchronously on writes.
- ``kasan.vmalloc=off`` or ``=on`` disables or enables tagging of vmalloc
allocations (default: ``on``).
- ``kasan.stacktrace=off`` or ``=on`` disables or enables alloc and free stack - ``kasan.stacktrace=off`` or ``=on`` disables or enables alloc and free stack
traces collection (default: ``on``). traces collection (default: ``on``).
...@@ -279,8 +282,8 @@ Software tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through ...@@ -279,8 +282,8 @@ Software tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through
pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently
reserved to tag freed memory regions. reserved to tag freed memory regions.
Software tag-based KASAN currently only supports tagging of slab and page_alloc Software tag-based KASAN currently only supports tagging of slab, page_alloc,
memory. and vmalloc memory.
Hardware tag-based KASAN Hardware tag-based KASAN
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -303,8 +306,8 @@ Hardware tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through ...@@ -303,8 +306,8 @@ Hardware tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through
pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently
reserved to tag freed memory regions. reserved to tag freed memory regions.
Hardware tag-based KASAN currently only supports tagging of slab and page_alloc Hardware tag-based KASAN currently only supports tagging of slab, page_alloc,
memory. and VM_ALLOC-based vmalloc memory.
If the hardware does not support MTE (pre ARMv8.5), hardware tag-based KASAN If the hardware does not support MTE (pre ARMv8.5), hardware tag-based KASAN
will not be enabled. In this case, all KASAN boot parameters are ignored. will not be enabled. In this case, all KASAN boot parameters are ignored.
...@@ -319,6 +322,8 @@ checking gets disabled. ...@@ -319,6 +322,8 @@ checking gets disabled.
Shadow memory Shadow memory
------------- -------------
The contents of this section are only applicable to software KASAN modes.
The kernel maps memory in several different parts of the address space. The kernel maps memory in several different parts of the address space.
The range of kernel virtual addresses is large: there is not enough real The range of kernel virtual addresses is large: there is not enough real
memory to support a real shadow region for every address that could be memory to support a real shadow region for every address that could be
...@@ -349,7 +354,7 @@ CONFIG_KASAN_VMALLOC ...@@ -349,7 +354,7 @@ CONFIG_KASAN_VMALLOC
With ``CONFIG_KASAN_VMALLOC``, KASAN can cover vmalloc space at the With ``CONFIG_KASAN_VMALLOC``, KASAN can cover vmalloc space at the
cost of greater memory usage. Currently, this is supported on x86, cost of greater memory usage. Currently, this is supported on x86,
riscv, s390, and powerpc. arm64, riscv, s390, and powerpc.
This works by hooking into vmalloc and vmap and dynamically This works by hooking into vmalloc and vmap and dynamically
allocating real shadow memory to back the mappings. allocating real shadow memory to back the mappings.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment