qcow2_try_delay_enospc() schedules tgt->event_work on the system
workqueue and arms tgt->enospc_timer, but qcow2_tgt_destroy() frees
the target without waiting for either. A work item queued just
before the device is suspended and removed runs on freed memory.

https://virtuozzo.atlassian.net/browse/VSTOR-152175
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <[email protected]>
---
 drivers/md/dm-qcow2-target.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f4004f6095a7..c49b0f466867 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -254,6 +254,8 @@ static void qcow2_tgt_destroy(struct qcow2_target *tgt)
                destroy_workqueue(tgt->wq);
        }
        qcow2_merge_backward_cancel(tgt);
+       timer_shutdown_sync(&tgt->enospc_timer);
+       cancel_work_sync(&tgt->event_work);
 
        mempool_destroy(tgt->qio_pool);
        mempool_destroy(tgt->qrq_pool);
-- 
2.53.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to