AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 59 Bitcoin

Prevent stale fs-store writes after lock cleanup

Public commit record

What the developer wrote

Authored by Elias Rohrer

78/100 · Adequate
Prevent stale fs-store writes after lock cleanup

Reserve write versions while holding the per-path lock map mutex so
cleanup cannot remove the version state between version allocation and
lock reference acquisition.

Add a regression test for the ordering invariant.

Co-Authored-By: HAL 9000

This finding was discovered by Project Loupe
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This patch fixes a subtle race condition in rust-lightning's file-system persistence layer. Previously, the code could reserve a new write version number before it had safely grabbed the corresponding per-file lock. A background cleanup task could then delete the lock entry in between, leaving the version number associated with a lock that no longer exists. The fix grabs the lock map first, then reserves the version while still holding that map lock, and adds a regression test to prove the ordering is correct.

Recommended action

Review the fix for correctness under all concurrency paths, ensure clean_locks and any other callers respect the new invariant, and consider whether additional synchronization is needed elsewhere in the fs_store module. Run the new regression test and related persistence tests.

Security signals we found

01

Race condition between version reservation and lock reference acquisition

02

Potential stale lock entry after lock-map cleanup

03

Concurrency bug in filesystem persistence store

04

Regression test added for ordering invariant

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 8/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.