Sanitizing the Linux Kernel — On KASAN and other Dynamic Bug-finding Tools
summary
Generic KASAN uses compiler instrumentation plus a kernel runtime with shadow memory (x86 maps 16 TiB) and per-allocator red zones to catch out‑of‑bounds and use‑after‑free in slab, page_alloc, vmalloc, stack and global memory; it adds a quarantine = 1/32 RAM to improve UAF detection and stores allocation/free stack traces in Stack Depot. Expect 2x–3x slowdown (outline mode trades speed for image size). Related tools: KMSAN (uninitialized), KCSAN (races), UBSAN; kfence sampling and software/hardware memory tagging aim for in‑field use.
AI-written summary · about
chapters (27)
- 0:00Start
- 4:01KASAN-Kernel Address Sanitizer
- 5:11KASAN parts
- 7:49Shadow byte values for inaccessible memory
- 8:13Shadow memory region
- 9:02Shadow mapping routines for x86-64
- 10:10Compiler instrumentation: 8-byte access
- 11:57Slab layout (for SLUB)
- 14:28Quarantine for freed memory
- 15:46Compiler instrumentation: stack variables [3/3]
- 16:39Compiler instrumentation: global variables
- 17:17Reporting bugs
- 18:56Report example: slab out-of-bounds [5/5]
- 22:04Generic KASAN notes and parts
- 25:09Generic KASAN summary
- 26:55KMSAN - Kernel Memory Sanitizer
- 28:08KCSAN - Kernel Concurrency Sanitizer
- 29:32UBSAN - [Kernel] Undefined Behavior Sanitizer
- 32:21Software Tag-Based KASAN
- 36:17Production stack traces for KASAN
- 39:50Extending Sanitizers
- 40:25Extending KASAN: custom redzones
- 42:12Percpu allocator: fairly used
- 43:10Percpu allocator: need KASAN annotations
- 43:59Extending KMSAN: USB annotations
- 44:54Finding more bugs
- 46:23Make better bug detectors
related talks
42mUnderstanding Data Races in the Linux Kernel
23mDealing with Uninitialized Memory in the Kernel
50mAddressSanitizer/ThreadSanitizer for Linux Kernel
08mWIP: QKSAN: Towards Multiple Sanitizers for In-vehicle COTS OS Kernels
37mBreaking and Fixing the Kernel: Crashes, Debugging & Performance Tun...
38mHow I started chasing speculative type confusion bugs in the kernel and ended up wi...
41mUsing Microarchitectural Design to Break KASLR and More
59mBeyond Sanitizers...
