Skip to content

tpm2_checkquote: Fix off-by-one in PCR digest list handling#3543

Merged
JuergenReppSIT merged 1 commit intotpm2-software:masterfrom
hyperfinitism:fix/checkquote-8pcrs
Feb 3, 2026
Merged

tpm2_checkquote: Fix off-by-one in PCR digest list handling#3543
JuergenReppSIT merged 1 commit intotpm2-software:masterfrom
hyperfinitism:fix/checkquote-8pcrs

Conversation

@hyperfinitism
Copy link
Contributor

Summary

This PR fixes the bug reported in #3542 where tpm2_checkquote fails when the PCR selection contains 8 or more PCRs.

The root cause is an off-by-one error in parse_selection_data_from_selection_string() when splitting PCR digests into TPML_DIGEST lists: the code populated 8 digests in a list but left TPML_DIGEST.count at 7. This causes subsequent processing to detect an inconsistent count, leading to failure.

This change ensures that:

  • Each TPML_DIGEST.count is kept in sync with the actual number of digests stored.
  • A new TPML_DIGEST is only started after 8 digests have been fully added to the current list.

Testing

I verified the fix using the reproduction script from Issue #3542.

Before this change:

  • The 7pcr case succeeded.
  • The 8pcr case failed with Something wrong, trying to print but nothing more.

After this change:

  • Both 7pcr and 8pcr cases complete successfully.
  • Additional cases (e.g. 9, 10, and all PCRs selected) also succeed without errors.

parse_selection_data_from_selection_string() now updates
TPML_DIGEST.count correctly and rolls over to a new list only after
8 digests, resolving failures with 8+ PCRs in the -f/-l path.

Fixes: tpm2-software#3542

Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
Copy link
Member

@JuergenReppSIT JuergenReppSIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyperfinitism Thank you for the PR!

@JuergenReppSIT JuergenReppSIT merged commit 140a9e7 into tpm2-software:master Feb 3, 2026
23 checks passed
@hyperfinitism hyperfinitism deleted the fix/checkquote-8pcrs branch February 7, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants