mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Change the way gVisor TPUProxy passes string arguments to IOCTL syscalls.
Passing the address of the string can't be recognized by the syscall, the syscall expects the address to the first byte of the string which is NUL-terminated. PiperOrigin-RevId: 617430240
This commit is contained in:
@@ -124,7 +124,14 @@ func (fd *tpuFD) getPciDeviceFd(t *kernel.Task, arg hostarch.Addr) (uintptr, fun
|
||||
if err != nil {
|
||||
return 0, func() {}, err
|
||||
}
|
||||
hostFD, err := IOCTLInvokePtrArg[uint32](fd.hostFD, linux.VFIO_GROUP_GET_DEVICE_FD, &pciAddress)
|
||||
// Build a NUL-terminated slice of bytes containing the PCI address.
|
||||
pciAddressBytes, err := unix.ByteSliceFromString(pciAddress)
|
||||
if err != nil {
|
||||
return 0, func() {}, err
|
||||
}
|
||||
// Pass the address of the PCI address' first byte which can be
|
||||
// recognized by the IOCTL syscall.
|
||||
hostFD, err := IOCTLInvokePtrArg[uint32](fd.hostFD, linux.VFIO_GROUP_GET_DEVICE_FD, &pciAddressBytes[0])
|
||||
if err != nil {
|
||||
return 0, func() {}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user