* [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages
@ 2026-11-25 11:29 Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 11:29 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
This series fixes the two older bugs that sashiko found in the
push_backup driver during the review of VSTOR-153891, and removes the
push_backup_read and push_backup_write messages that the current
ploop-backup no longer sends.
The first patch rejects a cluster size of 0 in the constructor. Before
it, such a table line divided by zero and oopsed the kernel. Only root
can load a table, but a malformed table line must not crash the node.
The second patch fixes a leak of the backup bitmaps. When a session
expires, the target keeps its bitmaps so that the status can report it
as expired. A new push_backup_start then allocated new bitmaps and
overwrote the pointers to the old ones. With fail_on_process_exit this
is easy to hit, because the session expires as soon as the backup
process exits. setup_pb() now swaps the new bitmaps in and frees the
old ones.
The third patch removes the push_backup_read and push_backup_write
messages. The current ploop-backup uses the event fd since commit
d723a1617e61 ("dm/push_backup: add event file descriptor interface"),
and push_backup_read is the message that sleeps with md->io_barrier
SRCU read locked. push_backup_write() itself stays, because the fd
write path uses it.
I tested the series on 8.2 with a debug kernel with KASAN, lockdep and
kmemleak enabled. The tests covered a table with a cluster size of 0,
the removed messages, a backup through the event fd, the
fail_on_process_exit tests from VSTOR-153891 and repeated restarts of
an expired session. KASAN, lockdep and kmemleak reported nothing, and
the bitmaps no longer leak.
https://virtuozzo.atlassian.net/browse/VSTOR-155791
https://virtuozzo.atlassian.net/browse/VSTOR-155790
https://virtuozzo.atlassian.net/browse/VSTOR-155816
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
Vasileios Almpanis (3):
dm/push_backup: reject a cluster size of 0
dm/push_backup: free the bitmaps of an expired session on restart
dm/push_backup: remove the push_backup_read and push_backup_write messages
drivers/md/dm-push-backup.c | 37 +++++++++----------------------------
include/uapi/linux/dm-push-backup.h | 5 ++---
2 files changed, 11 insertions(+), 31 deletions(-)
---
base-commit: aef96420256e57bf1291859a844800a462f2790e
change-id: 20261125-push-backup-fixes-a4dc3cef9cbe
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
@ 2026-11-25 11:29 ` Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 11:29 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
pb_ctr() parses the cluster size with kstrtou32(), which accepts 0, and
then computes the number of clusters with DIV_ROUND_UP(ti->len, sectors).
So a table line with a cluster size of 0 divides by zero and oopses
inside the constructor. Even if the constructor survived, pb->clu_size
would be 0 and calc_bio_clusters() would divide by it on every write.
Only root can load a table, but a malformed table line must not oops
the kernel. Reject a cluster size of 0 with EINVAL.
https://virtuozzo.atlassian.net/browse/VSTOR-155791
Feature: dm-backup: push backup target driver
Fixes: 162123bc62c7 ("dm: Add push backup driver")
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
drivers/md/dm-push-backup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 745ed28fd074..504713a9430e 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -890,6 +890,11 @@ static int pb_ctr(struct dm_target *ti, unsigned int argc, char **argv)
ti->error = "could not parse cluster size";
goto err;
}
+ if (!sectors) {
+ ret = -EINVAL;
+ ti->error = "cluster size must not be zero";
+ goto err;
+ }
pb->clu_size = to_bytes(sectors);
pb->nr_clus = DIV_ROUND_UP(ti->len, sectors);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
@ 2026-11-25 11:29 ` Vasileios Almpanis
2026-11-25 11:47 ` Konstantin Khorenko
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages Vasileios Almpanis
2026-11-25 11:47 ` [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Konstantin Khorenko
3 siblings, 1 reply; 7+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 11:29 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
When a backup session expires, cleanup_backup() clears pb->alive but
keeps pb->map and pb->pending_map, so that the target status can still
report the session as expired. push_backup_start() refuses to start
only while pb->alive is set, so a start after an expiry goes on to
setup_pb(), which overwrites both pointers with new bitmaps. The old
bitmaps are lost until the target is destroyed, because only
push_backup_stop() and pb_destroy() free them, and they see only the
current pointers.
Each bitmap takes one bit per cluster. For example, on a 32 GiB device
with a cluster size of 1 sector each bitmap is 8 MiB, so every restart
loses 16 MiB. With fail_on_process_exit the session expires as soon as
the sender exits, so this is easy to hit in a loop:
for i in $(seq 1000); do
dmsetup message <pb_dev> 0 push_backup_start 60 0 fail_on_process_exit
done
Swap the new bitmaps in under pb->lock and free the old ones in
setup_pb(). Nothing dereferences the bitmaps of an expired session
without holding pb->lock, so they can be freed once the lock is
dropped. If setting up the new session fails, the expired session
keeps its bitmaps and its expired state.
https://virtuozzo.atlassian.net/browse/VSTOR-155790
Feature: dm-backup: push backup target driver
Fixes: 162123bc62c7 ("dm: Add push backup driver")
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
drivers/md/dm-push-backup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 504713a9430e..433c61b63802 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -434,11 +434,13 @@ static int setup_pb(struct push_backup *pb, void __user *mask, int timeout)
map_bits = bitmap_weight(map, clus);
spin_lock_irq(&pb->lock);
- pb->map = map;
+ swap(pb->map, map);
pb->map_bits = map_bits;
- pb->pending_map = pending_map;
+ swap(pb->pending_map, pending_map);
pb->alive = true;
spin_unlock_irq(&pb->lock);
+ kvfree(map);
+ kvfree(pending_map);
return 0;
err:
kvfree(map);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
@ 2026-11-25 11:29 ` Vasileios Almpanis
2026-11-25 11:47 ` Konstantin Khorenko
2026-11-25 11:47 ` [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Konstantin Khorenko
3 siblings, 1 reply; 7+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 11:29 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
The current ploop-backup gets the ranges to back up and reports the
backed up ranges through the event fd, see commit d723a1617e61
("dm/push_backup: add event file descriptor interface"). It does not
send the push_backup_read and push_backup_write messages anymore.
push_backup_read is also the message that sleeps inside
target_message() with md->io_barrier SRCU read locked, which is the
reason the fd interface was added. Remove both messages, so that this
path cannot be used again.
push_backup_write() stays, because pb_fd_write() uses it. Also drop the
reference to the removed message from the comment of the fd write() in
the uapi header.
https://virtuozzo.atlassian.net/browse/VSTOR-155816
Feature: dm-backup: push backup target driver
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
drivers/md/dm-push-backup.c | 26 --------------------------
include/uapi/linux/dm-push-backup.h | 5 ++---
2 files changed, 2 insertions(+), 29 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 433c61b63802..e01e6c464089 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -550,24 +550,6 @@ static int pb_wait_range(struct push_backup *pb, u64 *clu, u64 *nr)
}
}
-static int push_backup_read(struct push_backup *pb,
- char *result, unsigned int maxlen)
-{
- unsigned int sz = 0;
- u64 clu, nr;
- int ret;
-
- if (!pb)
- return -EBADF;
-
- ret = pb_wait_range(pb, &clu, &nr);
- if (ret == -ERESTARTSYS)
- ret = -EINTR;
- if (ret == 1)
- DMEMIT("%llu:%llu", clu, nr);
- return ret;
-}
-
static int push_backup_write(struct push_backup *pb, u64 clu, u64 nr)
{
u64 i, key, nr_clus = pb->nr_clus;
@@ -790,14 +772,6 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
pb_watch_pid(pb);
} else if (!strcmp(argv[0], "push_backup_stop")) {
ret = push_backup_stop(pb, result, maxlen);
- } else if (!strcmp(argv[0], "push_backup_read")) {
- if (argc != 1)
- goto unlock;
- ret = push_backup_read(pb, result, maxlen);
- } else if (!strcmp(argv[0], "push_backup_write")) {
- if (argc != 2 || sscanf(argv[1], "%llu:%llu", &val, &val2) != 2)
- goto unlock;
- ret = push_backup_write(pb, val, val2);
} else if (!strcmp(argv[0], "push_backup_statistics")) {
ret = push_backup_statistics(pb, result, maxlen);
} else if (!strcmp(argv[0], "push_backup_get_fd")) {
diff --git a/include/uapi/linux/dm-push-backup.h b/include/uapi/linux/dm-push-backup.h
index b43e2e55dc69..b8d336f9fcc2 100644
--- a/include/uapi/linux/dm-push-backup.h
+++ b/include/uapi/linux/dm-push-backup.h
@@ -30,9 +30,8 @@
* EBADMSG - internal inconsistency of the pending state.
*
* write(fd, &range, sizeof(range)):
- * acknowledge that @range has been backed up; equivalent to the
- * "push_backup_write clu:nr" message. Fails with E2BIG if @range is out
- * of the device, ESTALE and ENODEV as read(), and EFAULT.
+ * acknowledge that @range has been backed up. Fails with E2BIG if @range
+ * is out of the device, ESTALE and ENODEV as read(), and EFAULT.
*/
#ifndef _UAPI_LINUX_DM_PUSH_BACKUP_H
#define _UAPI_LINUX_DM_PUSH_BACKUP_H
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
@ 2026-11-25 11:47 ` Konstantin Khorenko
0 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-25 11:47 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Den Lunev
I won't apply this version, please send v2 with the changes below.
- The old bitmaps are never freed, not "lost until the target is
destroyed": item 5 of the cover letter reply.
- Drop the 32 GiB example.
- Narrow the last sentence: a failed start still changes the timeout.
On Wed, 25 Nov 2026 11:29:52 +0000, Vasileios Almpanis wrote:
> bitmaps are lost until the target is destroyed, because only
> push_backup_stop() and pb_destroy() free them, and they see only the
> current pointers.
pb_destroy() frees only the current pointers, so the old bitmaps are
never freed; the sentence contradicts itself.
> Each bitmap takes one bit per cluster. For example, on a 32 GiB device
> with a cluster size of 1 sector each bitmap is 8 MiB, so every restart
The first sentence already says what the leak scales with; ploop sets
up the target with the image's cluster size, so the 1-sector example
overstates it.
> dropped. If setting up the new session fails, the expired session
> keeps its bitmaps and its expired state.
setup_pb() writes timeout_in_jiffies and deadline_jiffies before the
allocations, so after a failed start the status shows the expired
session with the timeout of the failed one. Either move the two stores
under pb->lock with the swap, or say "keeps its bitmaps".
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages Vasileios Almpanis
@ 2026-11-25 11:47 ` Konstantin Khorenko
0 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-25 11:47 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Den Lunev
I won't apply this version, please send v2 with the changes below.
- The ploop test and older ploop-backup still send these messages:
items 1 and 2 of the cover letter reply.
- Drop the push_backup_stop pre-step in pb_message(): item 3.
- Bump the target version, drop the dead check: item 4.
On Wed, 25 Nov 2026 11:29:53 +0000, Vasileios Almpanis wrote:
> The current ploop-backup gets the ranges to back up and reports the
> backed up ranges through the event fd, see commit d723a1617e61
> ("dm/push_backup: add event file descriptor interface"). It does not
> send the push_backup_read and push_backup_write messages anymore.
Item 1: ploop origin/hci-dev test/tests/test_ploop_tg.py,
test_ploop_tg_push_backup_io_should_work_when_backup_started, sends
both through dmsetup message and fails with ENOTSUPP after this patch.
Item 2: the fd exists only since d723a1617e61, so any ploop-backup
built before it still uses these messages. A node updated to this
kernel before ploop-backup breaks backups.
Item 3: the block in pb_message() that clears pb->alive and wakes the
waiters before taking ctl_rwsem came with 20815dd41f13 to kick a
push_backup_read that slept holding ctl_rwsem. Nothing sleeps under it
now, and the block leaves a window where a push_backup_start that comes
in between is torn down by the waiting stop. The argc check then goes
back into the stop branch.
Item 4: the version went up with every interface change before (1.1.0
for the fd, 1.2.0 for fail_on_process_exit); this one removes two
messages. push_backup_write() has a single caller, pb_fd_write(),
which never passes NULL, and pb->nr_clus is read before the check.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
` (2 preceding siblings ...)
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages Vasileios Almpanis
@ 2026-11-25 11:47 ` Konstantin Khorenko
3 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-25 11:47 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Den Lunev
I won't apply this version, please send v2 with the changes below.
1. 3/3: ploop's own test still sends both messages; move it to the
event fd first and name that ploop change.
2. 3/3: name the ploop-backup version that stopped sending the
messages, and what keeps an older one off a node with this kernel;
or keep the messages one more release.
3. 3/3: drop the push_backup_stop step before ctl_rwsem in
pb_message() together with push_backup_read.
4. 3/3: bump the target version; drop the dead "if (!pb)" in
push_backup_write().
5. 2/3: message fixes, see the reply to 2/3.
6. Cover letter: name the ploop-backup change, not the kernel commit.
1/3 is fine as is, and the code of 2/3 is right: every dereference of
the bitmaps is under pb->lock.
On Wed, 25 Nov 2026 11:29:50 +0000, Vasileios Almpanis wrote:
> messages. The current ploop-backup uses the event fd since commit
> d723a1617e61 ("dm/push_backup: add event file descriptor interface"),
Item 6: d723a1617e61 only added the interface to the kernel. Name the
ploop-backup change that moved to it.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-25 11:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
2026-11-25 11:47 ` Konstantin Khorenko
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages Vasileios Almpanis
2026-11-25 11:47 ` Konstantin Khorenko
2026-11-25 11:47 ` [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Konstantin Khorenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox