block/vvfat: Do not unref qcow on closing backing bdrv
commit8475ea48544b313cf533312846a4899ddecb799c
authorHikaru Nishida <hikarupsp@gmail.com>
Sun, 9 Feb 2020 17:51:56 +0000 (10 02:51 +0900)
committerKevin Wolf <kwolf@redhat.com>
Tue, 18 Feb 2020 09:53:56 +0000 (18 10:53 +0100)
tree9f7398065c697fc3118db709ce6df189a7cdcb2c
parent2d4b5256cf6a091bb6c3516661be11b9ec690f95
block/vvfat: Do not unref qcow on closing backing bdrv

Before this commit, BDRVVVFATState.qcow is unrefed in write_target_close
on closing backing bdrv of vvfat. However, qcow bdrv is opend as a child
of vvfat in enable_write_target() so it will be also unrefed on closing
vvfat itself. This causes use-after-free of qcow on freeing vvfat which
has backing bdrv and qcow bdrv as children in this order because
bdrv_close(vvfat) tries to free qcow bdrv after freeing backing bdrv
as QLIST_FOREACH_SAFE() loop keeps next pointer, but BdrvChild of qcow
is already freed in bdrv_close(backing bdrv).

Signed-off-by: Hikaru Nishida <hikarupsp@gmail.com>
Message-Id: <20200209175156.85748-1-hikarupsp@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vvfat.c