Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2939741iog; Mon, 20 Jun 2022 07:55:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vsgh4KU+2uBz+R/eKKOSweHSfSQlat8d0zsFuKHmdxYKTR8m84o9RGhXjYETJhDCO8kNo0 X-Received: by 2002:a17:906:1193:b0:70d:cf39:a4db with SMTP id n19-20020a170906119300b0070dcf39a4dbmr21564380eja.44.1655736933898; Mon, 20 Jun 2022 07:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736933; cv=none; d=google.com; s=arc-20160816; b=Uk+kvbiFUrD6ZJ6hMZF/I6D/NxhBUlDjAoVLMc8hfptdIu4aDrK8jd8v69LMhdjznb mWW0bDZKpleq4ArjlmzLHOqC/fzKu9cGe5Lw+PDgkVtMLVyXoXZJE58SECRJfLhi+V0D HCprzE07gJKd1CRLJIBGrln/3OS8hHv9Mgr5ExxegZ+tRqMSoY90c4cn7LR0qGuKcjEm Nx5D/VnkQIZCaaMRxix8lP8Oink8DoJv37VXH2k10WEkVvkEzL8bXbXgeaHhhoCHqdBY 8J7QZyRqSRzathPUaeqq/0JZDkUsTF5IduHtMbdG+XXHDCYCNfmldBhdL8ftv+/iUAxF XXCQ== 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=nKOIQ+UYVwsf6HExq3eapa+yNeynkc5m2nUVm8Kqmrs=; b=cBGaJFIfWOgKphAHiuOdv014bNWfmOilkdGj8BzuR9cDH8JrFt+CDe3XSubOtLCLwA hWoAVJnsQ/2dZnYXD2ma428SdgptezTAgm32jqZGJECOIToZiNjny9WKJAI1JDN+zV/K wlNdz5eSOXpKV+FuoFnwDuxs+aQ55xE/tcutSIHfC8ewCmonWVzpKoQ8CeObnoJ7ouWB zL7KlgwY0QtymhK/NNzpNf+c1QMgak7ayBLLOq31NEWSCYoIcrY5f7uGppHnYoMCypef FDcWYfS0DSt7cfgTBoWVXPqYzDsvCKBLmHMQJyAAkmH/RHe+B8JABbDUQTA1KFmDsXZf ULVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sTOFSXqm; 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 d4-20020a1709067a0400b0070bf25f1732si9059914ejo.155.2022.06.20.07.55.04; Mon, 20 Jun 2022 07:55:33 -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=sTOFSXqm; 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 S1346694AbiFTNiH (ORCPT + 99 others); Mon, 20 Jun 2022 09:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346925AbiFTNhF (ORCPT ); Mon, 20 Jun 2022 09:37:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8E22871B; Mon, 20 Jun 2022 06:14:02 -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 3C84B60FEF; Mon, 20 Jun 2022 13:13:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 432A5C3411B; Mon, 20 Jun 2022 13:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730814; bh=UQJ6FlovxwQc5SOGJLgNN+YfADKK5QP7JctfBCH+YzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTOFSXqm9bMUOvBq99Z1GHxj7tA3QmxkDuQT+l/WXUNA6soHMCIumqc0B6nTTsXAy 1AI5t8QuJpsmL+EUth/7t6qrK4XTchY6nhLhVFSp9V315Eg1ena+BVj6Az1wGZ5ZU+ +/7/AefcionLI02WtsfthqrDDSxQmPQS+Mktuxew= 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 5.4 062/240] random: continually use hwgenerator randomness Date: Mon, 20 Jun 2022 14:49:23 +0200 Message-Id: <20220620124740.133004351@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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 @@ -2195,13 +2195,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); }