virtio-gpu: fix information leak in capset get dispatch
PATCH 1/1 virtio-gpu: fix information leak in capset get dispatch
From: Li Qiang <[email protected]>
In virgl_cmd_get_capset function, it uses g_malloc to allocate a response struct to the guest. As the 'resp'struct hasn't been full initialized it will lead the 'resp->padding' field to the guest. Use g_malloc0 to avoid this.
--- hw/display/virtio-gpu-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/virtio-gpu-3d.c +1 -1
@@ -371,7 +371,7 @@ static void virgl_cmd_get_capset(VirtIOGPU *g,virgl_renderer_get_cap_set (gc.capset_id, &max_ver, &max_size); - resp =g_malloc (sizeof (*resp) + max_size); + resp =g_malloc0 (sizeof (*resp) + max_size); resp->hdr.type =VIRTIO_GPU_RESP_OK_CAPSET ; virgl_renderer_fill_caps(gc.capset_id,
Signature · 1 line
1.8.3.1
Hi
Quoted 9 lines · Li Qiang
From: Li Qiang <[email protected]>
In
virgl_cmd_get_capsetfunction, it usesg_mallocto allocate a response struct to the guest. As the 'resp'struct hasn't been full initialized it will lead the 'resp->padding' field to the guest. Useg_malloc0to avoid this.Signed-off-by Li Qiang <[email protected]>
I was about to point out this in the previous memset patch
---
Quoted 20 lines
hw/display/virtio-gpu-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/display/virtio-gpu-3d.c +1
-2@@ -371,7 +371,7 @@ static void virgl_cmd_get_capset(VirtIOGPU *g,virgl_renderer_get_cap_set (gc.capset_id, &max_ver, &max_size); - resp =g_malloc (sizeof (*resp) + max_size); + resp =g_malloc0 (sizeof (*resp) + max_size); resp->hdr.type =VIRTIO_GPU_RESP_OK_CAPSET ; virgl_renderer_fill_caps(gc.capset_id, --1.8.3.1
Quoted 1 line
--
Marc-André Lureau
Ping!
2016-11-01 20:37 GMT+08:00 Li Qiang <[email protected]>:
Quoted 29 lines
From: Li Qiang <[email protected]>
In
virgl_cmd_get_capsetfunction, it usesg_mallocto allocate a response struct to the guest. As the 'resp'struct hasn't been full initialized it will lead the 'resp->padding' field to the guest. Useg_malloc0to avoid this.Signed-off-by Li Qiang <[email protected]>--- hw/display/virtio-gpu-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/display/virtio-gpu-3d.c +1
-2@@ -371,7 +371,7 @@ static void virgl_cmd_get_capset(VirtIOGPU *g,virgl_renderer_get_cap_set (gc.capset_id, &max_ver, &max_size); - resp =g_malloc (sizeof (*resp) + max_size); + resp =g_malloc0 (sizeof (*resp) + max_size); resp->hdr.type =VIRTIO_GPU_RESP_OK_CAPSET ; virgl_renderer_fill_caps(gc.capset_id, --1.8.3.1