[Devel] [PATCH hci-8.2 v11 7/9] dm-ploop: fix flip_upper_deltas racing with resume

Alexander Ivanov alexander.ivanov at virtuozzo.com
Fri Nov 20 11:17:00 MSK 2026


ploop_preresume() checks noresume under ctl_rwsem, drops the lock and
only then clears ->suspended. Messages are not serialized with resume:
target_message() uses the live table without md->suspend_lock, so
"set_noresume 1" followed by "flip_upper_deltas" can pass the check
in ploop_flip_upper_deltas() in that gap. The device then goes live
with noresume set and the top deltas swapped.

Clear ->suspended in the same critical section as the noresume check,
and only if it passes.

https://virtuozzo.atlassian.net/browse/VSTOR-148171
Fixes: 90bb85536272 ("dm-ploop: Add ploop target driver")
Feature: dm-ploop: ploop target driver

Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 drivers/md/dm-ploop-target.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 3b5f37a58bb1..5cf561afb2e9 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -764,19 +764,16 @@ static int ploop_preresume(struct dm_target *ti)
 	struct ploop *ploop = ti->private;
 	int ret = 0;
 
-	down_read(&ploop->ctl_rwsem);
+	down_write(&ploop->ctl_rwsem);
 	if (ploop->noresume)
 		ret = -EAGAIN;
-	up_read(&ploop->ctl_rwsem);
-
-	if (ret == 0) {
-		/*
-		 * We are singleton target. There will be
-		 * no more reasons to break resume.
-		 */
-		ploop_set_suspended(ti, false);
+	/* Singleton target: nothing after preresume can fail the resume */
+	if (ret == 0)
+		ploop->suspended = false;
+	up_write(&ploop->ctl_rwsem);
+
+	if (ret == 0)
 		ploop_set_wants_suspend(ti, false);
-	}
 	return ret;
 }
 ALLOW_ERROR_INJECTION(ploop_preresume, ERRNO);
-- 
2.53.0



More information about the Devel mailing list