[Devel] [PATCH hci-8.2 v2 4/8] dm-qcow2: fix service_qio_endio() waking a freed target
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Mon Nov 23 18:43:12 MSK 2026
> From: Denis V. Lunev <den at openvz.org>
>
> service_qio_endio() decrements tgt->service_qios and only then calls
> wake_up() on tgt->service_wq. Service qios hold no inflight reference,
> so the waiter in qcow2_service_iter() can see the counter reach zero
> in that gap and return: the backward merge ends, and a dmsetup remove
> frees the target. The wake-up from the image I/O completion then takes
> the freed service_wq lock.
>
> Protect the counter with a dedicated spinlock and hold it over the
> wake-up; the waiters check the counter under the same lock with
> wait_event_lock_irq(), so they cannot return before the completion
> drops it. service_wq.lock itself cannot serve, as the wait takes it
> inside. Count a service qio before dispatching it, so that its
> completion never runs ahead of the increment, and read the status
> under the lock as well.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-156036
>
> Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files")
> Feature: dm-qcow2: block device over QCOW2 files driver
> Signed-off-by: Denis V. Lunev <den at openvz.org>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply at sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261123153640.128227-1-den@openvz.org?part=4
More information about the Devel
mailing list