qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Fix use after free error in bdrv_open_inherit()
@ 2018-09-06 14:25 Alberto Garcia
  2018-09-10  8:34 ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Alberto Garcia @ 2018-09-06 14:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alberto Garcia, qemu-block, Kevin Wolf, Max Reitz, qemu-stable

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

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 block.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block.c b/block.c
index 0dbb1fcc7b..a381c8ece8 100644
--- a/block.c
+++ b/block.c
@@ -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. */
-- 
2.11.0

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

* Re: [Qemu-devel] [PATCH] block: Fix use after free error in bdrv_open_inherit()
  2018-09-06 14:25 [Qemu-devel] [PATCH] block: Fix use after free error in bdrv_open_inherit() Alberto Garcia
@ 2018-09-10  8:34 ` Kevin Wolf
  2018-09-10  9:34   ` Alberto Garcia
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2018-09-10  8:34 UTC (permalink / raw)
  To: Alberto Garcia; +Cc: qemu-devel, qemu-block, Max Reitz, qemu-stable

Am 06.09.2018 um 16:25 hat Alberto Garcia geschrieben:
> 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
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>

Thanks, applied to the block branch.

But can we add the reproducer to some iotests case?

Kevin

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

* Re: [Qemu-devel] [PATCH] block: Fix use after free error in bdrv_open_inherit()
  2018-09-10  8:34 ` Kevin Wolf
@ 2018-09-10  9:34   ` Alberto Garcia
  0 siblings, 0 replies; 3+ messages in thread
From: Alberto Garcia @ 2018-09-10  9:34 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel, qemu-block, Max Reitz, qemu-stable

On Mon 10 Sep 2018 10:34:20 AM CEST, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 06.09.2018 um 16:25 hat Alberto Garcia geschrieben:
>> 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
>> 
>> Signed-off-by: Alberto Garcia <berto@igalia.com>
>
> Thanks, applied to the block branch.
>
> But can we add the reproducer to some iotests case?

Yup, I just sent it.

Berto

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

end of thread, other threads:[~2018-09-10  9:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 14:25 [Qemu-devel] [PATCH] block: Fix use after free error in bdrv_open_inherit() Alberto Garcia
2018-09-10  8:34 ` Kevin Wolf
2018-09-10  9:34   ` Alberto Garcia

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).