Date: Fri, 17 Sep 2021 16:31:13 -0700 From: Alan Coopersmith <alan.coopersmith@...cle.com> To: libc-coord@...ts.openwall.com Subject: freezero() and freezeroall() OpenBSD 6.2 added a new interface to their libc: void freezero(void *ptr, size_t size); The man page at https://man.openbsd.org/freezero defines it as: The freezero() function is similar to the free() function except it ensures memory is explicitly discarded. If ptr is NULL, no action occurs. If ptr is not NULL, the size argument must be equal to or smaller than the size of the earlier allocation that returned ptr. freezero() guarantees the memory range starting at ptr with length size is discarded while deallocating the whole object originally allocated. where "discarded" is defined as: pages of memory are disposed via munmap(2) and cached free objects are cleared with explicit_bzero(3). The reliance on the caller to provide the size to clear allows the function to be implemented independently of the underlying allocator library, and has allowed this function to be implemented in libbsd, as well as fallback implementations provided in portable software packages for systems without their own implementation - including in OpenSSH, OpenNNTPd, OpenBGPd, OpenIKEd, OpenSMTPd, sudo, tmux, libretls, and a few more I see in the search results on codesearch.debian.net. I've also seen it implemented in libc on illumos and DragonflyBSD. I'm working on adding it to the Solaris libc now, and since we can determine the underlying allocation size, proposed also adding: void freezeroall(void *ptr); as basically doing: freezero(ptr, malloc_usable_size(ptr)); During review of this change I was asked if there's any existing equivalent we should be following instead before we invent our own name - I couldn't find one, but figured I'd ask here - are other libc implementations doing anything like this? -- -Alan Coopersmith- alan.coopersmith@...cle.com Oracle Solaris Engineering - https://blogs.oracle.com/alanc
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.