Skip to contentSkip to conversation

block-vmdk.c:vmdk_close() use-after-free

Qemu-devel Ed Maste 1 participant 1 message May 21, 2008

lore
Share & tools
lore

Ed Maste

author
#0 lore raw

I ran into a segfault running qemu-img on FreeBSD (with malloc debugging on by default). It's reproducible by running

qemu-img convert -O vmdk /dev/null x.vmdk

It turns out to be a use-after-free in block-vmdk.c:vmdk_close(). I think the following patch should fix it:

block-vmdk.c (working copy) renamed from block-vmdk.c (revision 4519) +1 -1
Index: block-vmdk.c
===================================================================
@@ -808,9 +808,9 @@
 
     qemu_free(s->l1_table);
     qemu_free(s->l2_cache);
-    bdrv_delete(s->hd);
     // try to close parent image, if exist
     vmdk_parent_close(s->hd);
+    bdrv_delete(s->hd);
 }
 
 static void vmdk_flush(BlockDriverState *bs)

Regards,
Ed