From: Thanos Makatos <[email protected]> While this isn't technically a bug, it's highly unlikely that the server wouldn't be writing an entire struct.
Signed-off-by: Thanos Makatos <[email protected]> Fixes: 667866d66620 ("vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO") Reviewed-by: Cédric Le Goater <[email protected]> Link: https://lore.kernel.org/qemu-devel/[email protected] Signed-off-by: Cédric Le Goater <[email protected]> (cherry picked from commit 3966a4258b597c7e1a86a65d6a0d15f28a09dca8) Signed-off-by: Michael Tokarev <[email protected]> diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index 8feedf82238..df86dabe1e6 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -124,6 +124,11 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy, } trace_vfio_user_get_region_info(msgp->index, msgp->flags, msgp->size); + if (msgp->argsz < sizeof(*info)) { + error_printf("vfio_user_get_region_info reply argsz too small\n"); + return -EINVAL; + } + memcpy(info, &msgp->argsz, info->argsz); /* -- 2.47.3
