Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6133940iog; Thu, 23 Jun 2022 12:03:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vJGf45kANvxzUhrX+vqNepGN690mFsKYAyl2sXQ14RbQUpX+HxMMU7qEiAlx5sUi4DNbM5 X-Received: by 2002:a63:4f09:0:b0:3fd:3479:7624 with SMTP id d9-20020a634f09000000b003fd34797624mr8655604pgb.425.1656011031504; Thu, 23 Jun 2022 12:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011031; cv=none; d=google.com; s=arc-20160816; b=LG7KP5MrDK2GxLDQLIYtRx554vtETrhypOBgDrWFVR8euPKMW88L+AkeyKXwvPoW1h 6JEB9wRcZFNAOJ+LG18l1s6MGQCDSnDnnnPMTMvAW7l54/9CgU3iKZxhPr/WayPT5Xmf j+E5W0gksSGYl68ZfofT0UHolOVdHETTEXhFTGSTWW82HrcOtRgL6l1HSjtM0foS9Iyt ubFhKLLkxZvONbOkkJBv8ERukVsx/q0H7FlpCrzDMFrjzk+ipwM22/42yQX6KHJCnkwv a/Il9sDaDUuEhzeyP2yjN6N7O1V2lBjJ0MUKTaULWfhlSyBRgi4BywKx6Jnxl2XREnuJ /jTQ== 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=Clk7panAXkl3ImhHmoqZA4kKalFUxU6y1fnbeAG2FX0=; b=I8//s9F7VbTtx2P5N8zgVjYyAlNX4E8ZVyoONMJvtkuPx9FWDUf/bZpZvGEOm8KHku 4Jd+PasFLS+Pd+aCiU6lDVnX3dWpFFhNRsS8BJ116iElSTihY6dpCovom/l/ZRMH7BzC 4W5Y4fpmsQaFyEccbbTuYFFR4C5ZRQPYRwaJwe9AVqBxLX2tm999l1nooOyfn5qiRx2a GUqdQSr9aVVKygGt6DTDF8Qcj+zabrcvB4Cvl646RLsL1J/7auPIV/8Cv1snODhlkdbj +3HxHlOkeyb2K9SsPUck+IRCXIdHf4DsrgZ8DjOUT5x8Hj3Ez8UzhVlyIzPUvuBpF9cW aWQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f1+rushP; 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 y10-20020a17090a600a00b001e86a88ccbesi241506pji.81.2022.06.23.12.03.40; Thu, 23 Jun 2022 12:03:51 -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=f1+rushP; 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 S231984AbiFWR7Z (ORCPT + 99 others); Thu, 23 Jun 2022 13:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235386AbiFWRz0 (ORCPT ); Thu, 23 Jun 2022 13:55:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF3EAE316; Thu, 23 Jun 2022 10:15:22 -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 710E661DE1; Thu, 23 Jun 2022 17:15:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31D4DC3411B; Thu, 23 Jun 2022 17:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004520; bh=zGMzx0V/+Sn1NwVSNDMX88/j5POtGrZTAP3uXM3+C4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1+rushPQvp6xwwD4haZUN82uw2pkhDHmHuOEDECu7I44140rTk6/ND31XIDETRfI xVhoDRSTRWsaczGJKebH+q+B1oxQedTY36fmfmYfholr4+nY0nvLaEX4L2snhSPjAV YWshghdz2+4DZeILBZOU+shu9NlQFP9K2bXSIkdI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.19 063/234] random: remove incomplete last_data logic Date: Thu, 23 Jun 2022 18:42:10 +0200 Message-Id: <20220623164344.845930432@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 a4bfa9b31802c14ff5847123c12b98d5e36b3985 upstream. There were a few things added under the "if (fips_enabled)" banner, which never really got completed, and the FIPS people anyway are choosing a different direction. Rather than keep around this halfbaked code, get rid of it so that we can focus on a single design of the RNG rather than two designs. Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -337,8 +337,6 @@ #include #include #include -#include -#include #include #include #include @@ -518,14 +516,12 @@ struct entropy_store { u16 add_ptr; u16 input_rotate; int entropy_count; - unsigned int last_data_init:1; - u8 last_data[EXTRACT_SIZE]; }; static ssize_t extract_entropy(struct entropy_store *r, void *buf, size_t nbytes, int min, int rsvd); static ssize_t _extract_entropy(struct entropy_store *r, void *buf, - size_t nbytes, int fips); + size_t nbytes); static void crng_reseed(struct crng_state *crng, struct entropy_store *r); static u32 input_pool_data[INPUT_POOL_WORDS] __latent_entropy; @@ -822,7 +818,7 @@ static void crng_initialize_secondary(st static void __init crng_initialize_primary(struct crng_state *crng) { - _extract_entropy(&input_pool, &crng->state[4], sizeof(u32) * 12, 0); + _extract_entropy(&input_pool, &crng->state[4], sizeof(u32) * 12); if (crng_init_try_arch_early(crng) && trust_cpu && crng_init < 2) { invalidate_batched_entropy(); numa_crng_init(); @@ -1427,22 +1423,13 @@ static void extract_buf(struct entropy_s } static ssize_t _extract_entropy(struct entropy_store *r, void *buf, - size_t nbytes, int fips) + size_t nbytes) { ssize_t ret = 0, i; u8 tmp[EXTRACT_SIZE]; - unsigned long flags; while (nbytes) { extract_buf(r, tmp); - - if (fips) { - spin_lock_irqsave(&r->lock, flags); - if (!memcmp(tmp, r->last_data, EXTRACT_SIZE)) - panic("Hardware RNG duplicated output!\n"); - memcpy(r->last_data, tmp, EXTRACT_SIZE); - spin_unlock_irqrestore(&r->lock, flags); - } i = min_t(int, nbytes, EXTRACT_SIZE); memcpy(buf, tmp, i); nbytes -= i; @@ -1468,28 +1455,9 @@ static ssize_t _extract_entropy(struct e static ssize_t extract_entropy(struct entropy_store *r, void *buf, size_t nbytes, int min, int reserved) { - u8 tmp[EXTRACT_SIZE]; - unsigned long flags; - - /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */ - if (fips_enabled) { - spin_lock_irqsave(&r->lock, flags); - if (!r->last_data_init) { - r->last_data_init = 1; - spin_unlock_irqrestore(&r->lock, flags); - trace_extract_entropy(r->name, EXTRACT_SIZE, - ENTROPY_BITS(r), _RET_IP_); - extract_buf(r, tmp); - spin_lock_irqsave(&r->lock, flags); - memcpy(r->last_data, tmp, EXTRACT_SIZE); - } - spin_unlock_irqrestore(&r->lock, flags); - } - trace_extract_entropy(r->name, nbytes, ENTROPY_BITS(r), _RET_IP_); nbytes = account(r, nbytes, min, reserved); - - return _extract_entropy(r, buf, nbytes, fips_enabled); + return _extract_entropy(r, buf, nbytes); } #define warn_unseeded_randomness(previous) \