Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6050956iog; Thu, 23 Jun 2022 10:17:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tpGImGYIm96AmuDih9CFndiib5ggTY1S5wvG2O8tGu6ObKaZyS5pIQELozrZNO6FHg5ZLE X-Received: by 2002:a17:906:6c82:b0:709:f868:97f6 with SMTP id s2-20020a1709066c8200b00709f86897f6mr9580772ejr.555.1656004631478; Thu, 23 Jun 2022 10:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656004631; cv=none; d=google.com; s=arc-20160816; b=armCRJWEIxY/Il8h0XLUWk6iPAzesE/5c4i2AO5/GG9OZ85QVQJ9YaXn6NqXaU6f92 hs/Sn3pLCC39atssEJeZatnP6M3AQMPd+DaSm+OBdrznywOxaOLtWiZAyTVo2OOisW9P TGb/JWvc4JU9Gqi3ydqhJcsSGtBK/yD5yn4tfknmzNZtLcysfIjeiREKR8DKj5EcA9dj 2E2aozOFeS3GQzmBVG7UUhnbxXpkFeIzLtuBKtEA+N4OidaqebVjZAnaJ68Bh1M4JFl6 0wF4Sxevi2cKfAssiBbAXik3wsp7EwGVbfPHJRbuLzJYbG7qCcT+wSlUkgn5tK+5zcDv b9mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qNSoE+vT+F6LAnzieyRGeBMmW+nG8Kcr76cD9/hCyn0=; b=CSAmdwKhpgA1amnfjD0JmH5QmRV78AXXCN0+K8QZCmT1SCPi5x9yEGy+oZJGq2YhS9 D0NReletehpG0Z2BFI+q5vzM84faxFbQS1M6Qj5Zpam4rv2E3CnyYVG6rQyhyz5bEYW4 73L8FkCW1CxzU1mz6QSd5tyccSitppNXsAai2JS/O7v/gwco7w/+qYJarY3BcIv5UhQC 9cHF/+D8z61wOKxxt3CDB3eRStwioBGFEvagi1PSs6SaEI6Sk7uqV5lCDLogwnhSfQ++ Y+/3wELnp8y9ppttj37cxMKZU7ALMdZck9uLQydYL5vzye7MuODWBlRrakw/GhRoDVum 9/lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Rr6/wVY8"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf7-20020a1709077f0700b006fef8adb675si30184305ejc.953.2022.06.23.10.16.44; Thu, 23 Jun 2022 10:17:11 -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=@linuxfoundation.org header.s=korg header.b="Rr6/wVY8"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiFWRKO (ORCPT + 99 others); Thu, 23 Jun 2022 13:10:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233478AbiFWRHr (ORCPT ); Thu, 23 Jun 2022 13:07:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D34E52E65; Thu, 23 Jun 2022 09:56:33 -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 A887FB82495; Thu, 23 Jun 2022 16:56:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E81C341C4; Thu, 23 Jun 2022 16:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003381; bh=tVbxje2GoVXfy09EV+sn+bBxzkWmFnKhuanUt5iEoyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rr6/wVY8ZchZQ+YIfLG9rwkrz2lb6cR5a4MRfutWhD0g0T4CBC6QmWRezYc915dKG Tj98VDuZ9+/2JBYxykaAlLPOZEmNe5IyI5kFKCFOgg5gEjPpajJhgk896axwV8SRj/ rui1MhT3JxBKRUHCHTVi/NAVWL5ynrhuLK5Ji4eg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , Theodore Tso , "Jason A. Donenfeld" Subject: [PATCH 4.9 169/264] random: mix build-time latent entropy into pool at init Date: Thu, 23 Jun 2022 18:42:42 +0200 Message-Id: <20220623164348.845907841@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: "Jason A. Donenfeld" commit 1754abb3e7583c570666fa1e1ee5b317e88c89a0 upstream. Prior, the "input_pool_data" array needed no real initialization, and so it was easy to mark it with __latent_entropy to populate it during compile-time. In switching to using a hash function, this required us to specifically initialize it to some specific state, which means we dropped the __latent_entropy attribute. An unfortunate side effect was this meant the pool was no longer seeded using compile-time random data. In order to bring this back, we declare an array in rand_initialize() with __latent_entropy and call mix_pool_bytes() on that at init, which accomplishes the same thing as before. We make this __initconst, so that it doesn't take up space at runtime after init. Fixes: 6e8ec2552c7d ("random: use computational hash for entropy extraction") Reviewed-by: Dominik Brodowski Reviewed-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -968,6 +968,11 @@ int __init rand_initialize(void) bool arch_init = true; unsigned long rv; +#if defined(LATENT_ENTROPY_PLUGIN) + static const u8 compiletime_seed[BLAKE2S_BLOCK_SIZE] __initconst __latent_entropy; + _mix_pool_bytes(compiletime_seed, sizeof(compiletime_seed)); +#endif + for (i = 0; i < BLAKE2S_BLOCK_SIZE; i += sizeof(rv)) { if (!arch_get_random_seed_long_early(&rv) && !arch_get_random_long_early(&rv)) {