]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pcrlock: don't accept PCRs > 23 from firmware event log
authorLennart Poettering <lennart@amutable.com>
Thu, 12 Mar 2026 13:31:42 +0000 (14:31 +0100)
committerLennart Poettering <lennart@amutable.com>
Thu, 12 Mar 2026 13:43:47 +0000 (14:43 +0100)
Let's harden ourselves against shitty firmware which might report an
invalid PCR.

(This is not really a security issue, more a robustness issue, after all
firmware generally comes with highest privileges and trust, even though
it might just be shit)

Fixes an issue found with Claude code review

src/pcrlock/pcrlock.c

index acf68d698b90feb3b0cbd230b62e8f67cd00162f..2d3c0862615a4f48f63959b166cff2e3fb056013 100644 (file)
@@ -949,6 +949,11 @@ static int event_log_load_firmware(EventLog *el) {
                         continue;
                 }
 
+                if (event->pcrIndex >= TPM2_PCRS_MAX) {
+                        log_debug("Skipping event on PCR %" PRIu32 " (out of range).", event->pcrIndex);
+                        continue;
+                }
+
                 r = event_log_add_record(el, &record);
                 if (r < 0)
                         return log_error_errno(r, "Failed to add record to event log: %m");