Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZykvS9MlX1ycmvdA@gmail.com>
Date: Mon, 4 Nov 2024 15:32:11 -0500
From: Bryan Steele <brynet@...il.com>
To: libc-coord@...ts.openwall.com
Subject: Re: Anyone have a secure 'free' API?

On Mon, Nov 04, 2024 at 11:46:47AM -0800, Keith Packard wrote:
> 
> I'm wondering if anyone has an API which does memset followed by free to
> clear sensitive data from the heap after use as compilers will simply
> drop a call to memset before free these days. Linux has kfree_sensitive
> and memzero_explicit APIs, I'm wondering if anyone on this list has a C
> library exposing something like this for applications?
> 
> -- 
> -keith

OpenBSD has had freezero() in libc since 2017.

  freezero(void *ptr, size_t size);
...

`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.`

https://man.openbsd.org/malloc#freezero

https://github.com/openbsd/src/blob/master/lib/libc/stdlib/malloc.c#L1754

-Bryan.

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.