Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bw9iJ-00059s-OB for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 15:20:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bw9iJ-0001mB-42 for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2016 15:20:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bw9gu-0000A1-6w for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 15:19:04 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bw9gq-0002d8-W2 for pgsql-hackers@postgresql.org; Mon, 17 Oct 2016 15:19:03 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id C25145F799; Mon, 17 Oct 2016 11:18:14 -0400 (EDT) Date: Mon, 17 Oct 2016 11:18:14 -0400 From: Stephen Frost To: Heikki Linnakangas Cc: Tom Lane , Heikki Linnakangas , pgsql-hackers@postgresql.org Subject: Re: Re: [COMMITTERS] pgsql: Replace PostmasterRandom() with a stronger way of generating ran Message-ID: <20161017151814.GV13284@tamriel.snowman.net> References: <26591.1476715823@sss.pgh.pa.us> <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="SvWan4890fseGSLw" Content-Disposition: inline In-Reply-To: <4f31c7c5-817c-aa3b-ae48-a613008dc558@iki.fi> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 11:13:32 up 100 days, 16:37, 21 users, load average: 0.01, 0.06, 0.11 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --SvWan4890fseGSLw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Heikki Linnakangas (hlinnaka@iki.fi) wrote: > On 10/17/2016 05:50 PM, Tom Lane wrote: > >Heikki Linnakangas writes: > >>Replace PostmasterRandom() with a stronger way of generating randomness. > > > >This patch broke padmeleon: > > > >016-10-17 09:57:17.782 EDT [5804d8bd.57c2:1] LOG: database system was s= hut down at 2016-10-17 09:57:17 EDT > >2016-10-17 09:57:17.790 EDT [5804d8bd.57c2:2] LOG: MultiXact member wra= paround protections are now enabled > >2016-10-17 09:57:17.807 EDT [5804d8bd.57c6:1] LOG: autovacuum launcher = started > >2016-10-17 09:57:17.820 EDT [5804d8bd.57bf:1] LOG: database system is r= eady to accept connections > >2016-10-17 09:57:18.516 EDT [5804d8bd.57bf:2] LOG: could not generate r= andom query cancel key > >2016-10-17 09:57:19.544 EDT [5804d8bd.57bf:3] LOG: could not generate r= andom query cancel key > >2016-10-17 09:57:20.563 EDT [5804d8bd.57bf:4] LOG: could not generate r= andom query cancel key > >2016-10-17 09:57:21.584 EDT [5804d8bd.57bf:5] LOG: could not generate r= andom query cancel key > >2016-10-17 09:57:22.604 EDT [5804d8bd.57bf:6] LOG: could not generate r= andom query cancel key > > > >It's failing because this machine lacks /dev/random and /dev/urandom. > >It does have a non-kernel entropy daemon (prngd), which OpenSSL knows how > >to read from but the hard-wired code in pg_strong_random() does not. > > > >I'm not sure whether it's worth trying to make pg_strong_random() aware > >of prngd. >=20 > Seems simple enough.. If it is, then that's certainly tempting, especially if that's the only platform we support where we don't have a better option, and we wish to continue supporting it. > > The real issue here is whether we are willing to say that > >Postgres simply does not work anymore on machines without standard entro= py > >sources. Doesn't matter whether the user cares about the strength of > >cancel keys, we're just blowing them off. That seems a bit extreme > >from here. I think we should be willing to fall back to the old code > >if we can't find a real entropy source. >=20 > I'm scared of having pg_strong_random() that is willing to fall back > to not-so-strong values. We can rename it, of course, but it seems > dangerous to use a weak random-number generator for authentication > purposes (query cancel, MD5 salts, SCRAM nonces). >=20 > I think both for the MD5 salt and SCRAM, it doesn't have to be > unpredictable to attackers, as long the attacker cannot influence it > so that a particular value is chosen. For query cancel, it needs to > be unpredictable, but the query cancel key is quite short anyway, > and we haven't worried about it so far anyway, because an attacker > can't do very much damage by just canceling queries. >=20 > One option would be to disable query-canceling and MD5 (and SCRAM) > authentication, if we don't have an entropy source. Wouldn't it be possible to make this a build-time question..? I don't particularly like the idea of pg_strong_random() falling back to not-strong values, but maybe we could have a '--use-weak-random' configure switch for platforms that don't provide a strong source. Then again, if we wish to support this platform, then perhaps we should put in the effort to support prngd. Thanks! Stephen --SvWan4890fseGSLw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJYBOu2AAoJEO1sijiDR2RV4KYP/jiThVE1NXqVp+tevjKb5qVj NK+PtUKabbvwqBiByTPuP+IPWI5eukzBqemFX1oNqMstAml4BqPU1cATJlSqYi6F bh7BxYALYhHevJIj1SIsVn94JURRhKQ07C95r//X2gBSNGzt7CI35j1p1YNjPlf8 4ZGT2M2QKPdagIaSxOJI8A3Ye963Poh1IwNU3MhKXRknD+CVx42ifxrEL0q4sKcS 4a7apnTrSyFesgfRCUoWLPCKMUP2ZSEk6NoORMz6744sQY9pEVC6PMk0hQ59tUuF JOvw87N7NWWE4GCYT4DPi/c5/WW/0j9VVZWNYYEOaDMuZctDplzyDWFc0LtXZdUE wghL+rzsWGzu3tPzI3iACc7Ou1MIpEt/iKZQaDaXwcejJUgs1Cw37NmPFSb9c4K+ HCx1B+HTHF4ZnH1E4GifKvmLwwjftFnU1K44yWTwkoRWVGnEa5BThNWHzsbFm8RD bfcf8YehioBCLmdLUQ/jDLWae6lHkPqlUr5z0vXti6BhuyHjL7RbUtaeDkml/C0Z UAxYT7VTFROoqV2DjXwReQiE86dJFqf0Qlcx/NdiK+48qsne6xT2rwxO3RQDRtdS RiNV5GsbMu82ImIbEdteQrmxvzDrhOci5pfIbreF7Wgo6qRbPcm7BaXDk/rk/5Lf 2tcUD6W76SUIXoLtNmfH =PIJa -----END PGP SIGNATURE----- --SvWan4890fseGSLw--