Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6144429iog; Thu, 23 Jun 2022 12:15:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ukaqWbOc3x/jtnLl0kA/1aDJZtTECtE79z0K5AdATPuAldjXVvteI36n8u3EB0/v4rAxmE X-Received: by 2002:a17:90a:c001:b0:1ec:c72a:9667 with SMTP id p1-20020a17090ac00100b001ecc72a9667mr5541001pjt.38.1656011757774; Thu, 23 Jun 2022 12:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011757; cv=none; d=google.com; s=arc-20160816; b=RWvEBmRWUI2fhzboggvS7vbEcoKwB1iKpYlQCI3t9tFn6IXNXwU/ZgLC3q+9OwfniB gnNue6S9YjP7Lw96ARZqG1TE+8Z5QWk4fra1gxPXS7reo0WxYj6sTAtuNCCxCOYBKXtN 5rvlkGQwJmMU9uR8MOghBty1BEdJMYUcgP5QWcDQYXKOv3TanP4+rfdnue3RZV0H2gsk frC0AconA1lO4nLO5RjUpeO8MYx74+0ru1MceNDemAjFc3hS0Uy3eA1bA75rEajYRFHy rdzoY5Kr7Kl/68WCzp353vckjq71g5zIbd5GIlTw+tEgqbzZK8nzXfYkgYQxYjDHJJxr uyUw== 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=itmsK+B9eOqBWYgyVIzXTyNDdlsdD2YfT1cuC7CUTPI=; b=aUN2jic8uIv9xNr/eZry3EAPFYZZnPmPZO/OYW2TYv3LGPBVuMX0VPGQveva50Hxr/ B5FjtggtAO0HyGys8q08c/LOtkedCxlc3YE8rD/0GatmoxpfB0o/81lBsWlN7KKEnrjp LmCTuG8SnPXNBbop6nQmTFeGYHmBucO+1OJPpaAV+Wmv4TmcpnAJMeZpjrUVxwxUmRau Lu26wEptxCz7WD1Uq8GUkS/OJ7ord4SgA2ht6S4aXijfM07cVMD8U+djs4ZoSD4h/kbX j+ZXksdLEmcUhHLLd9S/u2HlShdHszzFkTKawPmIJSpz15F9LfMxMK4G24XZ6ceIQwTk 1rSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LouIx9qs; 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 r12-20020a17090b050c00b001ecb528e0b2si3663572pjz.99.2022.06.23.12.15.46; Thu, 23 Jun 2022 12:15:57 -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=LouIx9qs; 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 S233684AbiFWSNa (ORCPT + 99 others); Thu, 23 Jun 2022 14:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236221AbiFWSMN (ORCPT ); Thu, 23 Jun 2022 14:12:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC78BBEA84; Thu, 23 Jun 2022 10:20:30 -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 44599B824BE; Thu, 23 Jun 2022 17:20:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEA3FC3411B; Thu, 23 Jun 2022 17:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004828; bh=DPnFIHqCLWmJHrvmgIpzuKyLqE8UiAa+IVFBNmuOZEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LouIx9qs7PRtCTJzuogrs7Fb0Otrxc10UVS1ParhHg71fJbW1S1Nm7OzSyrLAIGLh unO/kqAoq2NNsQMkr9S7oH+VNFJep+eD75f1rxNjdwUVpX2ob40HjQcvebCtwuLIFB dFPvsgKGCDYtMwLTI3O/nBqzRvDy0fRK5ijPMSis= 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.19 126/234] random: mix build-time latent entropy into pool at init Date: Thu, 23 Jun 2022 18:43:13 +0200 Message-Id: <20220623164346.623027850@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 @@ -967,6 +967,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)) {