-
Notifications
You must be signed in to change notification settings - Fork 20
Add GitHub Action workflow for TPM corruption testing #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
devin-ai-integration
wants to merge
7
commits into
master
from
devin/1761720859-tpm-corruption-test-workflow
Closed
Add GitHub Action workflow for TPM corruption testing #154
devin-ai-integration
wants to merge
7
commits into
master
from
devin/1761720859-tpm-corruption-test-workflow
Conversation
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
This workflow provides a reproducible test case for the TPM corruption bug that occurs when filling the TPM with objects until storage exhaustion. The workflow: 1. Builds commit 1a7f7d7 (buggy version) 2. Runs corruption test by filling TPM with AES keys 3. Captures corrupted NVChip as artifact for analysis 4. Builds PR version of wolfPKCS11 5. Tests PR version against corrupted state This serves as a foundation for developing and testing the TPM corruption repair function. Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Can one of the admins verify this patch? |
- Update actions/checkout from v3 to v4 (Node 20 support) - Update actions/upload-artifact from v3 to v4 (fixes deprecation error) - Add NVChip existence verification before upload - Add if-no-files-found: error to upload step for better error handling - Add detailed logging to verify NVChip location and capture Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
Changes requested by user: 1. Remove C_Finalize and unload_library calls from corruption test - These could cause metadata to fix itself upon closing - Use _exit(0) instead to avoid cleanup handlers 2. Update both test programs to use C_GetSlotList instead of hardcoded slot 1 - More robust and portable across different CI environments 3. Update access_test expectations to properly handle migration - Treat CKR_USER_PIN_NOT_INITIALIZED (0x00000102) as migration bug - Provide clear error messages distinguishing migration vs corruption issues - Expect login to succeed after proper migration is implemented These changes prepare the workflow for the upcoming migration/repair function that will detect old-format tokens and set WP11_TOKEN_STATE_INITIALIZED flag. Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Detect tokens from old versions that don't have WP11_TOKEN_STATE_INITIALIZED set - Use heuristics (userPinLen, tokenFlags, objCnt) to determine if token is initialized - Persist migrated state back to storage for one-time fix - Add DEBUG_WOLFPKCS11 logging for migration events - Handles storage write failures gracefully with in-memory fix - Add forward declaration for wp11_Token_Store Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Migrate missing PIN flags when userPinLen/soPinLen > 0 but flags not set - This fixes C_Login failures with CKR_USER_PIN_NOT_INITIALIZED - Old versions may have PINs set but flags not properly set - Add DEBUG_WOLFPKCS11 logging for flag migration events Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
- Enable DEBUG_WOLFPKCS11 in both old and PR builds - Add wolfPKCS11_Debugging_On() calls via dlsym in test programs - Add debug prints to wp11_Token_Load showing pre/post migration state - Add debug prints to WP11_Slot_CheckUserPin showing which condition fails - Add debug prints to WP11_Slot_Has_Empty_Pin showing cached/checked results - This will help diagnose why C_Login still fails with CKR_USER_PIN_NOT_INITIALIZED Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
…ect loading - Add DEBUG_WOLFPKCS11 prints at wp11_Token_Load entry and after storage open - Add debug print before migration block showing ret and key fields - Add debug print in NOT_AVAILABLE_E path - Add debug print after object loading showing final ret value - CRITICAL FIX: Hoist migration logic to run BEFORE object loading loop so it works even if object loading fails due to corruption - Migration now runs right after storage close and before object load - This ensures state and tokenFlags are set correctly even when corrupted objects cause wp11_Object_Load to fail The previous implementation only ran migration inside 'if (ret == 0)' after object loading, which meant it never ran when object loading failed. This caused token fields to remain zero, leading to CKR_USER_PIN_NOT_INITIALIZED errors at C_Login time.
5 tasks
devin-ai-integration bot
added a commit
that referenced
this pull request
Nov 5, 2025
This adds a separate workflow to test the PIN flag upgrade issue from v1.3.0 to v2.0.0 using TPM storage (WOLFPKCS11_TPM_STORE). The workflow: 1. Sets up ibmswtpm2 (software TPM simulator) and wolfTPM 2. Builds wolfPKCS11 v1.3.0 with TPM support and initializes a token with PIN 3. Stops/restarts TPM server to flush NVChip (persists TPM state) 4. Builds PR version (v2.0.0+) with TPM support 5. Tests if the PIN flag is properly detected after upgrade This follows the pattern from PR #154 but uses inline C programs for token initialization and verification. The test uses exit code 100 for the expected bug (CKR_USER_PIN_NOT_INITIALIZED) to distinguish from workflow errors. Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
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.
Add GitHub Action workflow for TPM corruption testing
Summary
This PR adds a GitHub Action workflow that creates a reproducible test case for the TPM corruption bug discovered in commit 1a7f7d7. The workflow serves as a foundation for developing and testing a TPM corruption repair function.
The workflow:
Two files added:
.github/workflows/tpm-corruption-test.yml- The workflow definition with embedded test programs.github/workflows/README-tpm-corruption-test.md- Comprehensive documentationReview & Testing Checklist for Human
pkill -f tpm_serverand artifact capture stepsTest Plan
Notes
Link to Devin run: https://app.devin.ai/sessions/4d37989d79bf4632a9ca5cffed65ddbb
Requested by: andrew@wolfssl.com