qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio: abort on zero config length
@ 2013-04-25  7:43 Jason Wang
  2013-04-25  8:11 ` Michael S. Tsirkin
  2013-04-25 20:20 ` Anthony Liguori
  0 siblings, 2 replies; 11+ messages in thread
From: Jason Wang @ 2013-04-25  7:43 UTC (permalink / raw)
  To: aliguori, qemu-devel, mst; +Cc: Jason Wang

In fact we don't support zero length config length for virtio device. And it can
lead outbound memory access. So abort on zero config length to catch the bug
earlier.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio/virtio.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 1c2282c..a6fa667 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -923,6 +923,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
                  uint16_t device_id, size_t config_size)
 {
     int i;
+    assert(config_size);
     vdev->device_id = device_id;
     vdev->status = 0;
     vdev->isr = 0;
@@ -938,11 +939,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
 
     vdev->name = name;
     vdev->config_len = config_size;
-    if (vdev->config_len) {
-        vdev->config = g_malloc0(config_size);
-    } else {
-        vdev->config = NULL;
-    }
+    vdev->config = g_malloc0(config_size);
     vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,
                                                      vdev);
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-04-26 14:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25  7:43 [Qemu-devel] [PATCH] virtio: abort on zero config length Jason Wang
2013-04-25  8:11 ` Michael S. Tsirkin
2013-04-25 20:20 ` Anthony Liguori
2013-04-25 21:02   ` Michael S. Tsirkin
2013-04-25 22:27     ` Anthony Liguori
2013-04-26  5:06       ` Jason Wang
2013-04-26 10:32         ` Eric Blake
2013-04-26 10:33           ` Jason Wang
2013-04-26 12:31             ` Michael S. Tsirkin
2013-04-26 14:13               ` Anthony Liguori
2013-04-26 11:33           ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).