Commit b513b0d4 authored by Jiri Slaby's avatar Jiri Slaby Committed by Gerd Hoffmann

drm/virtio: fix OOB in virtio_gpu_object_create

After commit f651c8b0 ("drm/virtio: factor out the sg_table from
virtio_gpu_object"), virtio_gpu_create_object allocates too small space
to fit everything in. It is because it allocates struct
virtio_gpu_object, but should allocate a newly added struct
virtio_gpu_object_shmem which has 2 more members.

So fix that by using correct type in virtio_gpu_create_object.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: http://patchwork.freedesktop.org/patch/msgid/20200319100421.16267-1-jslaby@suse.cz
Fixes: f651c8b0 ("drm/virtio: factor out the sg_table from virtio_gpu_object")
Cc: Gurchetan Singh <gurchetansingh@chromium.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 0666a8d7)
parent c0f83d16
...@@ -123,15 +123,17 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo) ...@@ -123,15 +123,17 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo)
struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev, struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev,
size_t size) size_t size)
{ {
struct virtio_gpu_object *bo; struct virtio_gpu_object_shmem *shmem;
struct drm_gem_shmem_object *dshmem;
bo = kzalloc(sizeof(*bo), GFP_KERNEL); shmem = kzalloc(sizeof(*shmem), GFP_KERNEL);
if (!bo) if (!shmem)
return NULL; return NULL;
bo->base.base.funcs = &virtio_gpu_shmem_funcs; dshmem = &shmem->base.base;
bo->base.map_cached = true; dshmem->base.funcs = &virtio_gpu_shmem_funcs;
return &bo->base.base; dshmem->map_cached = true;
return &dshmem->base;
} }
static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment