KERNEL_SANITIZERS(7)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’… 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: Yes
  • STACK: Yes
  • ATOMICS: Yes
  • BUS_SPACE: Yes
  • BUS_DMA: Yes
  • VLAs: Yes

aarch64

  • HEAP: Yes
  • STACK: Yes
  • ATOMICS: Yes
  • BUS_SPACE: No
  • BUS_DMA: Yes
  • VLAs: Yes

arm

  • HEAP: Yes
  • STACK: Yes
  • ATOMICS: Yes
  • BUS_SPACE: No
  • BUS_DMA: Yes
  • VLAs: 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