[Devel] [PATCH hci-8.2 v9 6/9] dm-ploop: fix use-after-free on the last inflight_md decrement
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Thu Nov 19 14:47:45 MSK 2026
> The last piwb reference is often dropped from the BAT write completion
> in aio context. ploop_bat_write_finish() completes the data pios there,
> and once the last original request is done, suspend can finish and a
> table reload or remove can free the ploop in ploop_destroy(). The
> completing CPU still decrements inflight_md, calls
> wake_up_interruptible() on inflight_md_wq and frees the piwb into
> ploop->pio_pool, so it can lock a freed waitqueue or free into a
> destroyed mempool.
>
> Nothing on the suspend or destroy path waits for inflight_md, and the
> one waiter that exists, ploop_suspend_submitting_pios(), checks the
> counter without a lock. It can see zero and return before the wakeup and
> ploop_free_piwb() are done with the ploop.
>
> Free the piwb first, then decrement inflight_md and wake the waiters
> with wake_up_locked() under inflight_md_wq.lock as the last access to
> the ploop. Unlike wake_up_interruptible(), it wakes the uninterruptible
> wait in ploop_destroy(). In ploop_destroy(), wait for inflight_md to
> drop to zero and then take the same lock before freeing anything, so the
> waker is done with the ploop.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-148171
> Fixes: 9dff9fe86d29 ("dm-ploop: rework bat completion logic")
> Fixes: d1a1e5108aeb ("dm-ploop: add inflight metadata writeback counter")
> Feature: dm-ploop: ploop target driver
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
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/20261119113446.3579457-1-alexander.ivanov@virtuozzo.com?part=6
More information about the Devel
mailing list