Potential Memory Leak Bugs in drivers/gpu/drm/virtio/virtgpu_vq.c (Linux 5.6).

Dongyang Zhan zdyzztq at gmail.com
Thu May 28 07:57:05 UTC 2020

My name is Dongyang Zhan, I am a security researcher.
Currently, I found two possible memory bugs in
drivers/gpu/drm/virtio/virtgpu_vq.c (Linux 5.6).
I hope you can help me to confirm them. Thank you.

The first one is resp_buf will not be release in
virtio_gpu_cmd_get_display_info() with the condition
(resp_size <= MAX_INLINE_RESP_SIZE) in virtio_gpu_alloc_cmd_resp().

int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev)
struct virtio_gpu_ctrl_hdr *cmd_p;
struct virtio_gpu_vbuffer *vbuf;
void *resp_buf;
resp_buf = kzalloc(sizeof(struct virtio_gpu_resp_display_info), GFP_KERNEL);
if (!resp_buf)
     return -ENOMEM;
cmd_p =virtio_gpu_alloc_cmd_resp(vgdev,&virtio_gpu_cmd_get_display_info_cb,
sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_display_info),resp_buf); //
memset(cmd_p, 0, sizeof(*cmd_p));
return 0;

virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev,
   int size, int resp_size, void *resp_buf,
   virtio_gpu_resp_cb resp_cb)
struct virtio_gpu_vbuffer *vbuf;

vbuf = kmem_cache_zalloc(vgdev->vbufs, GFP_KERNEL);
if (!vbuf)
return ERR_PTR(-ENOMEM);

vbuf->buf = (void *)vbuf + sizeof(*vbuf);
vbuf->size = size;

vbuf->resp_cb = resp_cb;
vbuf->resp_size = resp_size;
if (resp_size <= MAX_INLINE_RESP_SIZE)
vbuf->resp_buf = (void *)vbuf->buf + size; // resp_buf will never be released.
vbuf->resp_buf = resp_buf;
return vbuf;

The second one is in virtio_gpu_cmd_get_edids(), which is similar with
the last one. resp_buf will not be released.

More information about the dri-devel mailing list