From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12966 invoked by alias); 13 Jun 2013 08:26:32 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 12869 invoked by uid 89); 13 Jun 2013 08:26:26 -0000 X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,DATE_IN_PAST_03_06,FREEMAIL_FROM,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SPF_NEUTRAL autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from popelka.ms.mff.cuni.cz (HELO popelka.ms.mff.cuni.cz) (195.113.20.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 13 Jun 2013 08:26:24 +0000 Received: from domone.kolej.mff.cuni.cz (popelka.ms.mff.cuni.cz [195.113.20.131]) by popelka.ms.mff.cuni.cz (Postfix) with ESMTPS id 894646945E; Thu, 13 Jun 2013 10:26:19 +0200 (CEST) Received: by domone.kolej.mff.cuni.cz (Postfix, from userid 1000) id 54BAB5FB95; Thu, 13 Jun 2013 06:52:06 +0200 (CEST) Date: Thu, 13 Jun 2013 08:26:00 -0000 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: bugdal at aerifal dot cx Cc: glibc-bugs@sourceware.org Subject: Re: [Bug libc/15615] New: Poor quality output from rand_r Message-ID: <20130613045205.GA28960@domone.kolej.mff.cuni.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-SW-Source: 2013-06/txt/msg00097.txt.bz2 On Wed, Jun 12, 2013 at 11:39:09PM +0000, bugdal at aerifal dot cx wrote: > http://sourceware.org/bugzilla/show_bug.cgi?id=15615 > > Bug ID: 15615 > Summary: Poor quality output from rand_r > Product: glibc > Version: unspecified > Status: NEW > Severity: normal > Priority: P2 > Component: libc > Assignee: unassigned at sourceware dot org > Reporter: bugdal at aerifal dot cx > CC: drepper.fsp at gmail dot com > > Created attachment 7075 > --> http://sourceware.org/bugzilla/attachment.cgi?id=7075&action=edit > test program to generate data for analysis by dieharder > > Implementing a decent rand_r is very tricky because the interface requirement > forces the full PRNG state to fit in 32 bits; this rules out pretty much all > good PRNGs. Nonetheless, glibc's rand_r is much worse than it needs to be. > > glibc's rand_r is based on the LCG published in the C standard: > > next = next * 1103515245 + 12345; > return next / 65536 % 32768; > A problem here is that for many users predictability is much more important than quality. Developer expects that when he uses rand_r with state that he controls will not vary. This can cause extra debbuging hastle when code mysteriously fails on one machine but not other or desync issues. > To fully fix rand_r, the approach of concatenating multiple iterations should > be abandoned in favor of a single-LCG-iteration approach followed by an > invertable transformation on the output. Obviously a 32-bit cryptographic block > cipher would give the best statistical properties, but it would be slow. In This is false, I have a replacement of this with four rounds of AES. On intel using aesenc I performance is better than current, I did not propose that due of problems above. I wrote a RFC for random replacement on libc-alpha, browse archives.