Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751509AbdFHMCK (ORCPT ); Thu, 8 Jun 2017 08:02:10 -0400 Received: from la.guarana.org ([173.254.219.205]:52144 "EHLO la.guarana.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbdFHMCI (ORCPT ); Thu, 8 Jun 2017 08:02:08 -0400 Date: Thu, 8 Jun 2017 08:02:02 -0400 From: Kevin Easton To: "Jason A. Donenfeld" Cc: "Theodore Ts'o" , Linux Crypto Mailing List , LKML , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , David Miller , Herbert Xu Subject: Re: [PATCH v3 04/13] crypto/rng: ensure that the RNG is ready before using Message-ID: <20170608120202.GA19250@la.guarana.org> References: <20170606005108.5646-1-Jason@zx2c4.com> <20170606005108.5646-5-Jason@zx2c4.com> <20170606030004.4go6btmobrsmqiwz@thunk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1064 Lines: 26 On Tue, Jun 06, 2017 at 05:56:20AM +0200, Jason A. Donenfeld wrote: > Hey Ted, > > On Tue, Jun 6, 2017 at 5:00 AM, Theodore Ts'o wrote: > > Note that crypto_rng_reset() is called by big_key_init() in > > security/keys/big_key.c as a late_initcall(). So if we are on a > > system where the crng doesn't get initialized until during the system > > boot scripts, and big_key is compiled directly into the kernel, the > > boot could end up deadlocking. > > > > There may be other instances of where crypto_rng_reset() is called by > > an initcall, so big_key_init() may not be an exhaustive enumeration of > > potential problems. But this is an example of why the synchronous > > API, although definitely much more convenient, can end up being a trap > > for the unwary.... > > Thanks for pointing this out. I'll look more closely into it and see > if I can figure out a good way of approaching this. Would it work for wait_for_random_bytes() to include a WARN_ON(system_state < SYSTEM_RUNNING); to catch those kinds of cases? - Kevin