kasan_mempool_poison_object(9)
β¨ 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:
kasan_unpoison_new_object(9)kasan_poison_new_object(9)kasan_slab_pre_free(9)kasan_slab_free(9)kasan_mempool_poison_pages(9)kasan_mempool_unpoison_pages(9)kasan_mempool_unpoison_object(9)kasan_report(9)
π 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms