pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: using explicit_bzero
Date: Sat, 6 Jul 2019 15:11:09 +0200
Message-ID: <09642d41-d90a-d2f1-2c6f-12e29c4a878a@2ndquadrant.com> (raw)
In-Reply-To: <CA+hUKGKAWKp-h9MX4VA4z3N2Mf1JqhZL0OkOm=n2S2xSpCT1Xg@mail.gmail.com>
References: <42d26bde-5d5b-c90d-87ae-6cab875f73be@2ndquadrant.com>
	<27860.1561123531@sss.pgh.pa.us>
	<26f25674-9c4d-241f-0e74-3fee9860ca13@2ndquadrant.com>
	<2b38e01a-0f7c-33f8-d4a9-edfcf85f9e4b@2ndquadrant.com>
	<CA+hUKGL2mmC43Oe2DouyvvEOmoKCGu82n7+oQ_jznCLwM15DZw@mail.gmail.com>
	<09ed59aa-8ef0-3cc0-f812-0bf93e959f09@2ndquadrant.com>
	<CA+hUKGKAWKp-h9MX4VA4z3N2Mf1JqhZL0OkOm=n2S2xSpCT1Xg@mail.gmail.com>

On 2019-07-05 23:02, Thomas Munro wrote:
> On Sat, Jul 6, 2019 at 1:07 AM Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
>> On 2019-07-05 14:06, Thomas Munro wrote:
>>> +#ifndef HAVE_EXPLICIT_BZERO
>>> +#define explicit_bzero(b, len) memset(b, 0, len)
>>> +#endif
>>>
>>> I noticed some other libraries use memset through a function pointer
>>> or at least define a function the compiler can't see.
>>
>> I don't understand what you are getting at here.
> 
> Do we want to provide a replacement implementation that actually
> prevents the compiler from generating no code in some circumstances?
> Then I think we need at least a function defined in another
> translation unit so the compiler can't see what it does, no?

I see.  My premise, which should perhaps be explained in a comment at
least, is that on an operating system that does not provide
explicit_bzero() (or an obvious alternative), we don't care about
addressing this particular security concern, since the rest of the
operating system won't be secure in this way either.  It shouldn't be
our job to fight this battle if the rest of the OS doesn't care.

An alternative patch would define explicit_bzero() to nothing if not
available.  But that might create bugs if subsequent code relies on the
memory being zeroed, independent of security concerns, so I changed it
to use memset() so that at least logically both code paths are the same.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (35+ messages)  latest in thread

Message-ID: <09642d41-d90a-d2f1-2c6f-12e29c4a878a@2ndquadrant.com>
Permalink:  ../09642d41-d90a-d2f1-2c6f-12e29c4a878a@2ndquadrant.com/
Also on:    postgresql.org/message-id/09642d41-d90a-d2f1-2c6f-12e29c4a878a@2ndquadrant.com

 · 

reply

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: peter.eisentraut@2ndquadrant.com, thomas.munro@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: using explicit_bzero
  In-Reply-To: <09642d41-d90a-d2f1-2c6f-12e29c4a878a@2ndquadrant.com>

* 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