block/qed: fix use-after-free by nullifying timer pointer after free
PATCH 1/1 block/qed: fix use-after-free by nullifying timer pointer after free
From: Denis Rastyogin <[email protected]>
This error was discovered by fuzzing qemu-img.
In the QED block driver, the need_check_timer timer is freed in bdrv_qed_detach_aio_context, but the pointer to the timer is not set to NULL. This can lead to a use-after-free scenario in bdrv_qed_drain_begin().
The need_check_timer pointer is set to NULL after freeing the timer. Which helps catch this condition when checking in bdrv_qed_drain_begin().
--- block/qed.c | 1 + 1 file changed, 1 insertion(+)
block/qed.c +1 -0
@@ -353,6 +353,7 @@ static void bdrv_qed_detach_aio_context(BlockDriverState *bs)qed_cancel_need_check_timer (s);timer_free (s->need_check_timer); + s->need_check_timer =NULL ; } static void bdrv_qed_attach_aio_context(BlockDriverState *bs,
Signature · 1 line
2.42.2
Stefan Hajnoczi
AppliedQuoted 9 lines · On Tue, Mar 04, 2025 at 11:39:10AM +0300, [email protected] wrote:
From: Denis Rastyogin <[email protected]>
This error was discovered by fuzzing qemu-img.
In the QED block driver, the
need_check_timertimer is freed inbdrv_qed_detach_aio_context, but the pointer to the timer is not set to NULL. This can lead to a use-after-free scenario inbdrv_qed_drain_begin().
Quoted 8 lines
The
need_check_timerpointer is set to NULL after freeing the timer. Which helps catch this condition when checking inbdrv_qed_drain_begin().Signed-off-by Denis Rastyogin <[email protected]>--- block/qed.c | 1 + 1 file changed, 1 insertion(+)
Thanks, applied to my block tree:
https://gitlab.com/stefanha/qemu/commits/block
Stefan