public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/grub2] rawhide: grub-efi-cc: disable TPM string measurements at runtime
@ 2026-08-07 18:20 Leo Sandoval
0 siblings, 0 replies; only message in thread
From: Leo Sandoval @ 2026-08-07 18:20 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/grub2
Branch : rawhide
Commit : fedae6ebf3e06c6a02dd8aa90e4277292575eb86
Author : Leo Sandoval <lsandova@redhat.com>
Date : 2026-08-06T11:04:45-06:00
Stats : +289/-35 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/grub2/c/fedae6ebf3e06c6a02dd8aa90e4277292575eb86?branch=rawhide
Log:
grub-efi-cc: disable TPM string measurements at runtime
Besides being a cleaner solution, less intrusive in general, it aims
to soften the transition into a completely new package, where
this new package would depend on grub2 package and create the image
with 'grub2-mkimage --disable-tpm-string-pcr'.
Signed-off-by: Leo Sandoval <lsandova@redhat.com>
---
diff --git a/0447-tpm-Only-skip-TPM-string-PCR-measurements-with-expli.patch b/0447-tpm-Only-skip-TPM-string-PCR-measurements-with-expli.patch
new file mode 100644
index 0000000..47c385a
--- /dev/null
+++ b/0447-tpm-Only-skip-TPM-string-PCR-measurements-with-expli.patch
@@ -0,0 +1,276 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Leo Sandoval <lsandova@redhat.com>
+Date: Fri, 31 Jul 2026 14:12:06 -0600
+Subject: [PATCH] tpm: Only skip TPM string PCR measurements with explicit
+ consent
+
+TPM PCR8 (GRUB_STRING_PCR) measurements record every GRUB command and
+kernel/module command line into TPM PCR register 8 via the TPM verifier's
+verify_string callback. In some deployment scenarios these string
+measurements are undesirable, for example on Confidential Computer
+workloads [1], while binary measurements (PCR9) remain valuable.
+
+Following the pattern established by commit 968de8c23 (shim_lock: Only
+skip loading shim_lock verifier with explicit consent), add a build-time
+--disable-tpm-string-pcr option to grub-mkimage and grub-install. When
+specified, an OBJ_TYPE_DISABLE_TPM_STRING_PCR marker is embedded in
+core.img. At runtime the TPM module scans the embedded module headers
+during GRUB_MOD_INIT(tpm) and sets a static flag; grub_tpm_verify_string()
+checks this flag and returns GRUB_ERR_NONE immediately, skipping all
+PCR8 measurements while leaving PCR9 binary measurements intact.
+
+This approach is tamper-resistant because the decision to skip string
+measurements is baked into the (potentially signed) GRUB image at build
+time and cannot be toggled by grub.cfg or an attacker with console
+access. The existing OBJ_TYPE_DISABLE_SHIM_LOCK and OBJ_TYPE_DISABLE_CLI
+markers use the same mechanism.
+
+[1] https://fedoraproject.org/wiki/Changes/Grub2LightForConfidentialComputing
+
+Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
+Signed-off-by: Leo Sandoval <lsandova@redhat.com>
+---
+ grub-core/commands/tpm.c | 19 +++++++++++++++++++
+ include/grub/kernel.h | 3 ++-
+ include/grub/util/install.h | 8 ++++++--
+ util/grub-install-common.c | 12 +++++++++---
+ util/grub-mkimage.c | 9 ++++++++-
+ util/mkimage.c | 16 +++++++++++++++-
+ 6 files changed, 59 insertions(+), 8 deletions(-)
+
+diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
+index 324423ef8..cfe7b6012 100644
+--- a/grub-core/commands/tpm.c
++++ b/grub-core/commands/tpm.c
+@@ -20,6 +20,7 @@
+
+ #include <grub/err.h>
+ #include <grub/i18n.h>
++#include <grub/kernel.h>
+ #include <grub/misc.h>
+ #include <grub/mm.h>
+ #include <grub/tpm.h>
+@@ -29,6 +30,8 @@
+
+ GRUB_MOD_LICENSE ("GPLv3+");
+
++static grub_uint8_t tpm_string_pcr_disabled;
++
+ static grub_err_t
+ grub_tpm_verify_init (grub_file_t io,
+ enum grub_file_type type __attribute__ ((unused)),
+@@ -58,6 +61,9 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type)
+ char *description;
+ grub_err_t status;
+
++ if (tpm_string_pcr_disabled)
++ return GRUB_ERR_NONE;
++
+ switch (type)
+ {
+ case GRUB_VERIFY_KERNEL_CMDLINE:
+@@ -96,6 +102,8 @@ struct grub_file_verifier grub_tpm_verifier = {
+
+ GRUB_MOD_INIT (tpm)
+ {
++ struct grub_module_header *header;
++
+ /*
+ * Even though this now calls ibmvtpm's grub_tpm_present() from GRUB_MOD_INIT(),
+ * it does seem to call it late enough in the initialization sequence so
+@@ -104,6 +112,17 @@ GRUB_MOD_INIT (tpm)
+ */
+ if (!grub_tpm_present())
+ return;
++
++ FOR_MODULES (header)
++ {
++ if (header->type == OBJ_TYPE_DISABLE_TPM_STRING_PCR)
++ {
++ tpm_string_pcr_disabled = 1;
++ grub_dprintf ("tpm", "String PCR measurements disabled\n");
++ break;
++ }
++ }
++
+ grub_verifier_register (&grub_tpm_verifier);
+ }
+
+diff --git a/include/grub/kernel.h b/include/grub/kernel.h
+index f98a780da..0e9ad9fa5 100644
+--- a/include/grub/kernel.h
++++ b/include/grub/kernel.h
+@@ -33,7 +33,8 @@ enum
+ OBJ_TYPE_DISABLE_SHIM_LOCK,
+ OBJ_TYPE_GPG_PUBKEY,
+ OBJ_TYPE_X509_PUBKEY,
+- OBJ_TYPE_DISABLE_CLI
++ OBJ_TYPE_DISABLE_CLI,
++ OBJ_TYPE_DISABLE_TPM_STRING_PCR
+ };
+
+ /* The module header. */
+diff --git a/include/grub/util/install.h b/include/grub/util/install.h
+index 857ccbbe9..e3e672e83 100644
+--- a/include/grub/util/install.h
++++ b/include/grub/util/install.h
+@@ -74,6 +74,8 @@
+ 1}, \
+ { "disable-cli", GRUB_INSTALL_OPTIONS_DISABLE_CLI, 0, 0, \
+ N_("disabled command line interface access"), 0 }, \
++ { "disable-tpm-string-pcr", GRUB_INSTALL_OPTIONS_DISABLE_TPM_STRING_PCR, 0, 0, \
++ N_("disable TPM string PCR measurements"), 0 }, \
+ { "verbose", 'v', 0, 0, \
+ N_("print verbose messages."), 1 }
+
+@@ -138,7 +140,8 @@ enum grub_install_options {
+ GRUB_INSTALL_OPTIONS_SBAT,
+ GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK,
+ GRUB_INSTALL_OPTIONS_APPENDED_SIGNATURE_SIZE,
+- GRUB_INSTALL_OPTIONS_DISABLE_CLI
++ GRUB_INSTALL_OPTIONS_DISABLE_CLI,
++ GRUB_INSTALL_OPTIONS_DISABLE_TPM_STRING_PCR
+ };
+
+ extern char *grub_install_source_directory;
+@@ -202,7 +205,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
+ int note, size_t appsig_size,
+ grub_compression_t comp, const char *dtb_file,
+ const char *sbat_path, const int disable_shim_lock,
+- const int disable_cli);
++ const int disable_cli,
++ const int disable_tpm_string_pcr);
+
+ const struct grub_install_image_target_desc *
+ grub_install_get_image_target (const char *arg);
+diff --git a/util/grub-install-common.c b/util/grub-install-common.c
+index 42aec141e..9cfa14acc 100644
+--- a/util/grub-install-common.c
++++ b/util/grub-install-common.c
+@@ -470,6 +470,7 @@ static size_t nx509keys;
+ static grub_compression_t compression;
+ static size_t appsig_size;
+ static int disable_cli;
++static int disable_tpm_string_pcr;
+
+ int
+ grub_install_parse (int key, char *arg)
+@@ -518,6 +519,9 @@ grub_install_parse (int key, char *arg)
+ case GRUB_INSTALL_OPTIONS_DISABLE_CLI:
+ disable_cli = 1;
+ return 1;
++ case GRUB_INSTALL_OPTIONS_DISABLE_TPM_STRING_PCR:
++ disable_tpm_string_pcr = 1;
++ return 1;
+
+ case GRUB_INSTALL_OPTIONS_VERBOSITY:
+ verbosity++;
+@@ -712,13 +716,14 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
+ grub_util_info ("grub-mkimage --directory '%s' --prefix '%s' --output '%s'"
+ " --format '%s' --compression '%s'"
+ " --appended-signture-size %zu %s%s%s\n",
+- " --format '%s' --compression '%s'%s%s%s%s\n",
++ " --format '%s' --compression '%s'%s%s%s%s%s\n",
+ dir, prefix, outname,
+ mkimage_target, compnames[compression],
+ appsig_size,
+ note ? " --note" : "",
+ disable_shim_lock ? " --disable-shim-lock" : "",
+- disable_cli ? " --disable-cli" : "", s);
++ disable_cli ? " --disable-cli" : "",
++ disable_tpm_string_pcr ? " --disable-tpm-string-pcr" : "", s);
+ free (s);
+
+ tgt = grub_install_get_image_target (mkimage_target);
+@@ -731,7 +736,8 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix,
+ x509keys, nx509keys,
+ config_path, tgt,
+ note, appsig_size, compression, dtb, sbat,
+- disable_shim_lock, disable_cli);
++ disable_shim_lock, disable_cli,
++ disable_tpm_string_pcr);
+ while (dc--)
+ grub_install_pop_module ();
+ }
+diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c
+index 13bdc6cf0..99d5c6046 100644
+--- a/util/grub-mkimage.c
++++ b/util/grub-mkimage.c
+@@ -85,6 +85,7 @@ static struct argp_option options[] = {
+ {"sbat", 's', N_("FILE"), 0, N_("SBAT metadata"), 0},
+ {"disable-shim-lock", GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK, 0, 0, N_("disable shim_lock verifier"), 0},
+ {"disable-cli", GRUB_INSTALL_OPTIONS_DISABLE_CLI, 0, 0, N_("disable command line interface access"), 0},
++ {"disable-tpm-string-pcr", GRUB_INSTALL_OPTIONS_DISABLE_TPM_STRING_PCR, 0, 0, N_("disable TPM string PCR measurements"), 0},
+ {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
+ {"appended-signature-size", 'S', N_("SIZE"), 0, N_("Add a note segment reserving SIZE bytes for an appended signature"), 0},
+ { 0, 0, 0, 0, 0, 0 }
+@@ -135,6 +136,7 @@ struct arguments
+ int disable_shim_lock;
+ size_t appsig_size;
+ int disable_cli;
++ int disable_tpm_string_pcr;
+ const struct grub_install_image_target_desc *image_target;
+ grub_compression_t comp;
+ };
+@@ -265,6 +267,10 @@ argp_parser (int key, char *arg, struct argp_state *state)
+ arguments->disable_cli = 1;
+ break;
+
++ case GRUB_INSTALL_OPTIONS_DISABLE_TPM_STRING_PCR:
++ arguments->disable_tpm_string_pcr = 1;
++ break;
++
+ case 'v':
+ verbosity++;
+ break;
+@@ -354,7 +360,8 @@ main (int argc, char *argv[])
+ arguments.appsig_size, arguments.comp,
+ arguments.dtb, arguments.sbat,
+ arguments.disable_shim_lock,
+- arguments.disable_cli);
++ arguments.disable_cli,
++ arguments.disable_tpm_string_pcr);
+
+ if (grub_util_file_sync (fp) < 0)
+ grub_util_error (_("cannot sync `%s': %s"), arguments.output ? : "stdout",
+diff --git a/util/mkimage.c b/util/mkimage.c
+index f92949d1d..7275a1b92 100644
+--- a/util/mkimage.c
++++ b/util/mkimage.c
+@@ -888,7 +888,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
+ const struct grub_install_image_target_desc *image_target,
+ int note, size_t appsig_size, grub_compression_t comp,
+ const char *dtb_path, const char *sbat_path,
+- int disable_shim_lock, int disable_cli)
++ int disable_shim_lock, int disable_cli,
++ int disable_tpm_string_pcr)
+ {
+ char *kernel_img, *core_img;
+ size_t total_module_size, core_size;
+@@ -966,6 +967,9 @@ grub_install_generate_image (const char *dir, const char *prefix,
+ if (disable_cli)
+ total_module_size += sizeof (struct grub_module_header);
+
++ if (disable_tpm_string_pcr)
++ total_module_size += sizeof (struct grub_module_header);
++
+ if (config_path)
+ {
+ config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1);
+@@ -1142,6 +1146,16 @@ grub_install_generate_image (const char *dir, const char *prefix,
+ offset += sizeof (*header);
+ }
+
++ if (disable_tpm_string_pcr)
++ {
++ struct grub_module_header *header;
++
++ header = (struct grub_module_header *) (kernel_img + offset);
++ header->type = grub_host_to_target32 (OBJ_TYPE_DISABLE_TPM_STRING_PCR);
++ header->size = grub_host_to_target32 (sizeof (*header));
++ offset += sizeof (*header);
++ }
++
+ if (config_path)
+ {
+ struct grub_module_header *header;
diff --git a/grub-cc.macros b/grub-cc.macros
index 14d3722..73684c1 100644
--- a/grub-cc.macros
+++ b/grub-cc.macros
@@ -1,4 +1,4 @@
-%global grub_efi_cc_dir %{grub_evr_dir}/EFI/%{os_id}/cc
+%global grub_efi_cc_dir %{grub_evr_dir}/EFI/%{efi_vendor}/cc
%global grubeficcname grub%{efiarch}-cc.efi
%global grubeficccdname gcd%{efiarch}-cc.efi
@@ -22,7 +22,7 @@
%define define_efi_cc_variant(o) \
%{expand:%%package %{1}-cc} \
-Summary: GRUB for EFI systems. \
+Summary: GRUB for EFI Confidential Computing systems. \
Requires: efi-filesystem \
Requires: grub2-common = %{evr} \
Requires: grub2-tools-minimal >= %{evr} \
@@ -38,35 +38,11 @@ This subpackage provides support for Confidential Computing %{1} systems. \
%{expand:%%{?!buildsubdir:%%define buildsubdir grub-%{1}-%{tarversion}-cc}}\
%define do_primary_efi_cc_build() \
-cd grub-%{1}-%{tarversion}-cc \
-%{expand:%%do_efi_cc_configure %%{4} %%{5} %%{6}} \
-%do_efi_build_all \
+cd grub-%{1}-%{tarversion} \
%{expand:%%do_efi_cc_build_images %{grub_target_name} %{2} %{3} ./ } \
cd .. \
%{nil}
-%define do_efi_cc_configure() \
-%configure \\\
- %{cc_equals} \\\
- HOST_CFLAGS="%{3}" \\\
- HOST_CPPFLAGS="-I$(pwd)" \\\
- HOST_LDFLAGS="%{efi_host_ldflags}" \\\
- TARGET_CFLAGS="%{2}" \\\
- TARGET_CPPFLAGS="-I$(pwd)" \\\
- TARGET_LDFLAGS="%{efi_target_ldflags}" \\\
- PACKAGE_STRING="GRUB CC %{version}-%{release}" \\\
- --with-rpm-version=%{version}-%{release} \\\
- --with-platform=efi \\\
- --with-utils=host \\\
- --with-pcr8-disabled=yes \\\
- --target=%{1} \\\
- --with-grubdir=grub2 \\\
- --program-transform-name=s,grub,grub2, \\\
- --disable-werror || ( cat config.log ; exit 1 ) \
-git add . \
-git commit -m "After efi confidential computing configure" \
-%{nil}
-
%define do_efi_cc_build_images() \
GRUB_MODULES+=%{grub_cc_modules} \
GRUB_MODULES+=%{efi_cc_modules} \
@@ -85,6 +61,7 @@ mksquashfs memdisk memdisk.squashfs -comp lzo \
-m memdisk.squashfs \\\
-c '%{SOURCE17}' \\\
-p /EFI/%{efi_vendor} \\\
+ --disable-tpm-string-pcr \\\
${GRUB_MODULES} \
%{4}./grub-mkimage -O %{1} -o %{3}.orig \\\
-d grub-core \\\
@@ -92,7 +69,8 @@ mksquashfs memdisk memdisk.squashfs -comp lzo \
-c '%{SOURCE17}' \\\
-m memdisk.squashfs \\\
-p /EFI/BOOT \\\
- ${GRUB_MODULES} \
+ --disable-tpm-string-pcr \\\
+ ${GRUB_CC_MODULES} \
%{expand:%%define ___pesign_client_cert %{?___pesign_client_cert}%{!?___pesign_client_cert:%{__pesign_client_cert}}} \
%{?__pesign_client_cert:%{expand:%%define __pesign_client_cert %{___pesign_client_cert}}} \
%{expand:%%{pesign -s -i %%{2}.orig -o %%{2}.onesig -a %%{5} -c %%{6} -n %%{7}}} \
@@ -103,7 +81,7 @@ mksquashfs memdisk memdisk.squashfs -comp lzo \
%{nil}
%define do_efi_cc_install() \
-cd grub-%{1}-%{tarversion}-cc \
+cd grub-%{1}-%{tarversion} \
install -d -m 0700 ${RPM_BUILD_ROOT}%{grub_efi_cc_dir}/ \
install -m 700 %{2} $RPM_BUILD_ROOT%{grub_efi_cc_dir}/%{2} \
%{expand:%%do_install_protected_file grub2-%{package_arch}-cc} \
diff --git a/grub.patches b/grub.patches
index 98cf868..2eb4021 100644
--- a/grub.patches
+++ b/grub.patches
@@ -425,11 +425,7 @@ Patch0425: 0425-tests-lib-functional_test-Unregister-commands-on-mod.patch
Patch0426: 0426-commands-usbtest-Use-correct-string-length-field.patch
Patch0427: 0427-commands-usbtest-Ensure-string-length-is-sufficient-.patch
Patch0429: 0429-term-serial.c-default-efi0-as-serial-port-if-present.patch
-Patch0430: 0430-commands-tpm.c-include-PCR-check-enable-disable-func.patch
-Patch0431: 0431-commands-efi-tpm.c-check-if-PCR-is-enable-before-TPM.patch
-Patch0432: 0432-tpm.c-disable-PCR8-measurements-at-the-configuration.patch
Patch0433: 0433-Add-support-for-efi-keyword.patch
-Patch0434: 0434-tpm-Disable-any-GRUB_STRING_PCR-command-measurement.patch
Patch0435: 0435-util-grub-editenv-remove-stale-env_block-on-unsuppor.patch
Patch0436: 0436-Change-login-error-message.patch
Patch0437: 0437-mdraid-fix-metadata-1.0-detection-in-userspace-utils-on-IEEE1275.patch
@@ -441,4 +437,5 @@ Patch0442: 0442-ieee1275-ofpath-enable-NVMeoF-logical-device-transla.patch
Patch0443: 0443-ieee1275-support-added-for-multiple-nvme-bootpaths.patch
Patch0444: 0444-ieee1275-add-support-for-NVMeoFC.patch
Patch0445: 0445-grub-get-kernel-settings-Treate-kernel-uki-dtbloader.patch
-Patch0446: 0446-mm-try-allocating-regions-above-defined-limit-as-las.patch
\ No newline at end of file
+Patch0446: 0446-mm-try-allocating-regions-above-defined-limit-as-las.patch
+Patch0447: 0447-tpm-Only-skip-TPM-string-PCR-measurements-with-expli.patch
\ No newline at end of file
diff --git a/grub2.spec b/grub2.spec
index 8f4df30..7c32f1c 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -17,7 +17,7 @@
Name: grub2
Epoch: 1
Version: 2.12
-Release: 73%{?dist}
+Release: 74%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPL-3.0-or-later
URL: http://www.gnu.org/software/grub/
@@ -694,6 +694,9 @@ fi
%endif
%changelog
+* Mon Aug 3 2026 Leo Sandoval <lsandova@redhat.com> - 2.12-74
+- grub-efi-cc: disable TPM string measurements at runtime
+
* Mon Jul 27 2026 Josue Hernandez <josherna@redhat.com> - 2.12-73
- Fix posttrans-pc condition
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-07 18:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-07 18:20 [rpms/grub2] rawhide: grub-efi-cc: disable TPM string measurements at runtime Leo Sandoval
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox