From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: using explicit_bzero
Date: Wed, 17 Jul 2019 17:19:31 -0400
Message-ID: <20190717211931.GA906@alvherre.pgsql> (raw)
In-Reply-To: <CA+hUKGK9dNAQoVtuXSa_rdTwdvtTiG=NytWq+Ert7_UJArTFKQ@mail.gmail.com>
On 2019-Jul-11, Thomas Munro wrote:
> Following a trail of crumbs beginning at OpenSSH's fallback
> implementation of this[1], I learned that C11 has standardised
> memset_s[2] for this purpose. Macs have memset_s but no
> explicit_bzero. FreeBSD has both. I wonder if it'd be better to make
> memset_s the function we use in our code, considering its standard
> blessing and therefore likelihood of being available on every system
> eventually.
Sounds like a future-proof way would be to implement memset_s in
src/port if absent from the OS (using explicit_bzero and other tricks),
and use that.
Here's a portable implementation (includes _WIN32 and NetBSD's
explicit_memset) under ISC license:
https://github.com/jedisct1/libsodium/blob/master/src/libsodium/sodium/utils.c#L112
(from https://www.cryptologie.net/article/419/zeroing-memory-compiler-optimizations-and-memset_s/ )
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, thomas.munro@gmail.com, peter.eisentraut@2ndquadrant.com, tgl@sss.pgh.pa.us
Subject: Re: using explicit_bzero
In-Reply-To: <20190717211931.GA906@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox