check for bs->drv in bdrv_flush
PATCH 1/1 check for bs->drv in bdrv_flush
All the bdrv_ helpers should check for bs->drv being zero as that means there is no backend image open. bdrv_flush fails to perform that check and can thus cause NULL pointer dereferences.
Found using qemu-io.
block.c +2 -0
@@ -979,6 +979,8 @@ const char *bdrv_get_device_name(BlockDrvoid bdrv_flush (BlockDriverState *bs) { +if (!bs->drv) +return ;if (bs->drv->bdrv_flush) bs->drv->bdrv_flush (bs);if (bs->backing_hd)
Anthony Liguori
AppliedQuoted 6 lines · Christoph Hellwig
All the
bdrv_helpers should check forbs->drvbeing zero as that means there is no backend image open.bdrv_flushfails to perform that check and can thus cause NULL pointer dereferences.Found using qemu-io.
Applied. Thanks.
FWIW, I plan to include qemu-io once you rebase the series to use IOVectors instead of struct iovec. It looks like a useful tool!
Regards,
Anthony Liguori
Quoted 20 lines
Signed-off-by Christoph Hellwig <[email protected]>Index:
qemu/block.c
===================================================================block.c +2
-0@@ -979,6 +979,8 @@ const char *bdrv_get_device_name(BlockDrvoid bdrv_flush (BlockDriverState *bs) { +if (!bs->drv) +return ;if (bs->drv->bdrv_flush) bs->drv->bdrv_flush (bs);if (bs->backing_hd)
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Christoph Hellwig
All the
bdrv_helpers should check forbs->drvbeing zero as that means there is no backend image open.bdrv_flushfails to perform that check and can thus cause NULL pointer dereferences.
Quoted 7 lines
Quoted 2 lines
Found using qemu-io.
Applied. Thanks.
FWIW, I plan to include qemu-io once you rebase the series to use IOVectors instead of struct iovec. It looks like a useful tool!
The repost already uses QEMUIOVectors, I'll resend it with a formal description.