Commit b0ee78ff authored by Li Qiang's avatar Li Qiang Committed by Gerd Hoffmann
Browse files

virtio-gpu: check if the resource already exists in virtio_gpu_load()



While loading virtio-gpu, the data can be malicious, we
should check if the resource already exists.

Signed-off-by: default avatarLi Qiang <liq3ea@163.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20190628161358.10400-1-liq3ea@163.com
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent a7f85e03
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1002,6 +1002,11 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,

    resource_id = qemu_get_be32(f);
    while (resource_id != 0) {
        res = virtio_gpu_find_resource(g, resource_id);
        if (res) {
            return -EINVAL;
        }

        res = g_new0(struct virtio_gpu_simple_resource, 1);
        res->resource_id = resource_id;
        res->width = qemu_get_be32(f);