From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8908AC433EF for ; Mon, 21 Feb 2022 04:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244699AbiBUEOS (ORCPT ); Sun, 20 Feb 2022 23:14:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiBUEOQ (ORCPT ); Sun, 20 Feb 2022 23:14:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 375784A3E2 for ; Sun, 20 Feb 2022 20:13:54 -0800 (PST) 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 C625F60FFA for ; Mon, 21 Feb 2022 04:13:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10283C340E9; Mon, 21 Feb 2022 04:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645416833; bh=G+Eis18y1zWCvepauh467PZlzV5JvJWkGiTP2FYEHIE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GuIj1QjiZtpnObcEWOW+joK3W8yJQoBHq4RZActqvRwtdm0V1D4bV/DoJx92cf2dm Jrad6NO32HMf0wtBIZIG6gdBxt1g5+woQAfF+vfhMVn+xXFB9OETkWmcd2Ksh8578i P3nGdw3tTYZLBYltAFXTsg9ua4dK2j7+xDiaSpMSRB/RZ0fy5A1vZ0NkggVvHeOq6c 2HArAGWFYSMrsSqpmeF1A6XzLt/ypCQ9YfPjuTlkdseU2hk7u+yANNLV3khZHVJ6KE w0qlWDh8A4Ptbu31KaLveV/uBGNUHpjcT4Mpsxhh8j98u0IYpxPdtRuCM96tR5Tiwc FN9AXAKFjWVrw== Date: Sun, 20 Feb 2022 20:13:51 -0800 From: Eric Biggers To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, Theodore Ts'o , Dominik Brodowski Subject: Re: [PATCH v2] random: tie batched entropy generation to base_crng generation Message-ID: References: <20220210131304.97224-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220210131304.97224-1-Jason@zx2c4.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 10, 2022 at 02:13:04PM +0100, Jason A. Donenfeld wrote: > Now that we have an explicit base_crng generation counter, we don't need > a separate one for batched entropy. Rather, we can just move the > generation forward every time we change crng_init state or update the > base_crng key. > > Cc: Theodore Ts'o > Reviewed-by: Dominik Brodowski > Signed-off-by: Jason A. Donenfeld > --- > v2 always increments the generation after extraction, as suggested by > Dominik. > > drivers/char/random.c | 29 ++++++++--------------------- > 1 file changed, 8 insertions(+), 21 deletions(-) Reviewed-by: Eric Biggers One comment below: > @@ -455,7 +453,7 @@ static size_t crng_fast_load(const void *cp, size_t len) > src++; crng_init_cnt++; len--; ret++; > } > if (crng_init_cnt >= CRNG_INIT_CNT_THRESH) { > - invalidate_batched_entropy(); > + ++base_crng.generation; > crng_init = 1; > } This is an existing issue, but why doesn't crng_slow_load() do this too? - Eric