Skip to content

Commit d725d87

Browse files
committed
fix(uffd): hold settle Lock across PrefetchData read
1 parent 5896b7b commit d725d87

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
@@ -555,9 +555,10 @@ func (u *Userfaultfd) faultPage(
555555
}
556556

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

562563
return u.prefetchTracker.PrefetchData()
563564
}

0 commit comments

Comments
 (0)