Skip to content

Commit

Permalink
Fix improper use of RawSyscall in KVM
Browse files Browse the repository at this point in the history
futex wait needs to be called surrounded by syscall.Entersyscall() and
syscall.Exitsyscall(), which RawSyscall does not do. It was a mistake
to substitute it.

PiperOrigin-RevId: 681629844
  • Loading branch information
konstantin-s-bogom authored and gvisor-bot committed Oct 2, 2024
1 parent ca8d05a commit d3ce23c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sentry/platform/kvm/machine_unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ func (c *vCPU) notify() {
//
// This panics on error.
func (c *vCPU) waitUntilNot(state uint32) {
errno := hostsyscall.RawSyscallErrno(
_, _, errno := unix.Syscall6(
unix.SYS_FUTEX,
uintptr(unsafe.Pointer(&c.state)),
linux.FUTEX_WAIT|linux.FUTEX_PRIVATE_FLAG,
uintptr(state))
uintptr(state),
0, 0, 0)
if errno != 0 && errno != unix.EINTR && errno != unix.EAGAIN {
panic("futex wait error")
}
Expand Down

0 comments on commit d3ce23c

Please sign in to comment.