WCU / Cybersecurity
~/CSC 472/Class 10/KP 05
Class 10 · KP 05 / 20

Kernel Memory: Slabs and the SLUB Allocator

  • User space has malloc; the kernel has kmalloc, backed by the SLUB slab allocator (the default modern allocator).
  • Objects are grouped by size into caches: general-purpose kmalloc-32, kmalloc-64, kmalloc-256, ... plus dedicated caches for hot structs (e.g. cred, files_struct).
  • Freed objects are pushed on a per-cache freelist and handed back on the next same-size allocation — often in LIFO order, which attackers exploit for predictable reuse.
  • Heap grooming / feng shui: allocate and free in a chosen pattern so a freed victim object is replaced by an attacker-shaped object of the same size class.
Key Takeaway

Kernel heap exploitation is about controlling which object lands in a freed slot — same techniques as user heap, higher stakes.