kasan_mempool_poison_object(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ kasan_mempool_poison_object πŸ’…

okay so bestie, welcome to the kasan_mempool_poison_object(9) page β€” it's a Kernel API Manual moment, and honestly it's giving "niche but iconic" πŸŽ€


🌸 NAME 🌸

kasan_mempool_poison_object β€” checks and poisons a mempool slab allocation. Yeah, it does both. Multi-talented. Main character energy fr fr πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

bool kasan_mempool_poison_object (void *ptr );

πŸ“ ARGUMENTS πŸ“

  • ptr β€” pointer to the slab allocation. That's it, that's the whole argument list. Simple. Elegant. Ate. ✨

πŸ’– DESCRIPTION πŸ’–

okay so here's the vibe: this function is for kernel subsystems that cache slab allocations so they can reuse them instead of freeing them back to the slab allocator (like, for example, mempool). They're hoarding their slabs and honestly? respect. πŸ‘‘

What it does: it poisons a slab allocation and saves a free stack trace for it β€” but without initializing the allocation's memory, and without putting it into the quarantine (that's for the Generic mode, iykyk). So like, poisoned but not fully committed to the bit. πŸ§ͺ

It also runs checks to detect double-free and invalid-free bugs and reports them, because catching those is lowkey the whole point. The caller can peek at the return value of this function to find out if the allocation is buggy β€” handy! πŸ”

⚠️ important bestie: before a poisoned allocation can be reused, it must be unpoisoned via kasan_mempool_unpoison_object. Do not skip this step. Do not pass go. Do not collect $200. 😭

And the reach? It operates on all slab allocations, including large kmalloc allocations β€” aka the ones backed directly by the buddy allocator rather than by kmalloc slab caches. No allocation left behind. 🌈


πŸ”₯ RETURN πŸ”₯

  • true β€” the allocation can be safely reused 🫢
  • false β€” nope, otherwise πŸ’€

🧚 SEE ALSO 🧚

Kernel file ./include/linux/kasan.h, plus the whole friend group:


πŸ’œ that's the whole page bestie, go poison some slabs responsibly πŸ’œ

sign-off szn πŸŽ€: this lil masterpiece lives in ./include/linux and it's dated October 2026 β€” yes, the future. periodt. βœ¨πŸ‘‘

πŸ“¦ where this page comes from