From d3ce23c2247bc6165a7c427b4fb080101a24ecb4 Mon Sep 17 00:00:00 2001 From: Konstantin Bogomolov Date: Wed, 2 Oct 2024 16:15:12 -0700 Subject: [PATCH] Fix improper use of RawSyscall in KVM 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 --- pkg/sentry/platform/kvm/machine_unsafe.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/platform/kvm/machine_unsafe.go b/pkg/sentry/platform/kvm/machine_unsafe.go index 179c318e7..cf2e36c5c 100644 --- a/pkg/sentry/platform/kvm/machine_unsafe.go +++ b/pkg/sentry/platform/kvm/machine_unsafe.go @@ -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") }