Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp586318rwb; Tue, 27 Sep 2022 01:37:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zR7G5PwFvCmfZvbTHvjdnmFb4hBtKw28YliJgut8ZFKHtwoL/A8mkM73Qt2YTVfPM/r+T X-Received: by 2002:a17:90b:1801:b0:202:7cf6:9f93 with SMTP id lw1-20020a17090b180100b002027cf69f93mr3229778pjb.170.1664267823038; Tue, 27 Sep 2022 01:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664267823; cv=none; d=google.com; s=arc-20160816; b=i8PjpZ7dAeY3jCK1f0dcDqPr6SuCMrjR3mLyklEvSpQcp9sm7/KkxLGxkQt4Bv3dh1 U+hRG7bJqUXuk9YJVVvj4MDNmK1pwtQ8KZ/UnfhYwLsRuUe08QstbGaUa/Sl0RhkYVOD q0tyoneFk8UK78C+J+YIv3irO3jjlBWlEMqu2V2263nj24vXQhqPe50eW+obc/+yqptG R+HVPEBd1cyk6k4o4XkQmnm4kLMOoESZwBFaejux+sjIXaewIBE7qTEqpGRElNthV9q+ c/oqOuWDoDn+E8mj6K3Q6hvWOK/qujIU5N5tNM68DmDvhw9kxMXUoOLsFJmPXp/+R9Ig gIVw== 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=gF2B0EX39catiZugICdowKOfDfyx3TjUROolfQVqhqI=; b=Ck3YnkB61gJBWw9HraSHRJbAbJSaWG9oLDsq/BF/WtHFFEKcUZ/P4blGCPs86HViJv n9YJR31BKunQiZ+ixBwG90s3JM8n1kwRDAoLI49/yQs1A3FrVLubmPv4W8Qj7M/1IUaT 2CCmblmGRovBHHxF7fkqRCdNAQoE8DA9OQ1W0vmGoktva586U5pwnvEDdR9iSlTPxsIa mxTNgRZAqgl0oR09hjdx8sWJNUnwgo+BH2bs5EZfZw6WRv4kSGjzqZQ8oKU3NSK5w02m QX7AGM6i16tQ8P3EXUFwvL1XpFnuQSslD7T6TGzx5iH3uZoXPMEca6c8CHA/sXbQ9rYq Aqtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=Q4YS52KU; 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 n11-20020a17090a928b00b00200a6decc3bsi13428187pjo.24.2022.09.27.01.36.51; Tue, 27 Sep 2022 01:37:03 -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=Q4YS52KU; 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 S231575AbiI0I2c (ORCPT + 99 others); Tue, 27 Sep 2022 04:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbiI0I2b (ORCPT ); Tue, 27 Sep 2022 04:28:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C524B07FC; Tue, 27 Sep 2022 01:28:29 -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 ams.source.kernel.org (Postfix) with ESMTPS id 01E35B81A3C; Tue, 27 Sep 2022 08:28:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C852C433D7; Tue, 27 Sep 2022 08:28:26 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="Q4YS52KU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1664267304; 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=gF2B0EX39catiZugICdowKOfDfyx3TjUROolfQVqhqI=; b=Q4YS52KUu5BTFy2/9feSQ0tXR2kzgs2Z///o6YVaxJeW9gKooHCd30CLHGPwQcmNKAAmZJ I3xDj6yFp/COv/CvZbeSkFlJMHkZeXSgNUrAeu3P25akAz8lzIKIiyR8K5f98qSgf/mF/R +pZlIGj5629qBBX1COF5dhqN2eEQSSs= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c51ab9de (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 27 Sep 2022 08:28:23 +0000 (UTC) Received: by mail-vs1-f54.google.com with SMTP id p4so8953522vsa.9; Tue, 27 Sep 2022 01:28:23 -0700 (PDT) X-Gm-Message-State: ACrzQf3Bhcp8KjMLL1p1KTx/lvHJtgj7+CmqN723cEaLDOZrDbPB5+WH i8GO+KQPz+ij7jpjhOnk1fAceUbfaeYvgm6lhZM= X-Received: by 2002:a67:c289:0:b0:398:cdc:c3ef with SMTP id k9-20020a67c289000000b003980cdcc3efmr11024734vsj.76.1664267302601; Tue, 27 Sep 2022 01:28:22 -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:28:11 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] random: split initialization into early step and later step To: linux@dominikbrodowski.net 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 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. Jason