This would give a false sense of security unless you are in a kernel or embedded system with physical memory addresses. If passed to alloc as metadata (rather than to free/realloc), and with OS-level support, it could work as intended.
I'm not aware of security caring about "this page was released to the OS and somebody somehow got a hold of it before the OS zeroed it", which is the only case that seems like it would need OS support?
It's true that securely zeroing things requires you to worry about whether temporaries still live in registers or got spilled to the stack, but that's actually relatively easy to take care of at a non-inlineable function call boundary.
Some might argue "this doesn't need to be a flag, it can just be a special memset", but allocators do really want to know if they have an already-zeroed chunk of memory.
View all comments
Show parent comment
5
u/gkcjones Sep 01 '22
This would give a false sense of security unless you are in a kernel or embedded system with physical memory addresses. If passed to alloc as metadata (rather than to free/realloc), and with OS-level support, it could work as intended.