Skip to contentSkip to conversation

Fix missing measurements on confidential computing enabled platform

PATCH In review Hector Cao 3 participants 4 messages Jun 3, 2024 – Jun 5, 2024

lore
Share & tools
lore

Hector Cao

author
#0 lore raw

cover Fix missing measurements on confidential computing enabled platform

Changes from v0:
- Add SOB line
- Compliant with grub coding style

Hector Cao (1):
Fix missing measurements on confidential computing enabled platform

 grub-core/commands/efi/tpm.c | 7 +++++++
 1 file changed, 7 insertions(+)
Signature · 7 lines
2.39.2


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
author
#1 lore raw

PATCH 1/1 Fix missing measurements on confidential computing enabled platform

The measurements for confidential computing has been introduced in the commit 4c76565b6 (efi/tpm: Add EFI_CC_MEASUREMENT_PROTOCOL support). Recently this patch 30708dfe3 (tpm: Disable the tpm verifier if the TPM device is not present) has been introduced to optimize the memory usage when TPM device is not available on the platform. This patch will prevent the tpm module to be loaded on confidential computing platform (for example Intel TDX) where no TPM device is available.

In this patch, we propose to load the tpm module for this use case by generalizing the tpm feature detection in order to cover CC platforms. Basically, do we it by detecting the availability of the EFI protocol EFI_CC_MEASUREMENT_PROTOCOL.

Fixes bug : https://savannah.gnu.org/bugs/?65821

---
 grub-core/commands/efi/tpm.c | 7 +++++++
 1 file changed, 7 insertions(+)
grub-core/commands/efi/tpm.c +7 -0
index f250c30db..40845af7a 100644
@@ -292,6 +292,13 @@ grub_tpm_present (void)
 {
   grub_efi_handle_t tpm_handle;
   grub_efi_uint8_t protocol_version;
+  grub_efi_cc_protocol_t *cc;
+
+  /* if confidential computing measurement protocol is enabled
+     we consider TPM is present */
+  cc = grub_efi_locate_protocol (&cc_measurement_guid, NULL);
+  if (cc != NULL)
+    return 1;
 
   if (!grub_tpm_handle_find (&tpm_handle, &protocol_version))
     return 0;
Signature · 7 lines
2.39.2


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#2 lore raw
Quoted 8 lines · Hector Cao

The measurements for confidential computing has been introduced in the commit 4c76565b6 (efi/tpm: Add EFI_CC_MEASUREMENT_PROTOCOL support). Recently this patch 30708dfe3 (tpm: Disable the tpm verifier if the TPM device is not present) has been introduced to optimize the memory usage when TPM device is not available on the platform. This patch will prevent the tpm module to be loaded on confidential computing platform (for example Intel TDX) where no TPM device is available.

Quoted 8 lines

In this patch, we propose to load the tpm module for this use case by generalizing the tpm feature detection in order to cover CC platforms. Basically, do we it by detecting the availability of the EFI protocol EFI_CC_MEASUREMENT_PROTOCOL.

Fixes bug : https://savannah.gnu.org/bugs/?65821

Quoted 9 lines
---
 grub-core/commands/efi/tpm.c | 7 +++++++
 1 file changed, 7 insertions(+)
grub-core/commands/efi/tpm.c +0 -0
index f250c30db..40845af7a 100644

grub-core/commands/efi/tpm.c grub_tpm_present (void) · line 298

Quoted 7 lines
grub-core/commands/efi/tpm.c +4 -0
@@ -292,6 +292,13 @@ grub_tpm_present (void)
 {
   grub_efi_handle_t tpm_handle;
   grub_efi_uint8_t protocol_version;
+  grub_efi_cc_protocol_t *cc;
+
+  /* if confidential computing measurement protocol is enabled
+     we consider TPM is present */

This is still not in line with the GRUB coding style. Though I will fix it for you this time.

grub-core/commands/efi/tpm.c grub_tpm_present (void) · line 304

Quoted 6 lines
grub-core/commands/efi/tpm.c +3 -0
+  cc = grub_efi_locate_protocol (&cc_measurement_guid, NULL);
+  if (cc != NULL)
+    return 1;
 
   if (!grub_tpm_handle_find (&tpm_handle, &protocol_version))
     return 0;

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
In reply to Hector Cao
Quoted 14 lines · Hector Cao

The measurements for confidential computing has been introduced in the commit 4c76565b6 (efi/tpm: Add EFI_CC_MEASUREMENT_PROTOCOL support). Recently this patch 30708dfe3 (tpm: Disable the tpm verifier if the TPM device is not present) has been introduced to optimize the memory usage when TPM device is not available on the platform. This patch will prevent the tpm module to be loaded on confidential computing platform (for example Intel TDX) where no TPM device is available.

In this patch, we propose to load the tpm module for this use case by generalizing the tpm feature detection in order to cover CC platforms. Basically, do we it by detecting the availability of the EFI protocol EFI_CC_MEASUREMENT_PROTOCOL.

Quoted 4 lines

Fixes bug : https://savannah.gnu.org/bugs/?65821

---

Looks good to me

Reviewed-by: Kuppuswamy Sathyanarayanan
<[email protected]>

Quoted 25 lines
 grub-core/commands/efi/tpm.c | 7 +++++++
 1 file changed, 7 insertions(+)
grub-core/commands/efi/tpm.c +7 -1
index f250c30db..40845af7a 100644
@@ -292,6 +292,13 @@ grub_tpm_present (void)
 {
   grub_efi_handle_t tpm_handle;
   grub_efi_uint8_t protocol_version;
+  grub_efi_cc_protocol_t *cc;
+
+  /* if confidential computing measurement protocol is enabled
+     we consider TPM is present */
+  cc = grub_efi_locate_protocol (&cc_measurement_guid, NULL);
+  if (cc != NULL)
+    return 1;
 
   if (!grub_tpm_handle_find (&tpm_handle, &protocol_version))
     return 0;
--

2.39.2

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel