From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751496AbdAREuV (ORCPT ); Tue, 17 Jan 2017 23:50:21 -0500 Received: from imap.thunk.org ([74.207.234.97]:55882 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdAREuT (ORCPT ); Tue, 17 Jan 2017 23:50:19 -0500 Date: Tue, 17 Jan 2017 22:49:07 -0500 From: "Theodore Ts'o" To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, Hannes Frederic Sowa , Andy Lutomirski Subject: Re: [PATCH 1/2] random: use chacha20 for get_random_int/long Message-ID: <20170118034907.spozwf4erlvx5s4x@thunk.org> Mail-Followup-To: Theodore Ts'o , "Jason A. Donenfeld" , linux-kernel@vger.kernel.org, Hannes Frederic Sowa , Andy Lutomirski References: <20170106183202.5035-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170106183202.5035-1-Jason@zx2c4.com> User-Agent: NeoMutt/20161126 (1.7.1) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jason, I've been taking a look at your patch, and i think it's... problematic. You're using a union for the entropy_u64 and entropy_u32 arrays, and the position field is used to indexed into those two arrays. So if the first caller calls get_random_u64 with position=0, it will get the first 64 bits out of the batched entropy, and increment the position to 1. If the second caller calls get_random_u32 with position=1... it will get the second of the 32-bit chunks in the batched entropy array --- which will include the 64 bits returned to the first caller. That's not very random. :-( - Ted