From patchwork Fri Jun 2 16:48:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9763059 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EE2D60360 for ; Fri, 2 Jun 2017 16:48:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F18828588 for ; Fri, 2 Jun 2017 16:48:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60F252855C; Fri, 2 Jun 2017 16:48:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5504C2855C for ; Fri, 2 Jun 2017 16:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751164AbdFBQs2 (ORCPT ); Fri, 2 Jun 2017 12:48:28 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:36861 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbdFBQs2 (ORCPT ); Fri, 2 Jun 2017 12:48:28 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d90ac54e; Fri, 2 Jun 2017 16:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :in-reply-to:references:from:date:message-id:subject:to :content-type; s=mail; bh=Hi0/Gc1c0wnDmswR3oX3SvkLDVE=; b=su5tKM 2Jtup13h8Yd77hCNeTMVioVq0nkY6cjLsLm91udFawuLQLDx6Kh8KnnIc2G2jlm7 vJ0fJ3ebCTSK5lKUKGqTyDc5t/Aka7ning5cFMcMTqzZFAefg/glfyBLroQQmbQ4 Ryg6ySO5a7SM9g/UQEz+QiY/aQqZ10ijv6d/JyaKR4iklZpcQOGrWH8HxjJkQ4Wu 73OAOcOrXl+d2MMj03E06r47Nt56xgo4qHMrWHeVJgRjRtnPv53f4d7ZBK09F6ZD pjRQ1rYq4WbK8GIerzjcJGVRPEWU0Hhc5mIZJi5KjVFk9YyInWk2XbGD/oz/Kkpq kmT6xZsiauAZI+zg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 6d1d38e8 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Fri, 2 Jun 2017 16:46:28 +0000 (UTC) Received: by mail-oi0-f47.google.com with SMTP id l18so98840347oig.2; Fri, 02 Jun 2017 09:48:26 -0700 (PDT) X-Gm-Message-State: AKS2vOwi98noAIIDZhvBvnujVzaoivu+8gOrQjlZkRfMMUZFiwVrN9bB vqg7QPEJfSyLYwmrjupJ07GwiSuMtQ== X-Received: by 10.157.31.71 with SMTP id x7mr5502674otx.249.1496422105884; Fri, 02 Jun 2017 09:48:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.17.129 with HTTP; Fri, 2 Jun 2017 09:48:25 -0700 (PDT) In-Reply-To: References: From: "Jason A. Donenfeld" Date: Fri, 2 Jun 2017 18:48:25 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: get_random_bytes returns bad randomness before seeding is complete To: Stephan Mueller , "Theodore Ts'o" , Linux Crypto Mailing List , LKML , kernel-hardening@lists.openwall.com, Herbert Xu Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Further investigations: if the whack-a-mole approach is desirable, perhaps many of those get_random_bytes calls should be converted to get_blocking_random_bytes. In that case, this commit, which removed this helpful API, should be reverted: commit c2719503f5e1e6213d716bb078bdad01e28ebcbf Author: Herbert Xu Date: Tue Jun 9 18:19:42 2015 +0800 random: Remove kernel blocking API This patch removes the kernel blocking API as it has been completely replaced by the callback API. Signed-off-by: Herbert Xu diff --git a/drivers/char/random.c b/drivers/char/random.c index a1576ed1d88e..d0da5d852d41 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1265,18 +1265,6 @@ void get_random_bytes(void *buf, int nbytes) EXPORT_SYMBOL(get_random_bytes); /* - * Equivalent function to get_random_bytes with the difference that this - * function blocks the request until the nonblocking_pool is initialized. - */ -void get_blocking_random_bytes(void *buf, int nbytes) -{ - if (unlikely(nonblocking_pool.initialized == 0)) - wait_event(urandom_init_wait, nonblocking_pool.initialized); - extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); -} -EXPORT_SYMBOL(get_blocking_random_bytes); - -/*