Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp586948rwb; Tue, 27 Sep 2022 01:37:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7dGOSnSlP85bEpo0eIIJO2ooilbW5K07A6lPUWZth6t6UIZFnSihWvWQK02a+swjbLzGch X-Received: by 2002:a63:587:0:b0:43c:da81:963f with SMTP id 129-20020a630587000000b0043cda81963fmr4701537pgf.123.1664267871249; Tue, 27 Sep 2022 01:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664267871; cv=none; d=google.com; s=arc-20160816; b=ZBE/RGu/KKkjreSzeRriDfH/dQLdntSUpjS+6CQ1EH2SFuIP88JSR8CfTK1XQuSdga EJe+Jyew+ifvfhE6ntzG7c8iwHSNE1Z+CoddmuzZH8K0gEoANjMQqt7P7r8DLz+8CKPB nhUz4EtAvZBujo/AcaZ7QsFENBdHkHpOhinj2PFEWa/wQDw238/RHIAPRawuWqyTMPeD qf6UbfqoWblH4obr+pf8wsD3V4r3DBRCa+pGQF0RT7aXR6SzMWzWW6nCXG4P19JH/Sy3 hW60GhsjHy56b6HFF9nGbacyrS1UQXlq7aIi8FfPeJd6bNwvBcArs185oem9yd3btQxL 5Y6w== 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=HQirqvyR11JUrFWBiZTkWi870cgxn67Y2EKlmqXlH+c=; b=XkC47mrBHhax2K5A9iIE0j9pKp95BoOiiP2MDAN6lIsOo+LM01IzHCuL7GiBI80yEB LTiaSVWBq8BrpTjOUSL7P1YOwGKuaFaLIzBYmMFhOLWml2aHI1ICncKZxpxwy+xHPbQW /l/BGDOAN/uhZk5HTXa3567wC4vjG2o+l9iklKQZ8rMNruITx2zADLBetRIFths+Wcs8 QSkBf2iBWEOV5EJipgPsJeV6zutKsMBHj3e5cf/rLIjcQyaYdLJKLiw7lwcZ6dRSVYVK X/wWh8SBejtvXG+t8o3Prp25kvniCfpzEYevG0LXVINtYbxXZA6JzAgXhc2Qw8OTSb+p 9/Qg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a170902ab9200b001713df0c8b2si1118227plr.213.2022.09.27.01.37.39; Tue, 27 Sep 2022 01:37:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230271AbiI0Ibb (ORCPT + 99 others); Tue, 27 Sep 2022 04:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbiI0IbC (ORCPT ); Tue, 27 Sep 2022 04:31:02 -0400 Received: from isilmar-4.linta.de (isilmar-4.linta.de [136.243.71.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1486D38465; Tue, 27 Sep 2022 01:30:41 -0700 (PDT) X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES 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 38C19201335; Tue, 27 Sep 2022 08:30:39 +0000 (UTC) Received: by owl.dominikbrodowski.net (Postfix, from userid 1000) id 8A4968052E; Tue, 27 Sep 2022 10:30:22 +0200 (CEST) Date: Tue, 27 Sep 2022 10:30:22 +0200 From: Dominik Brodowski To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, Kees Cook , Andrew Morton , stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] random: split initialization into early step and later step Message-ID: References: <20220926213130.1508261-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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-kernel@vger.kernel.org Am Tue, Sep 27, 2022 at 10:28:11AM +0200 schrieb Jason A. Donenfeld: > On Tue, Sep 27, 2022 at 8:35 AM Dominik Brodowski > wrote: > > > #if defined(LATENT_ENTROPY_PLUGIN) > > > static const u8 compiletime_seed[BLAKE2S_BLOCK_SIZE] __initconst __latent_entropy; > > > @@ -803,34 +798,46 @@ int __init random_init(const char *command_line) > > > i += longs; > > > continue; > > > } > > > - entropy[0] = random_get_entropy(); > > > - _mix_pool_bytes(entropy, sizeof(*entropy)); > > > arch_bits -= sizeof(*entropy) * 8; > > > ++i; > > > } > > > > > > Previously, random_get_entropy() was mixed into the pool ARRAY_SIZE(entropy) > > times. > > > > > +/* > > > + * This is called a little bit after the prior function, and now there is > > > + * access to timestamps counters. Interrupts are not yet enabled. > > > + */ > > > +void __init random_init(void) > > > +{ > > > + unsigned long entropy = random_get_entropy(); > > > + ktime_t now = ktime_get_real(); > > > + > > > + _mix_pool_bytes(utsname(), sizeof(*(utsname()))); > > > > But now, it's only mixed into the pool once. Is this change on purpose? > > Yea, it is. I don't think it's really doing much of use. Before we did > it because it was convenient -- because we simply could. But in > reality mostly what we care about is capturing when it gets to that > point in the execution. For jitter, the actual jitter function > (try_to_generate_entropy()) is better here. > > However, before feeling too sad about it, remember that > extract_entropy() is still filling a block with rdtsc when rdrand > fails, the same way as this function was. So it's still in there > anyway. With that explanation on the record (I think it's important to make such subtle changes explicit), Reviewed-by: Dominik Brodowski Thanks, Dominik