Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6138958iog; Thu, 23 Jun 2022 12:09:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLCYZSMjPJluZkD1SA4WBkEmbkiA1o78hig6c2afdmsa2euZNW1jAA8uc5he2buFmqzIEd X-Received: by 2002:a05:6402:27cf:b0:435:dae6:26aa with SMTP id c15-20020a05640227cf00b00435dae626aamr4013951ede.323.1656011368990; Thu, 23 Jun 2022 12:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011368; cv=none; d=google.com; s=arc-20160816; b=jQQtvOo/BXH1YBvJ+hJNzlhZcBy9ms2x8lZRrI6bbwnN3DJ6G8lQGvONOtoy7vOJT6 3aBPc4pN9NsvGiKDNgMOLhq11gkESnN8gxlJkeRQeSM0YFUQ45lHvhNGmEkRew1Ql+xI K0MGfy7VoMwOSgJa214U4KcHlU34GaWcQjVsXvuaFhgNw66zKfer9po/8wbG7f4/5zjQ Dng+w1icxK7f1skLhB/eAFExRW2iLhdSgmdio24eWW4VSAP7l5+2wekLi7hiAOBGy8A5 xrnhH4WkJQo85R0D05sS/Cguv+t82dYY3CY90HBxz2LMpHst+dnhKsOvVUOrPEE7TX// 6p7w== 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=JIGDRfsgEPCYssBa2Z/ZVWkAkUmtU/9PxiCTliAsnts=; b=J17EfFuryxHI006gKBTsZ9Q8T3VXuM96cpGHwjQBzxYL10MFxZ2ZfOmDW0JZfBBr7Y r85RjiCp4g+asTOAYOQrqrWLEpwkF/QZNI/j051ipiXPXnzy8OlY05xkecpexLZta2Mw uIVPxlVRPQ/66BlLF6x8aNAAOOH2J/1xTf5yZJHD+WIcEwveP+bM8Vd8Tp+I7nFUjiim vbdgvq8AJlWJAo0A5hvyit6YNg1V0Nbg4Z1kuCmePnJZ02PmFmK5jUEBirnHjCemjIRD yLhYaSHP8EdlixRbF9/+Ssapg6BvLT1RzvUFTs6HIlvzTRryjDFEUeE1AN1uO79ajjIJ sY4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JOUsGWTZ; 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 oz31-20020a1709077d9f00b006fe4c66b711si2435579ejc.46.2022.06.23.12.09.03; Thu, 23 Jun 2022 12:09:28 -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=JOUsGWTZ; 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 S235544AbiFWSAU (ORCPT + 99 others); Thu, 23 Jun 2022 14:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235883AbiFWR5r (ORCPT ); Thu, 23 Jun 2022 13:57:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA8C6F4B3; Thu, 23 Jun 2022 10:15:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1C73861E0F; Thu, 23 Jun 2022 17:15:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E21ACC3411B; Thu, 23 Jun 2022 17:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004550; bh=loYafYE5zjmnYdIqVer8tgs+VwSnZs+hHbLy9ZNlDUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOUsGWTZZF+JKHkRdCCMJR1/j1c2oixopmI3IIWgjEeRPYG3tIfY+/caRs4NjpiA9 SZz1stXlV9gEcqhp39XCoJzne+aXTpp4nortjdybazpkyYVYi9zNDorwI50XG+AA81 A3k8S/IKK6DZhp02ntneKKdX+NAMuW7WcQp2nLa8= 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.19 072/234] random: continually use hwgenerator randomness Date: Thu, 23 Jun 2022 18:42:19 +0200 Message-Id: <20220623164345.097775946@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 @@ -2193,13 +2193,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); }