Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp648324rwb; Tue, 27 Sep 2022 02:42:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wAIlqcNd1xAh7CUr/Y96u2ESDypW7nKl5DQr0+BICn+INwhw+EcDrUroHZsiAdE1BBhTI X-Received: by 2002:a17:902:e5c2:b0:178:2eca:9dea with SMTP id u2-20020a170902e5c200b001782eca9deamr26492994plf.73.1664271725093; Tue, 27 Sep 2022 02:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664271725; cv=none; d=google.com; s=arc-20160816; b=zoCuuFlbjKpqzCqTCFtL+hjpX2BOYJ0GpdbM55qxu/TbKf40j6RUMyR5aYkuUoe8XQ EJJzDZmK4DPf7M2re9uacFyQRKVGICAeaMdCfF3IEwSny902w5V4AjihPUgXvBtbm4Qh Hy8GRHy+AdiVCg3K1t9X6cwZcTgc6G/H7D3hYQXI6/I5yQIxSmggaJt4n4Col2MB09cJ EyUV5GPhQbQ6grqcHO2jaNUujZibthkwwRCRDBShsCErKiIDkKYVlG+F15eVSYc5uB87 Fp7qgGH948/nbY/ZOazLqLAkirXOyEVfvS0Y8ilABkotYcpMXsk0O3feBsBdsbpujV6K F0WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IV/Em9oY+NQiUPjmtckttX54KTlCyU8xGN0JLMqvDIc=; b=YgoF9AtxIqffcn2iizLeoded6E42GyQcilwZnXzlPkQgaRARFCURWgM/bNsoM9aYRl VSFHTzM8l4nZY8Bs53ggDNxpapJhm5131qsjvrDgAWsB2BR+q1y1RLCvduGdyLeCo5+V 8YRaraB0lYY0L18Dd+XZqx3pvemTqaGLMMO4x2f/AXuDC90BymRy3wrvuYdsCb9L+Dxs i/6pHBptd5iTgEPP/sllxzG8SJv9q778yPN3kGTR3YilDxGQT4IMK3flnfH+uRqIpOBI 5h6lYDsGZEAKGgm4pps6pO+9TJ+qXYAMXqesMqSNgrZnXhanAN1NOcCc9nIuLp7AJ0AQ jDTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=U2RFQizA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om8-20020a17090b3a8800b00202b5053462si16352640pjb.161.2022.09.27.02.41.53; Tue, 27 Sep 2022 02:42:05 -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=@zx2c4.com header.s=20210105 header.b=U2RFQizA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbiI0IlL (ORCPT + 99 others); Tue, 27 Sep 2022 04:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbiI0IlK (ORCPT ); Tue, 27 Sep 2022 04:41:10 -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 2BD2F58B62; Tue, 27 Sep 2022 01:41:08 -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 6AA3D61725; Tue, 27 Sep 2022 08:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D0F0C433C1; Tue, 27 Sep 2022 08:41:06 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="U2RFQizA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1664268064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IV/Em9oY+NQiUPjmtckttX54KTlCyU8xGN0JLMqvDIc=; b=U2RFQizAC2uVi7PeJpBOJhVm8sonI94kcMjpmIb7C+lbxJFAWil0g+O/A0FycoIKy0lXtM 6tGzi54hJvOMspzhR1YjM3/RFjGIOff6q+8UwTD3o5ErqUraiYhx26mwfv8NWoCEBDBca1 lXLtqDS1rHPcULbQg37rDsMricNl+lw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2a250998 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 27 Sep 2022 08:41:04 +0000 (UTC) Received: by mail-ua1-f44.google.com with SMTP id b7so3314326uas.2; Tue, 27 Sep 2022 01:41:04 -0700 (PDT) X-Gm-Message-State: ACrzQf1FGwfMhMpu43EGPvGPV6mYxIKl4Gye+3CWgi+0ChW7DyIdeBmW 7o+3OK8m64SzASfUdBkuSdXaU023FH0MEh4Wz9Y= X-Received: by 2002:a9f:3562:0:b0:3d0:ad99:b875 with SMTP id o89-20020a9f3562000000b003d0ad99b875mr1217071uao.102.1664268062673; Tue, 27 Sep 2022 01:41:02 -0700 (PDT) MIME-Version: 1.0 References: <20220926213130.1508261-1-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Tue, 27 Sep 2022 10:40:51 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] random: split initialization into early step and later step To: Dominik Brodowski Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, Kees Cook , Andrew Morton , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 On Tue, Sep 27, 2022 at 10:30 AM Dominik Brodowski wrote: > > 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 I'll augment the commit message to note this too. Thanks for the review. Jason