Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1q9vdl-0006QV-71 for mharc-grub-devel@gnu.org; Thu, 15 Jun 2023 18:40:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q9vdh-0006Px-5h for grub-devel@gnu.org; Thu, 15 Jun 2023 18:40:26 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q9vdf-0000RW-8U for grub-devel@gnu.org; Thu, 15 Jun 2023 18:40:24 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f766777605so3757582e87.1 for ; Thu, 15 Jun 2023 15:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686868821; x=1689460821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v+v11/qWizfY3638F1g7R6jxlA64cP2W1vm0mmcd540=; b=QpGu/WqTmmmGBcZkai4nNMLctX9zGjsHFkGf1eYu/1dbRgAJ8TZwb96VrLE8D+mWpG uUCdjKzDk04wD7EVeTHjJdf5rrZZ5Hr0Hw+7lAbsSjXpW8R16A6FizXFk2lKSukZjXOZ lBu8raPiZbqWnpZP8vcLbQm+kvUfYByZP0G/Bz76lS82+ck5dDqozdc97JteDOtugoEI ChaRtjBiW95I44qBFrsSuah8mOW/NbBESKcrKw0txD0+eyael/U7feScAj6zRsY0S96N Gd6B/qkJbAMyVNs2edrvZxSAzFXItXZAnvSdefK5+sXqp2sYdUmL/s2O+iQQ085LVPQn CRtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686868821; x=1689460821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v+v11/qWizfY3638F1g7R6jxlA64cP2W1vm0mmcd540=; b=OmyW40sOJuBIvNxtAZzzL/jz72ikIgLI6V2Zhk68OSgMrGubXOuSwxp1mA8njyZ/d8 vsjR2zqbr0upUuABMA0JqmJca1K5D8H/ldgB2lfT5XGNMX38YavVo5L3d7oPoNIw6W+v QK+YtTp6E7kef7YAt3VV9Mm/exWmA+WRtFY1hKeJwCOlqPVuG98jMGUMs6sBFPzKU/eo 55ApTNU3b33bqx/lXxiJEYfshExR0Fa+AqI6StUxuynwOwXouWD9C5Ay8ssSf6/Xb54x ayrOoaE19URCiC408kB7rh8ffbGR7inR+HqdToJIPDDQwfdY88G7o+rVMgTONtJNfBfg ucoA== X-Gm-Message-State: AC+VfDzpDU6NZU9aEBH/1G8cIM6qfVRF9+90V1HiVe6L+vAPNYPIR5M+ RnES/HTv1hbTRkM3MWkjnYuIvyYbkMM= X-Google-Smtp-Source: ACHHUZ7ErMWLRf+EvmUEFdgt9H29npniomSjRX1UayhsBDHoSLY7hBi2Iq/3hrRHqKyoz+nCgMIz0A== X-Received: by 2002:a05:6512:60d:b0:4f3:f98c:77fc with SMTP id b13-20020a056512060d00b004f3f98c77fcmr79644lfe.8.1686868820890; Thu, 15 Jun 2023 15:40:20 -0700 (PDT) Received: from fedora.36 ([77.252.47.129]) by smtp.gmail.com with ESMTPSA id j4-20020ac253a4000000b004f764716afdsm902962lfh.257.2023.06.15.15.40.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 15:40:20 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Grzelak?= To: grub-devel@gnu.org Cc: =?UTF-8?q?Micha=C5=82=20Grzelak?= Subject: [PATCH v2 1/1] tpm: Enable boot despite unknown firmware failure Date: Fri, 16 Jun 2023 00:39:47 +0200 Message-Id: <20230615223947.3700-2-mchl.grzlk@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230615223947.3700-1-mchl.grzlk@gmail.com> References: <20230615223947.3700-1-mchl.grzlk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=mchl.grzlk@gmail.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2023 22:40:26 -0000 Currently booting the system is prevented when call to EFI firmware hash_log_extend_event() returns unknown error. Solve this by following convention used in commit a4356538d (commands/tpm: Don't propagate measurement failures to the verifiers layer). Let the system to be bootable by default when unknown TPM error is encountered. Check environment variable tpm_fail_fatal to fallback to previous behaviour. Signed-off-by: MichaƂ Grzelak --- docs/grub.texi | 5 +++++ grub-core/commands/efi/tpm.c | 3 ++- grub-core/commands/tpm.c | 7 ------- include/grub/tpm.h | 9 +++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 9b58886a9..fc4e08f2c 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3841,6 +3841,11 @@ If this variable is set and true (i.e., not set to ``0'', ``false'', fatal. Otherwise, they will merely be debug-logged and boot will continue. +Call to EFI firmware, like hash_log_extend_event(), can return an unknown +error, i.e. due to bug present in firmware. When this variable is set and +true (same values as with TPM measurements) this situation will be considered +to be fatal and error-logged as ``unknown TPM error''. If not set, booting +the OS will be enabled. @node Environment block @section The GRUB environment block diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index c616768f9..508ae8b3a 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -146,7 +146,8 @@ grub_efi_log_event_status (grub_efi_status_t status) case GRUB_EFI_NOT_FOUND: return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); default: - return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("unknown TPM error")); + return grub_error (is_tpm_fail_fatal () ? GRUB_ERR_UNKNOWN_DEVICE + : GRUB_ERR_NONE, N_("unknown TPM error")); } } diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c index 9f830916d..c7e599170 100644 --- a/grub-core/commands/tpm.c +++ b/grub-core/commands/tpm.c @@ -18,7 +18,6 @@ * Core TPM support code. */ -#include #include #include #include @@ -40,12 +39,6 @@ grub_tpm_verify_init (grub_file_t io, return GRUB_ERR_NONE; } -static inline bool -is_tpm_fail_fatal (void) -{ - return grub_env_get_bool ("tpm_fail_fatal", false); -} - static grub_err_t grub_tpm_verify_write (void *context, void *buf, grub_size_t size) { diff --git a/include/grub/tpm.h b/include/grub/tpm.h index c19fcbd0a..11238da18 100644 --- a/include/grub/tpm.h +++ b/include/grub/tpm.h @@ -19,6 +19,8 @@ #ifndef GRUB_TPM_HEADER #define GRUB_TPM_HEADER 1 +#include + #define GRUB_STRING_PCR 8 #define GRUB_BINARY_PCR 9 @@ -37,4 +39,11 @@ grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description); int grub_tpm_present (void); + +static inline bool +is_tpm_fail_fatal (void) +{ + return grub_env_get_bool ("tpm_fail_fatal", false); +} + #endif -- 2.37.3