From patchwork Sat Aug 19 17:19:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 110453 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2343364qge; Sat, 19 Aug 2017 10:20:11 -0700 (PDT) X-Received: by 10.84.132.79 with SMTP id 73mr14003802ple.453.1503163211229; Sat, 19 Aug 2017 10:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503163211; cv=none; d=google.com; s=arc-20160816; b=0VTV2/WH1+mRdJ1rUgQ6K+GJlvFzZefW0ONVGEBoESIZt3nmks6ED6uRrz1VJ+1E9m SB4l/OMurcvmSARdx/AV/l6nxX0DCwd6RQvUhRxtrvRwgXOy1gi4oDsvWLN+t3pillAG UTreQe4TgSLkc4YVosGIMPzHdN9i2uacnFNhHc+VUCjDhOxeaOO44oXWHbDfzK2Bv03U 2VuACg6TI78/FO7r2NvM9MScnl4iSpaIiAcvlwB2VQR+B9jYhdhrPtePMYQqD7rs16+X HWP7P+l3gJtsYoUnI9oe535/gb6e0cV4cy2KfeN2vDH3Zob2x5o5MFfnUOQFQ1IgEF79 ndgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Xgk6Xz1Mbab8mDNK/6Daqqf/QWxeeZ28azU1oju1o34=; b=saC5Ddsa2aDx8ORNvmefthUlHBWYCmJek18p7ELczqoqPfVecwf5SkuEstsyBRkaYd l0B8NvMknHHNI7n7ao/2cBCSbjMNQmYk7llYkvgcEiCu3gMBVKdTJcc1zvUKWfXABfa6 9HYW5dAiT8e97SyS/LJVd0aO8IYQrnO54ZD6nM/PTCOtTeIwRXVxGTgzfiEIij6UopEI 4XjOP1ac0i9QfL1oEXBpsRS4nDDJrbrVOIqUcWSqUNE11fIc7ZOpjUwi43Mz9B3cUf9A sU43Tk6WqM4FIGcDCCsXClRB/+ld3CEZFDL9fRkX0SSMAo8bp3qyHixPeHZdFhaQWNNJ rrOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OXG9thcp; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si560395pgf.665.2017.08.19.10.20.11; Sat, 19 Aug 2017 10:20:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OXG9thcp; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751613AbdHSRUK (ORCPT + 2 others); Sat, 19 Aug 2017 13:20:10 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35182 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbdHSRUK (ORCPT ); Sat, 19 Aug 2017 13:20:10 -0400 Received: by mail-wm0-f51.google.com with SMTP id m85so20596383wma.0 for ; Sat, 19 Aug 2017 10:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=SFQ3e3s/tYzfGg3mUbOhotKxF3s764rPEDeG1QjsKdk=; b=OXG9thcp/huaOh3vri1BFqcOG4t1irboRm4XF8op1ZVaDdSLQ0IX116itwMWgrdcXv 3+E9284abfrV1wKbbz9TNKfXkJT+BbFrqf54g+Voj96QqgJ1Ws/prE/diIMnWo6yetui S8SGZyt9KNF3RURlCoJ9Aycr0pHiuUw6qHM8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SFQ3e3s/tYzfGg3mUbOhotKxF3s764rPEDeG1QjsKdk=; b=ja5ZG/fKjKDb0V3bReD3JTL1PxiPmo3kP3wnITGk8FpCR6iGuqmaVhk5ANWLBWjxks 3QJqB8MRvjINhe/eUH85v4MfPmkI0LAubcEuPJMkAu3JzrB7OUdZBGbFQjSYOQVsBwlJ ww0huDVJWp98D4rAMU9EdI31f6wKF01YXTUhGHu6C9JV1m1iYyr8PuQJIf4gJmHc7aOQ 70BWRCAjdnVQbeTv2JR+flSr3uitCiho86Icp1xKpo3d4+im96sm07mvgt2H6RQNb98/ KAvE0vzIVzDNMcRNHTh+OapASQziow0ueU0GgW2USv/5f4iKWs7fKof6IO1un5EECffU xFBg== X-Gm-Message-State: AHYfb5iVgUsDP9E6gwyzSqpdNxeRKNNwULY3bru03OZg+gmMaKBjnoo2 m7Kbt5VPditYYu1wua1bZg== X-Received: by 10.28.224.138 with SMTP id x132mr2946945wmg.90.1503163208701; Sat, 19 Aug 2017 10:20:08 -0700 (PDT) Received: from localhost.localdomain ([154.146.161.128]) by smtp.gmail.com with ESMTPSA id x67sm4267338wma.20.2017.08.19.10.20.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Aug 2017 10:20:07 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, linux-hardened@lists.openwall.com Cc: leif.lindholm@linaro.org, matt@codeblueprint.co.uk, lukas@wunner.de, keescook@chromium.org, Ard Biesheuvel Subject: [PATCH] efi: random: increase size of firmware supplied randomness Date: Sat, 19 Aug 2017 18:19:51 +0100 Message-Id: <20170819171951.18932-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The crng code requires at least 64 bytes (2 * CHACHA20_BLOCK_SIZE) to complete the fast boot-time init, so provide that many bytes when invoking UEFI protocols to seed the entropy pool. Also, add a notice so we can tell from the boot log when the seeding actually took place. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 3 ++- drivers/firmware/efi/libstub/random.c | 2 -- include/linux/efi.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 6519be44387c..9e822906adcb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -522,6 +522,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, if (seed != NULL) { add_device_randomness(seed->bits, seed->size); early_memunmap(seed, sizeof(*seed) + size); + pr_notice("seeding entropy pool\n"); } else { pr_err("Could not map UEFI random seed!\n"); } @@ -867,7 +868,7 @@ static int update_efi_random_seed(struct notifier_block *nb, seed = memremap(efi.rng_seed, sizeof(*seed), MEMREMAP_WB); if (seed != NULL) { - size = min(seed->size, 32U); + size = min(seed->size, EFI_RANDOM_SEED_SIZE); memunmap(seed); } else { pr_err("Could not map UEFI random seed!\n"); diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index fa10e14862b3..e460c59b448b 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -165,8 +165,6 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, return status; } -#define RANDOM_SEED_SIZE 32 - efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) { efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; diff --git a/include/linux/efi.h b/include/linux/efi.h index 253749cd9b62..cd23e1c4803c 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1566,6 +1566,8 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table, void *priv, efi_exit_boot_map_processing priv_func); +#define EFI_RANDOM_SEED_SIZE 64U + struct linux_efi_random_seed { u32 size; u8 bits[];