Skip to content

Commit 151b8a8

Browse files
keanji-xclaude
andcommitted
fix(block-buffer-manager): drop redundant epoch-change pre-check
The early is_epoch_change() check in get_ordered_blocks read buffer_state outside the mutex. If buffer_state flipped to EpochChange between the unlocked check and the subsequent mutex acquire, the in-lock recheck (at the start of the loop) would catch it and return the same error — so the pre-check was redundant and only widened the TOCTOU window for analysis. Removing it doesn't change behavior (caller still hits the in-lock check before any state read) and reduces the surface area of audit-flagged synchronization concerns around the dual AtomicU8 + Mutex design. Refs: Galxe/gravity-audit#522 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1165b76 commit 151b8a8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

crates/block-buffer-manager/src/block_buffer_manager.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ impl BlockBufferManager {
605605
self.ready_notifier.notified().await;
606606
}
607607

608-
if self.is_epoch_change() {
609-
return Err(anyhow::anyhow!("Buffer is in epoch change"));
610-
}
608+
// Note: the previous early `is_epoch_change()` check here was redundant
609+
// with the in-lock recheck below at the start of each loop iteration.
610+
// Removing it eliminates a TOCTOU window (buffer_state could flip between
611+
// the unlocked check and the mutex acquire) without changing semantics —
612+
// the in-lock recheck always observes the same state we'd act on.
611613

612614
let start = Instant::now();
613615
info!(

0 commit comments

Comments
 (0)