Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6160699iog; Thu, 23 Jun 2022 12:37:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhv/EIQ51eyK+e2jWg8lePQIikZL7Swhp75KcZHZ5ghvlcSOiJA4wfiEalgMWMw1DZYN/s X-Received: by 2002:a17:902:d48e:b0:167:5752:3b43 with SMTP id c14-20020a170902d48e00b0016757523b43mr39748689plg.52.1656013031733; Thu, 23 Jun 2022 12:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656013031; cv=none; d=google.com; s=arc-20160816; b=lHXXSHWYbrAjy5oXUjEN7uYCuny0+emakY7gjzE411Bgx1KQAuLtAQ09U0hyaBpZDv jzdXlmTFBE/jZpvYH2qF2vpsDoiaTiFHrGcVh8Sqo0xL25mOsKwsYsmMZMpdTcSpw98J gUrY/4jnF0EvFAm3Khy55kwbhgFk7XhsiWUmyTan68wXFhgYA55GLLPR9gBlub2qaqkZ DeC70LnaaqRA2cTK1Xwlkfxj6P5erwj+5YxLG44usy2g8Etc0cp0V2TOmD8drv4s9MAW kesjITXiahXnl/RLDcftxFwnPs1sOFhP+TPqcgQHynlf03JFsYJ3ip02Ns9mc2W3hhUW 0EQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GLHosYw61ITeM/TxzrJrNQFbAwsiWWQa9cw32DEr4SA=; b=k5C/D24QVRJibFnQwa0s45aGHp2LrHduH/IU01f2wi4dqrNF//mPRoUcIBkM3ZkQQK 9MAlP0efngbXPBpzhfFhZH6u12Ca0ezm/kOm1RiS0XDiMCifsdRt7uxzbilpcnh1FtRN K4LfxuTHqxqIzbVReV76f7OeGLC7wGZm/8SrCg/KuU7YiLmX8RT8necMcHYKShfnxh7O PJ0E8/NaIfsUDcyRXZlC3BE+QE6hV95yM6ZgbrmeGqnRamKsdHTX4nFEUZyX4AdZwI/j dnRTsHNKS79EJ4hbx4icSelH04KMTuAms6r1cSpgQCunjwYEauIJMSNuswvPJDI+F3Rm bMGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hj7aG7+0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020aa796b6000000b005191e154399si38597pfk.258.2022.06.23.12.36.59; Thu, 23 Jun 2022 12:37:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hj7aG7+0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbiFWRNh (ORCPT + 99 others); Thu, 23 Jun 2022 13:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiFWRLl (ORCPT ); Thu, 23 Jun 2022 13:11:41 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66B0BFD26; Thu, 23 Jun 2022 09:50:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C347DCE25DE; Thu, 23 Jun 2022 16:50:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93925C3411B; Thu, 23 Jun 2022 16:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003031; bh=cMW0RWQwvnmaeI4SjGqV7oxsiHkLWotEGjxucDFTelw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hj7aG7+0e9EuI+EkcSac2XUX7bPg2+eCXFPGb6k+O+EUHdSjVf1fvdPDVNnFOgB8K jnnICNnxxX77QomLbvMVpL4WZnrMCgCYnjFFhPaTfoFMYGiatapZWq09YVQT/80QAB u/yHF8N3mdTGry9/CwIS5LXSMBDZLGjxpSToNbV4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , "Jason A. Donenfeld" , Dominik Brodowski Subject: [PATCH 4.9 107/264] random: continually use hwgenerator randomness Date: Thu, 23 Jun 2022 18:41:40 +0200 Message-Id: <20220623164347.096943607@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dominik Brodowski commit c321e907aa4803d562d6e70ebed9444ad082f953 upstream. The rngd kernel thread may sleep indefinitely if the entropy count is kept above random_write_wakeup_bits by other entropy sources. To make best use of multiple sources of randomness, mix entropy from hardware RNGs into the pool at least once within CRNG_RESEED_INTERVAL. Cc: Herbert Xu Cc: Jason A. Donenfeld Signed-off-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2244,13 +2244,15 @@ void add_hwgenerator_randomness(const ch return; } - /* Suspend writing if we're above the trickle threshold. + /* Throttle writing if we're above the trickle threshold. * We'll be woken up again once below random_write_wakeup_thresh, - * or when the calling thread is about to terminate. + * when the calling thread is about to terminate, or once + * CRNG_RESEED_INTERVAL has lapsed. */ - wait_event_interruptible(random_write_wait, + wait_event_interruptible_timeout(random_write_wait, !system_wq || kthread_should_stop() || - POOL_ENTROPY_BITS() <= random_write_wakeup_bits); + POOL_ENTROPY_BITS() <= random_write_wakeup_bits, + CRNG_RESEED_INTERVAL); mix_pool_bytes(buffer, count); credit_entropy_bits(entropy); }