Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1984706pxx; Sat, 31 Oct 2020 04:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYOBqMgzGLT+yKBxdwTxvfYxIqkVogUsDv9FBbMgjQd1cllHaIv3dAAkBuMdUSM361ZtQV X-Received: by 2002:aa7:c586:: with SMTP id g6mr7394655edq.343.1604145097449; Sat, 31 Oct 2020 04:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145097; cv=none; d=google.com; s=arc-20160816; b=P3GxBMbMb5v7bNcuihv/KcbK6HKKqNqL18nvP86c2sX0CFh0uHLsd2/YFBWvKes1Z0 qXIInRX++m0w4JwPYYpvMejqCHFKMjjGxHTzlxj4qeFdN1wM3nqQxxLykqERlbexAZph f3wRCAH2TA6t5wrQvQ+GqYzRpZTuioJWzIwILTRS+QqwVxIIS7JF/Ae6sELUAnQe6/bT WgQKhKXJA5/AgBfXA8CCQSKr86zXFomj5PL3gPe5T23qNMPOpRgktEhLou1UcuQXkE1A 8RC/zKY4nmWXg+FaK/XcDF4sefWesrxNvxcFoOXwEXV+IaAym99nknJYqrEFIqmFi1c3 xeuA== 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=oo7jQU1OuAhcAVn9HaU+derXkqYcNmXSt0PFAFvt6wFfr3tQWS8bxk0jO/mKbXJrwf Djv9+9mIUvb+UrDEd8NJOzyz3thXnL3b1amIjEx4OVwlLOfr/zIV41O/UJNEAgq2hpbw d8hKIAQBc/OS4JTjk6S3FC31BHC2E5LX/eApEMtrRPtjkSo9TMsJd3jJchsEvuhs4WLp lryD8aFWRbwER5HYouxtf5afMlDrdgko25UoZXdY8mEcyX2F+pArvWJa5pKYjc0OmVVq zaZF+pvqv1T1jCtCcI/Se8cPmJJh3fxEIe933jJdssY/w8t5babd5QOzwo3CBcancWxP cuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OoS1tClK; 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 f27si6821011ejf.749.2020.10.31.04.51.15; Sat, 31 Oct 2020 04:51:37 -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=OoS1tClK; 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 S1727863AbgJaLm0 (ORCPT + 99 others); Sat, 31 Oct 2020 07:42:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:41962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727332AbgJaLmY (ORCPT ); Sat, 31 Oct 2020 07:42:24 -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 38153205F4; Sat, 31 Oct 2020 11:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144543; bh=lyN8fzdZVm2iK4kV+7mrPWBQYhkvGH4kdoLeQtrO2uU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoS1tClKWSB0hbhVO62QoubylVBgx7f7O4EY3mTP+59sIO9BIPjyx4NLzx2fbdjF1 ZUkM03pJ2/elm89Uj0oKv3rvweUtLP5qt68K5qZtrQ+C/MxYeYtphQd7XydOWk2CSi xgP2co5LccEnXeECpSspf1UThLvfWxhfIJGD0FUA= 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.8 18/70] efi/arm64: libstub: Deal gracefully with EFI_RNG_PROTOCOL failure Date: Sat, 31 Oct 2020 12:35:50 +0100 Message-Id: <20201031113500.381102391@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@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; } }