From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34B53C43217 for ; Tue, 8 Nov 2022 13:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234585AbiKHNuO (ORCPT ); Tue, 8 Nov 2022 08:50:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234624AbiKHNuM (ORCPT ); Tue, 8 Nov 2022 08:50:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697C063F0 for ; Tue, 8 Nov 2022 05:50:12 -0800 (PST) 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 073C2615A3 for ; Tue, 8 Nov 2022 13:50:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 123C1C433D7; Tue, 8 Nov 2022 13:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667915411; bh=ravxm6RvOKV3wTkK9yfdUMIYcy+FOZZceg3Prsg4fBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDf9m9GT7P4UjcRBMRnpeU0rSWDTbo2KIM3u4mQ6N7FsNtiBVEJI+B6JNhr7Jgzy7 K6Mx+0jqyl90iHFrts9PAJ86+C+7IJucx3tQb26ebASzP/eDqBC/gAEg8c5KiwcrW7 4clK1VrLZ0r4BL84aSAvfoiJtW6+CzRPKF56CTdk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ard Biesheuvel , "Jason A. Donenfeld" , Ilias Apalodimas Subject: [PATCH 5.4 55/74] efi: random: reduce seed size to 32 bytes Date: Tue, 8 Nov 2022 14:39:23 +0100 Message-Id: <20221108133336.015931064@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221108133333.659601604@linuxfoundation.org> References: <20221108133333.659601604@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ard Biesheuvel commit 161a438d730dade2ba2b1bf8785f0759aba4ca5f upstream. We no longer need at least 64 bytes of random seed to permit the early crng init to complete. The RNG is now based on Blake2s, so reduce the EFI seed size to the Blake2s hash size, which is sufficient for our purposes. While at it, drop the READ_ONCE(), which was supposed to prevent size from being evaluated after seed was unmapped. However, this cannot actually happen, so READ_ONCE() is unnecessary here. Cc: # v4.14+ Signed-off-by: Ard Biesheuvel Reviewed-by: Jason A. Donenfeld Acked-by: Ilias Apalodimas Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/efi.c | 2 +- include/linux/efi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -546,7 +546,7 @@ int __init efi_config_parse_tables(void seed = early_memremap(efi.rng_seed, sizeof(*seed)); if (seed != NULL) { - size = READ_ONCE(seed->size); + size = min(seed->size, EFI_RANDOM_SEED_SIZE); early_memunmap(seed, sizeof(*seed)); } else { pr_err("Could not map UEFI random seed!\n"); --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1715,7 +1715,7 @@ efi_status_t efi_exit_boot_services(efi_ void *priv, efi_exit_boot_map_processing priv_func); -#define EFI_RANDOM_SEED_SIZE 64U +#define EFI_RANDOM_SEED_SIZE 32U // BLAKE2S_HASH_SIZE struct linux_efi_random_seed { u32 size;