Skip to contentSkip to conversation

block: Fix use after free error in bdrv_open_inherit()

PATCH Applied Alberto Garcia 2 participants 3 messages Sep 6, 2018 – Sep 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: Fix use after free error in bdrv_open_inherit()

When a block device is opened with BDRV_O_SNAPSHOT and the bdrv_append_temp_snapshot() call fails then the error code path tries to unref the already destroyed 'options' QDict.

This can be reproduced easily by setting TMPDIR to a location where the QEMU process can't write:

   $ TMPDIR=/nonexistent $QEMU -drive driver=null-co,snapshot=on
---
 block.c | 1 +
 1 file changed, 1 insertion(+)
block.c +1 -0
index 0dbb1fcc7b..a381c8ece8 100644
@@ -2792,6 +2792,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
     bdrv_parent_cb_change_media(bs, true);
 
     qobject_unref(options);
+    options = NULL;
 
     /* For snapshot=on, create a temporary qcow2 overlay. bs points to the
      * temporary snapshot afterwards. */
Signature · 1 line
2.11.0
Applied
#1 lore raw

Am 06.09.2018 um 16:25 hat Alberto Garcia geschrieben:

Quoted 10 lines

When a block device is opened with BDRV_O_SNAPSHOT and the bdrv_append_temp_snapshot() call fails then the error code path tries to unref the already destroyed 'options' QDict.

This can be reproduced easily by setting TMPDIR to a location where the QEMU process can't write:

   $ TMPDIR=/nonexistent $QEMU -drive driver=null-co,snapshot=on

Thanks, applied to the block branch.

But can we add the reproducer to some iotests case?

Kevin

#2 lore raw
Quoted 8 lines · Kevin Wolf

Am 06.09.2018 um 16:25 hat Alberto Garcia geschrieben:

Quoted 7 lines

When a block device is opened with BDRV_O_SNAPSHOT and the bdrv_append_temp_snapshot() call fails then the error code path tries to unref the already destroyed 'options' QDict.

This can be reproduced easily by setting TMPDIR to a location where the QEMU process can't write:

Quoted 7 lines
Quoted 3 lines
   $ TMPDIR=/nonexistent $QEMU -drive driver=null-co,snapshot=on

Thanks, applied to the block branch.

But can we add the reproducer to some iotests case?

Yup, I just sent it.

Berto