Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2438111ioo; Sat, 28 May 2022 13:42:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5YKjxMt2hov/IYf76e7Y7kuZTxPJWJnWzeTsBbC6INJdZZPWA2wBC4jijKVXVNcBzK8i0 X-Received: by 2002:a05:6a00:228d:b0:510:7594:a73c with SMTP id f13-20020a056a00228d00b005107594a73cmr50095842pfe.17.1653770520688; Sat, 28 May 2022 13:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653770520; cv=none; d=google.com; s=arc-20160816; b=0mt8RvJxKoQLVU6h8vHuGnsSOyC2aqFe95D5JcYq4n4xfZDfCakFoWX5WgckEGUqNc 8xfH6isgMeMGZVujK/uheBe8nHXgmJsPTXy04DJKBAu9+c9e7FyxMW+kuVxg3voeoHlK WATWA4B4bxYX7ANWzdijPcFwkAk7hhtiBPFySFcBUVgsc+jD1BYW/Wk5BSL6uZFIB08H bd9qVy198PYb4lSLDGvaFIjkZgud1DGci+BvSFAzLq+SOZuyPHW5E6LU7X+DIE8/bf1o dporOy8yZg9b8oPgQ8XaXje65X54tgJJwepdWkFcJt9swy4rnEpsx/2uZ6Pgzui+eioD +XQg== 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=i/ZNhCki3WWEmfIa6wUOP73gFXLC8tW6t6IZ0cZ+xx8=; b=Kya3CcvA5lEfKLEf0DMZORY5GWjpWr5iz0cUYIKoX/Q92GoV5gS8F7MIvJajLVJqNS vTOMR8CrTLw4avAdIET19cNVWFsXWqfzhKRQNt8Iw1cybrcXN8Ljuj/wKjjbIKdgG0EE Yk1j4xKIz2aUFeloDl7yKTEyCuYODkFBLDNczMnY4mUmcBsPuQeUN83pJ2mi8hisPJGL wy9MgFIzxX95k/TC7UJTilG0dnNKz3PKkrlqmgTHzPgqShe56kM9NMa68B8MlHH90Ap/ yKKzdXYL+X1mCvSqrCyJBA0jIAAeYJ82zuqx6CwiPpkVjQzF8+YgBia76xhTv9vlFGgP 6rDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jsfso5SS; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u12-20020a17090a450c00b001bfc324fc16si6774887pjg.99.2022.05.28.13.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:42:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jsfso5SS; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11DF111044B; Sat, 28 May 2022 12:44:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351459AbiE0Ll6 (ORCPT + 99 others); Fri, 27 May 2022 07:41:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351574AbiE0Lkr (ORCPT ); Fri, 27 May 2022 07:40:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F55913C1F4; Fri, 27 May 2022 04:39: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 dfw.source.kernel.org (Postfix) with ESMTPS id B9DB461CC4; Fri, 27 May 2022 11:39:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3772C385A9; Fri, 27 May 2022 11:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653651569; bh=hnMVFKzJakkFudy48mRUI+VFFoGuT+sdo+aAIP6T100=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jsfso5SSCF12QNUW1Sa2P1qYKa3xf/FKQEUq81nEkiuWkHnoRTUr5pqIHvpmywwwI a+SN+ta2zydQv0ROSbcvPcUoSjEvIh9vVn8D+63BX9nb4Rd8qxogDJaD288BfFJk4o i+9taOR7I4gW55rQb/BhNJUGrXfSvGMrxhhx6CSM= 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 5.17 059/111] random: mix build-time latent entropy into pool at init Date: Fri, 27 May 2022 10:49:31 +0200 Message-Id: <20220527084827.872544791@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220527084819.133490171@linuxfoundation.org> References: <20220527084819.133490171@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=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 @@ -970,6 +970,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)) {