Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp846634rwb; Thu, 22 Sep 2022 07:09:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7v05gJ57gZTc79/MaJEm+kFMkvnsykUwpBSAGCDEjVpKEpCd08dr52Mra3SR2oIGfjxZuH X-Received: by 2002:a17:90b:17c5:b0:202:596d:6e40 with SMTP id me5-20020a17090b17c500b00202596d6e40mr15799865pjb.53.1663855777788; Thu, 22 Sep 2022 07:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663855777; cv=none; d=google.com; s=arc-20160816; b=qI4LAsYDCqMXIg+YhdAZ45KpsXCAIB/nWZEOA5elAVar2Pj1Fi0peq24utU8IjvlZW HsyDegUV5qkDvANSP7Ugq8tAIpcBH4Mhx+89Bux66lmteFxo4ixPgvQCkzQm8cfTYCIQ rC7qK5RU05fFT2TaEf4nefFz9nQb+t/kHRQ0GngCy07dFgE8vUCEoB4iJ1VXlqxAndw+ JSSTPOkWyMW48ITMwbVFKPQBMQSv4vzIPVH4B9ZEelFZnHyKWoqexUKL14ngz4y8seDB YM6g+/vq3+BBVxjE1C9lDytd07n0CdLC3zUR8vB5CBdX6AGD3CMY7CsxE7nB4sP/nagP Ca5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gJsBUPhxWLjFen34ThaI929R4nRyqRqke+/LMNrwYJI=; b=Bjx/hov0UfiQU6VKfKdh9VLtvq1nBhkLLb5ajfZKkNTzWHzLQOtc9p/NJIL1l6wujs yZZRldbTU2P33lJhV5U30ud9JH/+sZ20TcCVsn3Yh114dhRGEJnNcjnU/d50TnNTrF00 9JxkFhKK7gezhsmSEzLGIUx8iSMepkva8CvAvAJ4HkHOrtpDEpBuGLsehxwXp34vJBOE IxyG/FAfw0hXqAQDk9HhbkuZ+bfa24J4XZ2lXP8PtyDjv4NSfgKDGxjZwmnU6dK+kYw4 GKabSHiYpYd+I999piJteKYYHqt7K8td7sVusl3ja996pQ5kaVyTTQamPrvZvsiO5eVf gQ0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a056a000c8400b00536f8a6acadsi6621235pfv.2.2022.09.22.07.09.17; Thu, 22 Sep 2022 07:09:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbiIVOCC (ORCPT + 99 others); Thu, 22 Sep 2022 10:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiIVOB5 (ORCPT ); Thu, 22 Sep 2022 10:01:57 -0400 Received: from isilmar-4.linta.de (isilmar-4.linta.de [136.243.71.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62583D0795; Thu, 22 Sep 2022 07:01:55 -0700 (PDT) X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES Received: from owl.dominikbrodowski.net (owl.brodo.linta [10.2.0.111]) by isilmar-4.linta.de (Postfix) with ESMTPSA id 304A8201342; Thu, 22 Sep 2022 14:01:53 +0000 (UTC) Received: by owl.dominikbrodowski.net (Postfix, from userid 1000) id 2B27B80607; Thu, 22 Sep 2022 15:51:05 +0200 (CEST) Date: Thu, 22 Sep 2022 15:51:05 +0200 From: Dominik Brodowski To: "Jason A. Donenfeld" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Herbert Xu Subject: Re: [PATCH] random: throttle hwrng writes if no entropy is credited Message-ID: References: <20220920141438.2782446-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220920141438.2782446-1-Jason@zx2c4.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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-crypto@vger.kernel.org Hi Jason, thanks for splitting this change out of my other patch. You can add my Signed-off-by, but I'd like to suggest rewriting the commit message as follows (please modify as needed): In case a hwrng source does not provide (trusted) entropy, it cannot assist in initializing the CRNG. Therefore, in case add_hwgenerator_randomness() is called with the entropy parameter set to zero, go to sleep until one reseed interval has passed. While the hwrng thread currently only runs under conditions where this is non-zero, this change is not harmful and prepares for future updates to the hwrng core. Thanks, Dominik Am Tue, Sep 20, 2022 at 04:14:38PM +0200 schrieb Jason A. Donenfeld: > This value is currently never set to zero, because the hwrng thread only > runs if it's going to be non-zero. This is an oversight, however, that > Dominik is working on fixing. In preparation for this, and so that > there's less coordination required between my tree and Herbert's, make > this currently useless, but not harmful, change here now, in hopes that > Dominik can make the corresponding change in the hwrng core later. > > Cc: Dominik Brodowski > Cc: Herbert Xu > Signed-off-by: Jason A. Donenfeld > --- > drivers/char/random.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/random.c b/drivers/char/random.c > index 16e0c5f6cf2f..520a385c7dab 100644 > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -865,9 +865,9 @@ void add_hwgenerator_randomness(const void *buf, size_t len, size_t entropy) > > /* > * Throttle writing to once every reseed interval, unless we're not yet > - * initialized. > + * initialized or no entropy is credited. > */ > - if (!kthread_should_stop() && crng_ready()) > + if (!kthread_should_stop() && (crng_ready() || !entropy)) > schedule_timeout_interruptible(crng_reseed_interval()); > } > EXPORT_SYMBOL_GPL(add_hwgenerator_randomness); > -- > 2.37.3 >