KERNEL_SANITIZERS(7)
π KERNEL_SANITIZERS β the NetBSD kernel's glow-up squad
okay so this is KERNEL_SANITIZERS(7) from the Miscellaneous Information Manual, and bestie, it's literally the page about NetBSD's kernel bug-hunting besties. Let's get into it β¨
πΈ NAME πΈ
kernel_sanitizers β NetBSD Kernel Sanitizers. that's it, that's the name, iconic π
π¦ DESCRIPTION π¦
Kernel Sanitizers are these powerful kernel bug detection features that can automatically discover several classes of bugs at run time, while the kernel is out there executing. like they're just sitting there watching the kernel do its thing and going "hmm, that's sus" π₯
NetBSD supports four kernel sanitizers. big caveat though: they are not mutually compatible, and only one can be enabled at a time, and you do that via compilation options. so no polyamory for sanitizers, one at a time, periodt π
π KUBSAN π
Kernel Undefined Behavior Sanitizer β specializes in finding several types of undefined behaviors, such as misaligned accesses and integer overflows. it's giving undefined-behavior detective π
Runtime cost
Heavy runtime checks. like, it will slow you down π
Used components
Compiler instrumentation and an entirely MI runtime.
Supported architectures
aarch64 (gcc), amd64 (gcc), arm (gcc).
[Theoretically supported on all other architectures with no MD change required] β that bracketed note is literally in the manpage, iykyk π
Files
src/common/lib/libc/misc/ubsan.cβ Core KUBSAN code. MI.
π KASAN π
Kernel Address Sanitizer β specializes in finding memory corruptions, such as buffer overflows and use-after-frees. the memory-crime scene investigator, fr fr π΅οΈββοΈ
Runtime cost
Heavy runtime checks, and ~12.5% increase in memory consumption. your RAM is paying rent now π
Used components
Shadow memory, compiler instrumentation, special kernel wrappers, and light MD infrastructure.
Supported architectures
aarch64 (gcc), amd64 (gcc, llvm), arm (gcc).
KASAN is made of six sub-features that perform memory validation. the original page has a whole table, and since we don't do tables here, imma spell it out per port so nothing gets lost π
amd64
HEAP: YesSTACK: YesATOMICS: YesBUS_SPACE: YesBUS_DMA: YesVLAs: Yes
aarch64
HEAP: YesSTACK: YesATOMICS: YesBUS_SPACE: NoBUS_DMA: YesVLAs: Yes
arm
HEAP: YesSTACK: YesATOMICS: YesBUS_SPACE: NoBUS_DMA: YesVLAs: Yes
An architecture is allowed to have only partial support. so partial slay is still slay π«Ά
Files
src/sys/kern/subr_asan.cβ Core KASAN code. MI.src/sys/sys/asan.hβ Main KASAN header. MI.src/sys/arch/{port}/include/asan.hβ Port-specific KASAN code. MD.
Each new port of KASAN should respect the existing naming conventions, and should introduce only one MD header file. one header, no clutter, we love a tidy queen π
β KCSAN β
Kernel Concurrency Sanitizer β specializes in finding memory races. it catches threads beefing over memory in real time π
Runtime cost
Medium runtime checks. medium! not heavy! we love a balanced vibe β¨
Used components
Compiler instrumentation, special kernel wrappers, and light MD infrastructure.
Supported architectures
amd64 (gcc).
Files
src/sys/kern/subr_csan.cβ Core KCSAN code. MI.src/sys/sys/csan.hβ Main KCSAN header. MI.src/sys/arch/{port}/include/csan.hβ Port-specific KCSAN code. MD.
Each new port of KCSAN should respect the existing naming conventions, and should introduce only one MD header file. same rule, same energy π
π KMSAN π
Kernel Memory Sanitizer β specializes in finding uninitialized memory. the "bestie you never set this variable" detector π
Runtime cost
Heavy runtime checks, and ~200% increase in memory consumption. TWO HUNDRED PERCENT. your memory is gone, she left the chat ππ
Used components
Double shadow memory, compiler instrumentation, special kernel wrappers, and heavy MD infrastructure. double shadow, double trouble βοΈ
Supported architectures
amd64 (llvm).
Files
src/sys/kern/subr_msan.cβ Core KMSAN code. MI.src/sys/sys/msan.hβ Main KMSAN header. MI.src/sys/arch/{port}/include/msan.hβ Port-specific KMSAN code. MD.
Each new port of KMSAN should respect the existing naming conventions, and should introduce only one MD header file. consistent naming is the moment, no cap π
π AUTHORS π
- Support for KUBSAN was developed by Kamil Rytarowski.
- Support for KASAN, KCSAN and KMSAN was developed by Maxime Villard.
- Support for KASAN on ARM was developed by Nick Hudson.
absolute icons, every single one of them ππ«Ά
and that's a wrap bestie!! this page came from the Debian flavour of the manual, dated July 12, 2020, and it lives at section KERNEL_SANITIZERS(7). go forth and sanitize responsibly π
β¨π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2020 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms