Coverity fixes Harden TPM bounds and configuration paths - #591
Open
aidangarske wants to merge 1 commit into
Open
Coverity fixes Harden TPM bounds and configuration paths#591aidangarske wants to merge 1 commit into
aidangarske wants to merge 1 commit into
Conversation
aidangarske
commented
Sep 7, 2026
Member
- 911493
- 912593
- 913183
- 913184
- 913340
- 913341
There was a problem hiding this comment.
🟡 Changes recommended
wolfTPM2_ST33_GetFwUpgradeCommands now dereferences caps unconditionally and forces haveFwVer=1, violating its documented/covered caps == NULL contract and risking a NULL-pointer crash.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR appears to address multiple Coverity findings by tightening bounds checks in TPM wrapper code paths, hardening packet/response boundary handling, and adjusting configuration/locking behavior in the core TPM2 context cleanup.
Changes:
- Add/strengthen bounds validation to prevent out-of-range writes and inconsistent session mutation (e.g.,
wolfTPM2_SetAuthHandle,wolfTPM2_PolicyPCRMake) and add unit tests for these edge cases. - Refine cleanup-time locking behavior in
TPM2_Cleanupto avoid acquiring/releasing an uninitialized mutex depending on build configuration. - Adjust firmware TPM crypto/curve selection logic to reject unsupported ECC curves at compile-time thresholds.
File summaries
| File | Description |
|---|---|
| tests/unit_tests.c | Adds coverage for wolfTPM2_SetAuthHandle policy-auth offset bounds and non-mutation on failure. |
| tests/fwtpm_unit_tests.c | Tightens PCR properties capability parsing boundary checks in test code. |
| src/tpm2.c | Introduces TPM2_DYNAMIC_HW_LOCK path to conditionally acquire/release the global HW lock during cleanup. |
| src/tpm2_wrap.c | Hardens bounds checks in wolfTPM2_SetAuthHandle and wolfTPM2_PolicyPCRMake; modifies ST33 FW upgrade command selection path. |
| src/fwtpm/fwtpm_crypto.c | Updates ECC curve mapping to reject curves below ECC_MIN_KEY_SZ using preprocessor checks. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aidangarske
marked this pull request as ready for review
September 7, 2026 18:03
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.