tpm2_checkquote: Fix off-by-one in PCR digest list handling#3543
Merged
JuergenReppSIT merged 1 commit intotpm2-software:masterfrom Feb 3, 2026
Merged
Conversation
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>
JuergenReppSIT
approved these changes
Feb 3, 2026
Member
JuergenReppSIT
left a comment
There was a problem hiding this comment.
@hyperfinitism Thank you for the PR!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the bug reported in #3542 where
tpm2_checkquotefails 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 intoTPML_DIGESTlists: the code populated 8 digests in a list but leftTPML_DIGEST.countat 7. This causes subsequent processing to detect an inconsistent count, leading to failure.This change ensures that:
TPML_DIGEST.countis kept in sync with the actual number of digests stored.TPML_DIGESTis 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:
7pcrcase succeeded.8pcrcase failed withSomething wrong, trying to print but nothing more.After this change:
7pcrand8pcrcases complete successfully.