Fix a state reading issue due to ppList and auditCommand size increases and cleanups#562
Merged
stefanberger merged 3 commits intomasterfrom Mar 5, 2026
Merged
Fix a state reading issue due to ppList and auditCommand size increases and cleanups#562stefanberger merged 3 commits intomasterfrom
stefanberger merged 3 commits intomasterfrom
Conversation
…) (BUGFIX) The current libtpms v0.10.2 does not accept a TPM 2 state that was written with a more recent version of libtpms if the sizes of ppList and/or auditCommands increased. Remove the asserts that trigger state reading failures and limit array_size to the sizeof(data->ppList) and sizeof(data->auditCommands) respectively . More recent versions of libtpms, if they support more TPM 2 commands, will extend these arrays but those new commands will not be usable by older versions of libtpms (via profile and StateFormatLevel) and can therefore be ignored by truncating those arrays. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Use the BITS_TO_BYTES macro where the number of bits is used for calculating the size of a byte array. Also, make the clearing of the rest of the byte arrays (ppList and auditCommands) a bit more efficient than clearing the whole array before copying the new data into it. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
It is not necessary anymore to check for an increase of the sizes of the PERSISTENT_DATA ppList and auditCommands fields since they are marshalled with an array-size indicator. Any previous version of libtpms should be able to resume a profile with the ppList and auditCommands written with a later version. If later versions have new commands, then those new commands must be added beyond the current TPM_CC_FIRST. The ppList and auditCommands may be bigger than before but can be truncated IFF new commands were added. These new commands will not be usable with the older verison of libtpms based on the StateFormatLevel then. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5eb2eec to
636af2c
Compare
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.
This PR fixes a state reading issue that occurs if a later version of libtpms write larger ppList and/or auditCommand arrays.
Do some cleanups around the ppList and auditCommands. Remove a test for the current sizes of these arrays that is not necessary anymore to have.