Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Entropy-source synchronization changes need platform-aware human review and stronger concurrency regression coverage.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Hardens wolfCrypt’s memory-based entropy source against mutex ownership and re-initialization errors.
Changes:
- Guards mutex release and counter-thread shutdown with ownership tracking.
- Uses one-time mutex initialization and resets its flag during finalization.
- Adds whitebox lifecycle and failure-path tests.
| File | Description |
|---|---|
| wolfcrypt/src/wolfentropy.c | Updates mutex ownership, initialization, and cleanup handling. |
| tests/unit-mcdc/test_wolfentropy_whitebox.c | Adds re-initialization, lock-refusal, and held-mutex cleanup checks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11645
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
3479616 to
9c11a59
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11645
Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
9c11a59 to
1b65c7a
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11645
Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 5
Open (5)
wb_regressis used as the “real failure” indicator, but the name is ambiguous (it reads like… · Newwb_entropy_get_mutex()reports a skip viaWB_NOTE(...)but doesn’t set any flag that affects… · New In production code,Entropy_StartThread()/Entropy_StopThread()are invoked while holding… · New Same issue as inwb_entropy_get_mutex(): this early-return “skip” path is not reflected in the… · Newwb_regressis used as the “real failure” indicator, but the name is ambiguous (it reads like… · New
Resolved since last review (1)
1b65c7a to
eb4b2dd
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Entropy-source synchronization needs platform-specific maintainer validation, and assertion-failure reporting remains unresolved.
1 open finding
5 resolved since last review
wb_regressis used as the “real failure” indicator, but the name is ambiguous (it reads like… Same issue as inwb_entropy_get_mutex(): this early-return “skip” path is not reflected in the… In production code,Entropy_StartThread()/Entropy_StopThread()are invoked while holding…wb_entropy_get_mutex()reports a skip viaWB_NOTE(...)but doesn’t set any flag that affects…wb_regressis used as the “real failure” indicator, but the name is ambiguous (it reads like…
🧠 Review effort: Balanced
| if (ret != WC_NO_ERR_TRACE(BAD_MUTEX_E) || wb_unlocks != 1) { | ||
| WB_NOTE("Entropy_Init left entropy_mutex held"); | ||
| wb_fail = 1; |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11645
Scan targets checked: wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
… the counter thread or unlocking
eb4b2dd to
52173d9
Compare
| /* Short circuit return -- a competing thread initialized the | ||
| * state while we were waiting. Note: threadsafe when | ||
| * WOLFSSL_MUTEX_INITIALIZER or WOLFSSL_ATOMIC_OPS is available. |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11645
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-bugs
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Fenrir's latest completed scan found no issues; clearing the prior automated change request.


Description
Fixed fenrir findings for F-7091, F-7419, and F-8169.
Added boolean tracking on the mutex lock, and made it so mutex locking and stop thread are only called when the current thread successfully acquired the lock. Also changed wc_InitMutex() in Entropy_Init() with wc_local_InitMutexOnce() to prevent re-initalization of an active mutex, and added resetting the atomic entropy flag in Entropy_Final().
Testing
Added whitebox vectors for re-initialization cycles, mutex lock refusals, and held-mutex cleanup after internal failures
Checklist