Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Critical] drm/virtio: host GPU can overwrite guest read-only memory via 
userptr
--

commit c5dbb2382bf8fa9c29656a9b3e8e517c49a15783
Author: Honglei Huang <[email protected]>
Subject: drm/virtio: wire blob ioctl creation to userptr objects

This commit integrates userptr into the blob resource creation ioctl. It
accepts the userptr hints, validates them against the blob memory type,
and delegates creation to virtio_gpu_userptr_create().

> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c 
> b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index 3d8e4ccdb7c1f..225a550be00ca 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
[ ... ]
> @@ -538,7 +562,10 @@ static int virtio_gpu_resource_create_blob_ioctl(struct 
> drm_device *dev,
>                                     vfpriv->ctx_id, NULL, NULL);
>       }
>  
> -     if (guest_blob)
> +     if (guest_blob &&
> +         (params.blob_hints & DRM_VIRTGPU_BLOB_FLAG_HINT_USERPTR))
> +             ret = virtio_gpu_userptr_create(vgdev, file, &params, &bo);

[Severity: Critical]
Does this code path allow the host GPU to overwrite guest read-only memory?

When the DRM_VIRTGPU_BLOB_FLAG_HINT_USERPTR_RDONLY hint is used, the guest
pins read-only physical pages (like shared libraries) by omitting FOLL_WRITE
in virtio_gpu_userptr_get_pages().

However, when virtio_gpu_userptr_create() delegates to the host:

drivers/gpu/drm/virtio/virtgpu_vq.c:virtio_gpu_cmd_resource_create_blob() {
        ...
        cmd_p->blob_mem = cpu_to_le32(params->blob_mem);
        cmd_p->blob_flags = cpu_to_le32(params->blob_flags);
        ...
}

The blob_hints containing the RDONLY flag are never serialized to the host
in the virtio-gpu protocol. Since the host is unaware of the read-only
restriction, it treats the physical pages as writable. Can guest userspace
then submit 3D rendering commands to the host GPU to modify this read-only
memory, bypassing guest protections?

> +     else if (guest_blob)
>               ret = virtio_gpu_object_create(vgdev, &params, &bo, NULL);
>       else if (!guest_blob && host3d_blob)
>               ret = virtio_gpu_vram_create(vgdev, &params, &bo);

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=4

Reply via email to