| From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
|---|---|
| To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Cc: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: using explicit_bzero |
| Date: | 2019-07-17 21:19:31 |
| Message-ID: | 20190717211931.GA906@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Darafei Komяpa Praliaskouski | 2019-07-17 21:20:21 | Re: Unwanted expression simplification in PG12b2 |
| Previous Message | Tom Lane | 2019-07-17 20:58:14 | Re: Unwanted expression simplification in PG12b2 |