Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gd2dV-0005Aa-Kd for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Dec 2018 00:37:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gd2dT-0005ik-QT for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Dec 2018 00:37:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gd2dT-0005id-Fk for pgsql-hackers@lists.postgresql.org; Sat, 29 Dec 2018 00:37:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gd2dQ-000187-RI for pgsql-hackers@postgresql.org; Sat, 29 Dec 2018 00:37:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBT0aqBr026723; Fri, 28 Dec 2018 19:36:52 -0500 From: Tom Lane To: Thomas Munro cc: Heikki Linnakangas , Peter Geoghegan , Michael Paquier , Alvaro Herrera , Adrien Nayrat , Dmitry Dolgov <9erthalion6@gmail.com>, Tomas Vondra , Vik Fearing , Robert Haas , David Rowley , Pg Hackers Subject: Re: random() (was Re: New GUC to sample log queries) In-reply-to: <10913.1546038905@sss.pgh.pa.us> References: <20181129214850.kiq6mvofsgplqjdr@alvherre.pgsql> <3859.1545849900@sss.pgh.pa.us> <20181227013458.GF2106@paquier.xyz> <32696.1545875185@sss.pgh.pa.us> <2820.1545878340@sss.pgh.pa.us> <9703.1545939393@sss.pgh.pa.us> <10913.1546038905@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 28 Dec 2018 18:15:05 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26721.1546043812.1@sss.pgh.pa.us> Date: Fri, 28 Dec 2018 19:36:52 -0500 Message-ID: <26722.1546043812@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > Looking at this, I seem to remember that we considered doing exactly this > awhile ago, but refrained because there was concern about depleting the > system's reserve of entropy if we have a high backend spawn rate, and it > didn't seem like there was a security reason to insist on unpredictable > random() results. However, the log-sampling patch destroys the latter > argument. As for the former argument, I'm not sure how big a deal that > really is. Presumably, the act of spawning a backend would itself > contribute some more entropy to the pool (particularly if a network > connection is involved), so the depletion problem might be fictitious > in the first place. Also, a few references I consulted, such as the > Linux urandom(4) man page, suggest that even in a depleted-entropy > state the results of reading /dev/urandom should be random enough > for all but the very strictest security requirements. I did some experimentation, watching /proc/sys/kernel/random/entropy_avail while continuously spawning backends, and I can't see any difference in behavior with or without this patch. If there is any effect at all, it's completely swamped by other noise (and there's a lot of noise, even on a machine that's idle). Also, further googling says there's a pretty sizable body of opinion that Linux's available-entropy calculation is bogus anyway: once the system's acquired a reasonable amount of entropy, no amount of reading from /dev/urandom will cause the randomness of the results to decrease. So there's no reason to be concerned about whether we're reading it "too much". regards, tom lane