Lines Matching +full:1 +full:- +full:based
5 --------
8 designed to find out-of-bound and use-after-free bugs. KASAN has three modes:
10 1. generic KASAN (similar to userspace ASan),
11 2. software tag-based KASAN (similar to userspace HWASan),
12 3. hardware tag-based KASAN (based on hardware memory tagging).
15 Software tag-based KASAN can be used for dogfood testing as it has a lower
16 memory overhead that allows using it with real workloads. Hardware tag-based
18 used in production. Either as an in-field memory bug detector or as a security
21 Software KASAN modes (#1 and #2) use compile-time instrumentation to insert
27 out-of-bounds accesses for global variables is only supported since Clang 11.
29 Software tag-based KASAN mode is only supported in Clang.
36 while the hardware tag-based KASAN currently only supports SLUB.
39 and riscv architectures, and tag-based KASAN modes are supported only for arm64.
42 -----
49 ``CONFIG_KASAN_SW_TAGS`` (to enable software tag-based KASAN), and
50 ``CONFIG_KASAN_HW_TAGS`` (to enable hardware tag-based KASAN).
54 The former produces a smaller binary while the latter is 1.1-2 times faster.
66 BUG: KASAN: slab-out-of-bounds in kmalloc_oob_right+0xa8/0xbc [test_kasan]
67 Write of size 1 at addr ffff8801f44ec37b by task insmod/2760
69 CPU: 1 PID: 2760 Comm: insmod Not tainted 4.19.0-rc3+ #698
70 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
117 which belongs to the cache kmalloc-128 of size 128
119 128-byte region [ffff8801f44ec300, ffff8801f44ec380)
121 page:ffffea0007d13b00 count:1 mapcount:0 mapping:ffff8801f7001640 index:0x0
139 and a stack trace of where the object was freed (in case of a use-after-free
153 memory region are accessible; number N (1 <= N <= 7) means that the first N
154 bytes are accessible, and other (8 - N) bytes are not; any negative value
155 indicates that the entire 8-byte word is inaccessible. KASAN uses different
162 For tag-based KASAN modes, this last report section shows the memory tags around
165 Note that KASAN bug titles (like ``slab-out-of-bounds`` or ``use-after-free``)
166 are best-effort: KASAN prints the most probable bug type based on the limited
187 - ``kasan.fault=report`` or ``=panic`` controls whether to only print a KASAN
191 Hardware tag-based KASAN mode (see the section about various modes below) is
195 - ``kasan=off`` or ``=on`` controls whether KASAN is enabled (default: ``on``).
197 - ``kasan.mode=sync`` or ``=async`` controls whether KASAN is configured in
206 - ``kasan.stacktrace=off`` or ``=on`` disables or enables alloc and free stack
210 ----------------------
216 safe to access and use compile-time instrumentation to insert shadow memory
219 Generic KASAN dedicates 1/8th of kernel memory to its shadow memory (16TB
234 Compile-time instrumentation is used to insert memory access checks. Compiler
236 each memory access of size 1, 2, 4, 8, or 16. These functions check whether
241 enlarges the kernel, but it gives an x1.1-x2 performance boost over the
242 outline-instrumented kernel.
247 Software tag-based KASAN
250 Software tag-based KASAN uses a software memory tagging approach to checking
253 Software tag-based KASAN uses the Top Byte Ignore (TBI) feature of arm64 CPUs
255 to store memory tags associated with each 16-byte memory cell (therefore, it
256 dedicates 1/16th of the kernel memory for shadow memory).
258 On each memory allocation, software tag-based KASAN generates a random tag, tags
262 Software tag-based KASAN uses compile-time instrumentation to insert checks
265 this memory. In case of a tag mismatch, software tag-based KASAN prints a bug
268 Software tag-based KASAN also has two instrumentation modes (outline, which
275 Software tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through
279 Software tag-based KASAN currently only supports tagging of slab and page_alloc
282 Hardware tag-based KASAN
285 Hardware tag-based KASAN is similar to the software mode in concept but uses
289 Hardware tag-based KASAN is currently only implemented for arm64 architecture
290 and based on both arm64 Memory Tagging Extension (MTE) introduced in ARMv8.5
299 Hardware tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through
303 Hardware tag-based KASAN currently only supports tagging of slab and page_alloc
306 If the hardware does not support MTE (pre ARMv8.5), hardware tag-based KASAN
309 Note that enabling CONFIG_KASAN_HW_TAGS always results in in-kernel TBI being
313 Hardware tag-based KASAN only reports the first found bug. After that, MTE tag
317 -------------
330 other areas - such as vmalloc and vmemmap space - a single read-only
331 page is mapped over the shadow area. This read-only shadow page
340 lives in vmalloc space, it will be shadowed by the read-only page, and
371 This will require changes in arch-specific code.
377 --------------
394 - For a single file (e.g., main.o)::
398 - For all files in one directory::
402 For software KASAN modes, to disable instrumentation on a per-function basis,
403 use the KASAN-specific ``__no_sanitize_address`` function attribute or the
406 Note that disabling compiler instrumentation (either on a per-file or a
407 per-function basis) makes KASAN ignore the accesses that happen directly in
410 tag-based mode that does not use compiler instrumentation.
417 For tag-based KASAN modes (include the hardware one), to disable access
420 saving and restoring the per-page KASAN tag via
429 1. Tests that are integrated with the KUnit Test Framework. Enabled with
438 Each KUnit-compatible KASAN test prints one of multiple KASAN reports if an
443 ok 28 - kmalloc_double_kzfree
449 not ok 4 - kmalloc_large_oob_right
455 not ok 44 - kmalloc_double_kzfree
460 ok 1 - kasan
464 not ok 1 - kasan
466 There are a few ways to run KUnit-compatible KASAN tests.
468 1. Loadable module
470 With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a loadable
473 2. Built-In
475 With ``CONFIG_KUNIT`` built-in, KASAN-KUnit tests can be built-in as well.
476 In this case, the tests will run at boot as a late-init call.
480 With ``CONFIG_KUNIT`` and ``CONFIG_KASAN_KUNIT_TEST`` built-in, it is also
483 See `KUnit documentation <https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html>`_
484 for more up-to-date information on ``kunit_tool``.
486 .. _KUnit: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html