tpuproxy: cap VFIO_DEVICE_GET_INFO copy-out size to appArgsz

len(buf) may be larger than appArgsz since it's required to be at least
deviceInfo.SizeBytes().

PiperOrigin-RevId: 916048743
This commit is contained in:
Jamie Liu
2026-05-15 09:45:49 -07:00
committed by gVisor bot
parent bc65dcecb2
commit 100be8fd1d
@@ -220,7 +220,7 @@ retry:
// gVisor is not supposed to change any device information that is
// returned from the host since gVisor doesn't own the device.
// Passing the device info back to the caller will be just fine.
if _, err := t.CopyOutBytes(arg, buf); err != nil {
if _, err := t.CopyOutBytes(arg, buf[:min(len(buf), appArgsz)]); err != nil {
return 0, err
}
return ret, nil