Skip to content

Commit d2303ae

Browse files
committed
fix(uffd): hold settle Lock across PrefetchData read
1 parent e7ad5d8 commit d2303ae

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/orchestrator/pkg/sandbox/uffd/userfaultfd/userfaultfd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,10 @@ func (u *Userfaultfd) faultPage(
530530
}
531531

532532
func (u *Userfaultfd) PrefetchData() block.PrefetchData {
533-
// This will be at worst cancelled when the uffd is closed.
533+
// Hold Lock across the read — Lock; Unlock; Read leaves a window
534+
// where a worker can RLock and mutate prefetchTracker before we read.
534535
u.settleRequests.Lock()
535-
u.settleRequests.Unlock() //nolint:staticcheck // SA2001: intentional — we just need to settle the read locks.
536+
defer u.settleRequests.Unlock()
536537

537538
return u.prefetchTracker.PrefetchData()
538539
}

0 commit comments

Comments
 (0)