pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Guard against rare RAND_bytes() failures in pg_strong_random().
Date: Fri, 20 Jul 2018 08:12:27 +0000
Message-ID: <E1fgQWZ-0004jr-6e@gemulon.postgresql.org> (raw)

Guard against rare RAND_bytes() failures in pg_strong_random().

When built using OpenSSL, pg_strong_random() uses RAND_bytes() to
generate the random number. On very rare occasions that can fail, if
its PRNG has not been seeded with enough data. Additionally, once it
does fail, all subsequent calls will also fail until more seed data is
added. Since this is required during backend startup, this can result
in all new backends failing to start until a postmaster restart.

Guard against that by checking the state of OpenSSL's PRNG using
RAND_status(), and if necessary (very rarely), seeding it using
RAND_poll().

Back-patch to v10, where pg_strong_random() was introduced.

Dean Rasheed and Michael Paquier.

Discussion: https://postgr.es/m/CAEZATCXMtxbzSAvyKKk5uCRf9pNt4UV%2BF_5v%3DgLfJUuPxU4Ytg%40mail.gmail.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/821200405cc3f25fda28c5f58d17d640e25559b8

Modified Files
--------------
src/port/pg_strong_random.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)



view thread (3+ messages)

Message-ID: <E1fgQWZ-0004jr-6e@gemulon.postgresql.org>
Permalink:  ../E1fgQWZ-0004jr-6e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fgQWZ-0004jr-6e@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Guard against rare RAND_bytes() failures in pg_strong_random().
  In-Reply-To: <E1fgQWZ-0004jr-6e@gemulon.postgresql.org>
  References: <E1fgQWZ-0004jr-6e@gemulon.postgresql.org>

* 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