Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2931246iog; Mon, 20 Jun 2022 07:44:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBJXeGW41mSuVqiCUXmPkvUM54UrNFzIIJaGA7kON6Spu8nGEonmsc8nLj5hImVGbBfHIT X-Received: by 2002:a17:90b:1646:b0:1e3:15ef:2871 with SMTP id il6-20020a17090b164600b001e315ef2871mr38154814pjb.105.1655736262547; Mon, 20 Jun 2022 07:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736262; cv=none; d=google.com; s=arc-20160816; b=WpFPo7IXnPwsdfeZ4XBKVJ+nmY3D6FnvHII6aQYbfr8YtXt0GSYw4ml6ilBk/IIJyU h4O+d0sLfGAk2/FiedB2H9r/v2ksfPQIXlpwXX+F358pcJpc3xMz/JqAWJv0Sxt+s5ai 0l3zPYC44AEslYfhIWoAS9l8KCKNBqa7NtHglC0OYqCOzFhNUnwjGpwSIFfNMAADVhdt ebvD1UNlHEaX2Z3ExV0vIh2Qd3OmRNL0aikvezc9aXfX8nYLo5GWLFYVOJchyokFBT4m wXllE+r/ThDBSykpH1VB7z+xJkN70wPtDaDaOTTng6vcK9G7Vmmohlf40s3nzjFZAAXd CPKQ== 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=dCVEFyk5ynPohvBdcKncVY5mKYekctq17f9HUpl7k+IT3ydfZ3tg9RFtvTul1rLxc8 sDjaT//PiSnppmUG8lIPaw3fsEd8bNTPaQOoAeQccgK/VxJSjagx0N97XJB3xIXudt2h f6aG9HGA2dAZYLEwo3myTJexPgDXeqsZyoiqivv5mGMnWOrCYtMXsZuLQZLf8+CxElGH 4h+qtBYPTrajFvtllDFnjOI9A7cAsemV8I4+6tyDXGsJDrzp7EBw+5BfTwall5vJZELh m8A1H/xYIUlM05GHdDuQyCFAIjGj47z8bfd2A7Ck5Rw+cDZNquKWM+TcawBYKRQVre+Q mUDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ILM+j88E; 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 y5-20020aa79ae5000000b0050e0d9b0e4dsi7442828pfp.166.2022.06.20.07.44.10; Mon, 20 Jun 2022 07:44:22 -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=ILM+j88E; 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 S1346449AbiFTNho (ORCPT + 99 others); Mon, 20 Jun 2022 09:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345649AbiFTNgz (ORCPT ); Mon, 20 Jun 2022 09:36:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4469A1EACD; Mon, 20 Jun 2022 06:13:57 -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 9A0F060EA0; Mon, 20 Jun 2022 13:12:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88365C3411B; Mon, 20 Jun 2022 13:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730779; bh=zGMzx0V/+Sn1NwVSNDMX88/j5POtGrZTAP3uXM3+C4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ILM+j88EYeILTNEbuF00O08aWZrt2A///E2/Ft0JrnLcEVZg0IT4ux/fSO7lbwiUE 1cUfVlPNrv+6VwhRaLNQtbPWiI8US5J/TQ8QY5lZYheNFWCh8cSpRnpqV4O3icsUhC rB0ZWlQ2JGlHa0sgagrNl+0zsRm5OLIDpeiLZzX0= 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 5.4 052/240] random: remove incomplete last_data logic Date: Mon, 20 Jun 2022 14:49:13 +0200 Message-Id: <20220620124739.670626576@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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) \