block: Fix use after free error in bdrv_open_inherit()
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
@@ -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
Kevin Wolf
AppliedAm 06.09.2018 um 16:25 hat Alberto Garcia geschrieben:
Quoted 10 lines
When a block device is opened with
BDRV_O_SNAPSHOTand thebdrv_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=onSigned-off-by Alberto Garcia <[email protected]>
Thanks, applied to the block branch.
But can we add the reproducer to some iotests case?
Kevin
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_SNAPSHOTand thebdrv_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=onSigned-off-by Alberto Garcia <[email protected]>Thanks, applied to the block branch.
But can we add the reproducer to some iotests case?
Yup, I just sent it.
Berto