Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGMM-00051e-Dq for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2013 14:21:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VYGML-0003uW-P3 for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2013 14:21:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGMK-0003uP-QZ for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:21:28 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGMF-0007yz-MP for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:21:28 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 2E4012A37D; Mon, 21 Oct 2013 07:19:29 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 27AFB4013E; Mon, 21 Oct 2013 07:19:29 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 0DE34120032; Mon, 21 Oct 2013 07:26:31 -0700 (PDT) Received: from [192.168.43.149] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Mon, 21 Oct 2013 07:26:29 -0700 (PDT) Message-ID: <526537ED.2010607@vmware.com> Date: Mon, 21 Oct 2013 17:19:25 +0300 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Honza Horak CC: pgsql-bugs@postgresql.org Subject: Re: random() generates collisions too early References: <5261219D.3060205@redhat.com> In-Reply-To: <5261219D.3060205@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.3 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 18.10.2013 14:55, Honza Horak wrote: > On 10/18/2013 02:10 AM, Noah Misch wrote: > > sudo sysctl -w kernel.pid_max=2048 > > psql -c 'create unlogged table samp(c float8)' > > for n in `seq 1 200000`; do psql -qc 'insert into samp values > (random())'; done > > > > The results covered only 181383 distinct values, and 68 values > repeated four > > or five times each. We should at least consider using a > higher-entropy seed. > > As I was told this is not taken as a security issue, since random() is > not considered as a CSPRNG in any case, but as Noah said, we should > probably try to make it a bit better. Interesting. PostgreSQL's random() function just calls the underlying libc random() function. I assume you tested this on with Linux and glibc. > Also, I'd suggest to state explicitly in the doc, that random() > shouldn't be taken as CSPRNG, since I can imagine people blindly > believing that random() can be good enough for such use cases, just > because they see how many possible values they get from double-precision > type: > http://www.postgresql.org/docs/9.3/static/functions-math.html Yeah, that seems like a good idea. A patch would be welcome. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs