Repository navigation
Unload every transient handle reported by TPM_CAP_HANDLES - #666
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Handle cleanup stops after the first capability page and accepts non-transient handles that can clear session configuration, while its test fails on RSA-only TPMs.
3 open issues
What changed in this PR
This PR changes wolfTPM’s transient-handle cleanup to query loaded handles instead of blindly flushing three fixed slots, reducing misleading debug errors when no objects are loaded.
Changes:
- Query
TPM_CAP_HANDLESbefore flushing, retaining the fixed-range fallback if the query fails. - Replace the PQC example’s local cleanup helper with the shared wrapper.
- Document the behavior and add a unit test covering transient-object cleanup.
| File | Description |
|---|---|
wolftpm/tpm2_wrap.h |
Documents capability-based cleanup and fallback behavior. |
tests/unit_tests.c |
Adds a test that creates an SRK and verifies transient handles are unloaded. |
src/tpm2_wrap.c |
Implements capability-based transient-handle cleanup. |
examples/pqc/pqc_ctrl.c |
Reuses the wrapper instead of a local cleanup implementation. |
Review effort: Balanced
dgarske
force-pushed
the
unload_transient
branch
from
November 4, 2026 00:38
16237eb to
caa7cda
Compare
embhorn
requested changes
Nov 5, 2026
embhorn
left a comment
Member
There was a problem hiding this comment.
Skoll Code Review
Scan type: review
Overall recommendation: REQUEST_CHANGES
Findings: 3 total — 3 posted, 0 skipped
3 finding(s) posted as inline comments (see file-level comments below)
Posted findings
- [High] Advance the cursor from the reported handle —
src/tpm2_wrap.c:9488 - [High] Preserve failure reporting for the flush command —
examples/pqc/pqc_ctrl.c:690 - [Medium] Exercise continuation in the new test —
tests/unit_tests.c:1889-1891
Review generated by Skoll
dgarske
force-pushed
the
unload_transient
branch
from
November 5, 2026 18:25
caa7cda to
ae5a50e
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.

wolfTPM2_UnloadHandles_AllTransient()flushed0x80000000to0x80000002blindly. With nothing loaded each flush returnsTPM_RC_HANDLE, whichDEBUG_WOLFTPMprints at the start ofwrap_teston real hardware as if the transport had failed. It also never reached past three handles.The wrapper now queries
TPM_CAP_HANDLESfromTRANSIENT_FIRST, following continuation pages, and flushes exactly the handles reported. If the first query fails it still tries the fixed range. A failed query or flush is now returned to the caller, where this API previously always returned success.src/tpm2_wrap.c,wolftpm/tpm2_wrap.h: the change and its doc note.examples/pqc/pqc_ctrl.c: use the wrapper instead of a local copy of the same query.tests/unit_tests.c: load a transient SRK, flush, confirm none remain.tests/transient_unload_tests.c: scriptedTPM_CAP_HANDLESpages for continuation and the failure paths, which a simulator cannot produce on demand.Tested with
make checkagainst the fwTPM and ibmswtpm2 simulators.