memzero_explicit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… memzero_explicit πŸ’…

okay bestie, welcome to the Kernel API Manual β€” today's main character is memzero_explicit(9) and honestly she's lowkey a lifesaver 🫢


✨ NAME ✨

memzero_explicit β€” fills a region of memory (like, say, your sensitive keying data πŸ‘€πŸ”) with 0s. yes, just zeros. iconic behaviour, no notes.


🌸 SYNOPSIS 🌸

void memzero_explicit (void *s , size_t count );

πŸŽ€ ARGUMENTS πŸŽ€

  • s β€” pointer to the start of the area πŸ’– like, where the memory party begins
  • count β€” the size of the area πŸ¦‹ how much of it we're zeroing, fr fr

πŸ’€ NOTE πŸ’€

okay so usually just using memset is literally fine (!) β€” no cap, it's fine β€” but in cases where clearing out _local_ data at the end of a scope is necessary, you should use memzero_explicit instead, and here's why bestie: it stops the compiler from optimising away your zeroing 😭 like the compiler will genuinely just be like "hmm nobody reads this, delete it" and then your secrets are still sitting there. not slay. so use this one instead. periodt. πŸ’…

also good news: memzero_explicit doesn't need an arch-specific version because it just invokes the one of memset implicitly ✨ she's efficient like that 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./include/linux/string.h β€” and the whole friend group:


and that's the whole page, bestie πŸ§šπŸ’œ she lives in ./include/linux, dated October 2026, and she answers to memzero_explicit(9) β€” go forth and zero responsibly πŸ”₯πŸ‘‘β­πŸ“

πŸ“¦ where this page comes from