Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1q9Rzq-0005kd-Oe for mharc-grub-devel@gnu.org; Wed, 14 Jun 2023 11:01:19 -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 1q9Rzo-0005kI-VR for grub-devel@gnu.org; Wed, 14 Jun 2023 11:01:17 -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 1q9Rzm-0007Rx-FU for grub-devel@gnu.org; Wed, 14 Jun 2023 11:01:16 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f62cf9755eso8677040e87.1 for ; Wed, 14 Jun 2023 08:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686754868; x=1689346868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c1r31986XMRWkCO/2vE7kdvZvXuSHG4IpqZehWu04Hk=; b=K6P0DM1pLkCRxy4ldyaJKEsDYn1bVLdmR6BGShcBtS/6Km0V8dKtunLN5HcHh3D9ZU ddxMhMttK/i0RdfDuy3OGyFzRs8Mow8NqD+qfBUVlyQU7PM15nvjCJCGWRg0Qra9tIa6 rfAMRUhCOHcTbtMXFnG4t1TGzQ7IR311tODuRjVmpLxp+2tE+QetlaGHGgNxorp4E7+I 57kO0EIDT0vVg+6J6KTB/jrMVbnY1ujnradb+KJv/EM9NYTAQCa26k1OkcKjvKbj6FuC GQKFWLuZeme5ZvT7YXzzjMKgYF7PVNRJp3frORcMELmFd9kO2sICoAn5B4NmrUT2XIWd K4GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686754868; x=1689346868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c1r31986XMRWkCO/2vE7kdvZvXuSHG4IpqZehWu04Hk=; b=kOQRpF0p3DA4qZ7oEcTvoDuDZ84S6ZigGGJ2Rov+qCqNQC2LXaqasTaU67U0xaVZzg oLFIvjJVkQonti4lZgaTmxdFmRWs0lPQevK+Jd1zGZIf0W5DpoC/NlYlavH9qu1BHejI ATIQJwdxK6ZicMFFjcCqn1c79SlVMnVWlh4m0Yi2JeBVJyeJ1BTc/McrEYSEB3RqL6OC p/D/UnO1fEvKIp2NQ+ZyQpal8NzyK2xdjOuWDVVX6/t5Lg/BouhDNk/mlDtsPOpOajCj WV9XEVWMt2tXasyimrVVWdzWu/d5e333qStGKAx4GOP6ogKLzPoiaSmBGWHBQU0wLNdU xsyQ== X-Gm-Message-State: AC+VfDyD+xawWBbXk8JW4LzYDSbObDio2Vv/0Evj0i6/ee6vYdHMBm4n FoVByckJccIlJtvYu+VTmWLB6rqB4zU= X-Google-Smtp-Source: ACHHUZ5Ln49P2e/WiTSI83SYXFNvBHKDzXt4mdyM9+OFu3dlQlH+4T904NijOUOZ2a2EJDjLiFDQyQ== X-Received: by 2002:a19:920a:0:b0:4ee:dafa:cb00 with SMTP id u10-20020a19920a000000b004eedafacb00mr8041059lfd.60.1686754867675; Wed, 14 Jun 2023 08:01:07 -0700 (PDT) Received: from fedora.36 (77-252-46-174.static.ip.netia.com.pl. [77.252.46.174]) by smtp.gmail.com with ESMTPSA id y12-20020a19750c000000b004ef92c6e645sm1746906lfe.263.2023.06.14.08.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 08:01:07 -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] tpm: Enable boot despite unknown firmware failure Date: Wed, 14 Jun 2023 16:59:29 +0200 Message-Id: <20230614145929.4172-1-mchl.grzlk@gmail.com> X-Mailer: git-send-email 2.37.3 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: Wed, 14 Jun 2023 15:01:17 -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. Make grub_tpm_is_fail_fatal() global and move its body to efi/tpm.c. Check environment variable tpm_fail_fatal to fallback to previous behaviour. Signed-off-by: MichaƂ Grzelak --- grub-core/commands/efi/tpm.c | 10 +++++++++- grub-core/commands/tpm.c | 11 ++--------- include/grub/tpm.h | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c index c616768f9..05f3064f7 100644 --- a/grub-core/commands/efi/tpm.c +++ b/grub-core/commands/efi/tpm.c @@ -18,6 +18,7 @@ * EFI TPM support code. */ +#include #include #include #include @@ -146,7 +147,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 (grub_tpm_is_fail_fatal () ? GRUB_ERR_UNKNOWN_DEVICE + : GRUB_ERR_NONE, N_("unknown TPM error")); } } @@ -266,6 +268,12 @@ grub_cc_log_event (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, grub_efi_log_event_status (status); } +bool +grub_tpm_is_fail_fatal (void) +{ + return grub_env_get_bool ("tpm_fail_fatal", false); +} + grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description) diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c index 9f830916d..f86bdc81e 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) { @@ -55,7 +48,7 @@ grub_tpm_verify_write (void *context, void *buf, grub_size_t size) return GRUB_ERR_NONE; grub_dprintf ("tpm", "Measuring buffer failed: %d\n", status); - return is_tpm_fail_fatal () ? status : GRUB_ERR_NONE; + return grub_tpm_is_fail_fatal () ? status : GRUB_ERR_NONE; } static grub_err_t @@ -91,7 +84,7 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) return GRUB_ERR_NONE; grub_dprintf ("tpm", "Measuring string %s failed: %d\n", str, status); - return is_tpm_fail_fatal () ? status : GRUB_ERR_NONE; + return grub_tpm_is_fail_fatal () ? status : GRUB_ERR_NONE; } struct grub_file_verifier grub_tpm_verifier = { diff --git a/include/grub/tpm.h b/include/grub/tpm.h index c19fcbd0a..aea145dd1 100644 --- a/include/grub/tpm.h +++ b/include/grub/tpm.h @@ -36,5 +36,6 @@ grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, const char *description); +bool grub_tpm_is_fail_fatal (void); int grub_tpm_present (void); #endif -- 2.37.3