memzero_explicit(9)
π 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 beginscountβ 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:
memdup_array_user(9)vmemdup_array_user(9)strscpy(9)strscpy_pad(9)mem_is_zero(9)sysfs_match_string(9)kbasename(9)strtomem_pad(9)strtomem(9)memtostr(9)memtostr_pad(9)memset_after(9)memset_startat(9)str_has_prefix(9)strstarts(9)strends(9)
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
- 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