Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1985219pxx; Sat, 31 Oct 2020 04:52:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8Cd2pBafD4UoYPWw9ffPZP63YdcQuSe9PKrJYtSEdCnqv/Z7Nbg8DpkOplnCBsDbHLP2I X-Received: by 2002:a17:906:6a94:: with SMTP id p20mr6574683ejr.499.1604145164721; Sat, 31 Oct 2020 04:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145164; cv=none; d=google.com; s=arc-20160816; b=gUk36ICSgAQcUKGwJnvPw1B3AuRpvu94A///HpP0TWIReHxsrZCmUGAX1sGsFayFeF V7P2O3HVyqaxgi1BfhC64dp+dBN6B859apMZcoc84MKBa5sP95eC+WqQskqCTSVwWRnj V/CB3xyBfBuoekqZry0FPOiubozl2Zvu27tltZzWGQjTnAEnYvgB+zc25roCA4Uqjdn9 6OSXIm3LH42Kp+H0pc1aCo/T9VJpAX57IH8FnjvMJkqLHguv3DgtaOrx55CeobxDLe82 abyE7bZgQB6Puzm5n3hCMxcP8gCX021MctVTdqlJg1HlowAMuP8TFqSs9m063HYB3Yhb AdGg== 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=NkUh08tCej/bRyIvFOAgJIszX5PTPmMc8aEnZPgvkWE=; b=A4Bx9oA8m8p+PYi+7MMkKx9ZbrxI39BPdWf1TdWetjMMas5oke+JiWDkhtQzQBQEZ6 KCIV57InRMRO+xdiz7J6nPZ/gQdQVo9w4g5NFJF4xyLSByA0pRecI/moEgGQOpwnBJ2V vSLeOou/VeCHDd3Ejr4rImFa4vg1yFu0j1wxnn3mPxwep5NKR9C2CT5tB6mALhSW9BXB 9vk7Dl284myzJT5iMILXVisDwZ+AQUME42upNgX8Ur8z3VQYvVn97SgJjKSwLYjkKjkN gXddVo3kVdsmcnEiEWpxQkmV2C/oZscD6IcjRvsIl2asHBsq+AFemDQZaCq9OCZmz8IH 9fCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qf0XWdQC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si7773347edi.564.2020.10.31.04.52.22; Sat, 31 Oct 2020 04:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qf0XWdQC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbgJaLsn (ORCPT + 99 others); Sat, 31 Oct 2020 07:48:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728050AbgJaLnk (ORCPT ); Sat, 31 Oct 2020 07:43:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2042420731; Sat, 31 Oct 2020 11:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144620; bh=lyN8fzdZVm2iK4kV+7mrPWBQYhkvGH4kdoLeQtrO2uU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qf0XWdQC9FjF8TQ2VbkQVS/nEYGvD+uk1lSLIxDY9QOxfeD5VNwZD58ZMPAt/St0F ibpImJGYZm4s+A2xRrcn3Bqq1j1kkTN47Y/giUuidz3GovOUzAoSL0jjSbcjDTvihP bETj5EsgGcydN6ocN1JGxhA0NBmgSDNjqTwvsvek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heinrich Schuchardt , Ard Biesheuvel Subject: [PATCH 5.9 18/74] efi/arm64: libstub: Deal gracefully with EFI_RNG_PROTOCOL failure Date: Sat, 31 Oct 2020 12:36:00 +0100 Message-Id: <20201031113500.927808908@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113500.031279088@linuxfoundation.org> References: <20201031113500.031279088@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit d32de9130f6c79533508e2c7879f18997bfbe2a0 upstream. Currently, on arm64, we abort on any failure from efi_get_random_bytes() other than EFI_NOT_FOUND when it comes to setting the physical seed for KASLR, but ignore such failures when obtaining the seed for virtual KASLR or for early seeding of the kernel's entropy pool via the config table. This is inconsistent, and may lead to unexpected boot failures. So let's permit any failure for the physical seed, and simply report the error code if it does not equal EFI_NOT_FOUND. Cc: # v5.8+ Reported-by: Heinrich Schuchardt Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/arm64-stub.c | 8 +++++--- drivers/firmware/efi/libstub/fdt.c | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -62,10 +62,12 @@ efi_status_t handle_kernel_image(unsigne status = efi_get_random_bytes(sizeof(phys_seed), (u8 *)&phys_seed); if (status == EFI_NOT_FOUND) { - efi_info("EFI_RNG_PROTOCOL unavailable, no randomness supplied\n"); + efi_info("EFI_RNG_PROTOCOL unavailable, KASLR will be disabled\n"); + efi_nokaslr = true; } else if (status != EFI_SUCCESS) { - efi_err("efi_get_random_bytes() failed\n"); - return status; + efi_err("efi_get_random_bytes() failed (0x%lx), KASLR will be disabled\n", + status); + efi_nokaslr = true; } } else { efi_info("KASLR disabled on kernel command line\n"); --- a/drivers/firmware/efi/libstub/fdt.c +++ b/drivers/firmware/efi/libstub/fdt.c @@ -136,7 +136,7 @@ static efi_status_t update_fdt(void *ori if (status) goto fdt_set_fail; - if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && !efi_nokaslr) { efi_status_t efi_status; efi_status = efi_get_random_bytes(sizeof(fdt_val64), @@ -145,8 +145,6 @@ static efi_status_t update_fdt(void *ori status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64); if (status) goto fdt_set_fail; - } else if (efi_status != EFI_NOT_FOUND) { - return efi_status; } }