pcrlock: don't accept PCRs > 23 from firmware event log

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
This commit is contained in:
Lennart Poettering
2026-03-12 14:43:47 +01:00
parent 6eab41c813
commit c248d6a409
+5
View 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");