The patch titled Subject: kasan: documentation updates has been added to the -mm tree. Its filename is kasan-documentation-updates.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/kasan-documentation-updates.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/kasan-documentation-updates.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Subject: 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 2decad92f4731 ("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@xxxxxxxxxx Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Acked-by: Marco Elver <elver@xxxxxxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Evgenii Stepanov <eugenis@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Peter Collingbourne <pcc@xxxxxxxxxx> Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/dev-tools/kasan.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/Documentation/dev-tools/kasan.rst~kasan-documentation-updates +++ a/Documentation/dev-tools/kasan.rst @@ -30,7 +30,7 @@ Software tag-based KASAN mode is only su The hardware KASAN mode (#3) relies on hardware to perform the checks but 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, while the hardware tag-based KASAN currently only supports SLUB. @@ -206,6 +206,9 @@ additional boot parameters that allow di Asymmetric mode: a bad access is detected synchronously on reads and 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 traces collection (default: ``on``). @@ -279,8 +282,8 @@ Software tag-based KASAN uses 0xFF as a pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently reserved to tag freed memory regions. -Software tag-based KASAN currently only supports tagging of slab and page_alloc -memory. +Software tag-based KASAN currently only supports tagging of slab, page_alloc, +and vmalloc memory. Hardware tag-based KASAN ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -303,8 +306,8 @@ Hardware tag-based KASAN uses 0xFF as a pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently reserved to tag freed memory regions. -Hardware tag-based KASAN currently only supports tagging of slab and page_alloc -memory. +Hardware tag-based KASAN currently only supports tagging of slab, page_alloc, +and VM_ALLOC-based vmalloc memory. 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. @@ -319,6 +322,8 @@ checking gets disabled. 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 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 @@ -349,7 +354,7 @@ CONFIG_KASAN_VMALLOC With ``CONFIG_KASAN_VMALLOC``, KASAN can cover vmalloc space at the 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 allocating real shadow memory to back the mappings. _ Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are kasan-page_alloc-deduplicate-should_skip_kasan_poison.patch kasan-page_alloc-move-tag_clear_highpage-out-of-kernel_init_free_pages.patch kasan-page_alloc-merge-kasan_free_pages-into-free_pages_prepare.patch kasan-page_alloc-simplify-kasan_poison_pages-call-site.patch kasan-page_alloc-init-memory-of-skipped-pages-on-free.patch kasan-drop-skip_kasan_poison-variable-in-free_pages_prepare.patch mm-clarify-__gfp_zerotags-comment.patch kasan-only-apply-__gfp_zerotags-when-memory-is-zeroed.patch kasan-page_alloc-refactor-init-checks-in-post_alloc_hook.patch kasan-page_alloc-merge-kasan_alloc_pages-into-post_alloc_hook.patch kasan-page_alloc-combine-tag_clear_highpage-calls-in-post_alloc_hook.patch kasan-page_alloc-move-setpageskipkasanpoison-in-post_alloc_hook.patch kasan-page_alloc-move-kernel_init_free_pages-in-post_alloc_hook.patch kasan-page_alloc-rework-kasan_unpoison_pages-call-site.patch kasan-clean-up-metadata-byte-definitions.patch kasan-define-kasan_vmalloc_invalid-for-sw_tags.patch kasan-x86-arm64-s390-rename-functions-for-modules-shadow.patch kasan-vmalloc-drop-outdated-vm_kasan-comment.patch kasan-reorder-vmalloc-hooks.patch kasan-add-wrappers-for-vmalloc-hooks.patch kasan-vmalloc-reset-tags-in-vmalloc-functions.patch kasan-fork-reset-pointer-tags-of-vmapped-stacks.patch kasan-arm64-reset-pointer-tags-of-vmapped-stacks.patch kasan-vmalloc-add-vmalloc-tagging-for-sw_tags.patch kasan-vmalloc-arm64-mark-vmalloc-mappings-as-pgprot_tagged.patch kasan-vmalloc-unpoison-vm_alloc-pages-after-mapping.patch kasan-mm-only-define-___gfp_skip_kasan_poison-with-hw_tags.patch kasan-page_alloc-allow-skipping-unpoisoning-for-hw_tags.patch kasan-page_alloc-allow-skipping-memory-init-for-hw_tags.patch kasan-vmalloc-add-vmalloc-tagging-for-hw_tags.patch kasan-vmalloc-only-tag-normal-vmalloc-allocations.patch kasan-arm64-dont-tag-executable-vmalloc-allocations.patch kasan-mark-kasan_arg_stacktrace-as-__initdata.patch kasan-clean-up-feature-flags-for-hw_tags-mode.patch kasan-add-kasanvmalloc-command-line-flag.patch kasan-allow-enabling-kasan_vmalloc-and-sw-hw_tags.patch arm64-select-kasan_vmalloc-for-sw-hw_tags-modes.patch kasan-documentation-updates.patch kasan-improve-vmalloc-tests.patch