pcr-oracle/fix-event-reshash-for-cryptouuid.patch

36 lines
1.3 KiB
Diff

From bfd8520b4af3743a51046c83a1382fe1e66cc95a Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Thu, 26 Dec 2024 13:46:45 +0800
Subject: [PATCH] Fix event rehash for grub files on system partition
The crypto device logged by grub may not be 'crypto0'. It could begin
with the 'cryptouuid' prefix like this:
cryptouuid/4203418d2b034db5b9476f013ee3dc80
This commit adds the additional prefix matching for 'cryptouuid' to make
pcr-oracle to search the file on system partition.
Signed-off-by: Gary Lin <glin@suse.com>
---
src/eventlog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/eventlog.c b/src/eventlog.c
index 4277d42..c49599d 100644
--- a/src/eventlog.c
+++ b/src/eventlog.c
@@ -578,7 +578,8 @@ __tpm_event_grub_file_rehash(const tpm_event_t *ev, const tpm_parsed_event_t *pa
const tpm_evdigest_t *md = NULL;
debug(" re-hashing %s\n", __tpm_event_grub_file_describe(parsed));
- if (evspec->device == NULL || !strcmp(evspec->device, "crypto0")) {
+ if (evspec->device == NULL || !strcmp(evspec->device, "crypto0") ||
+ !strncmp(evspec->device, "cryptouuid", strlen("cryptouuid"))) {
debug(" assuming the file resides on system partition\n");
md = runtime_digest_rootfs_file(ctx->algo, evspec->path);
} else {
--
2.43.0