Skip to content

Fix a state reading issue due to ppList and auditCommand size increases and cleanups#562

Merged
stefanberger merged 3 commits intomasterfrom
master.next
Mar 5, 2026
Merged

Fix a state reading issue due to ppList and auditCommand size increases and cleanups#562
stefanberger merged 3 commits intomasterfrom
master.next

Conversation

@stefanberger
Copy link
Copy Markdown
Owner

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.

…) (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>
@stefanberger stefanberger merged commit a3bf0cd into master Mar 5, 2026
4 checks passed
@stefanberger stefanberger mentioned this pull request Mar 5, 2026
34 tasks
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.

1 participant