* [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs
@ 2026-11-25 12:12 Vasileios Almpanis
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 12:12 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.
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, which were never freed. 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.
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,
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
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
Changes in v2:
- Drop the patch that removed the push_backup_read and push_backup_write
messages. The ploop test still sends them and an older ploop-backup
has nothing that keeps it off this kernel, so it will come separately.
- 2/2: say that the old bitmaps are never freed, drop the 32 GiB
example and say that a failed start keeps only the bitmaps.
- Link to v1: http://lore.virtuozzo.com/20261125-push-backup-fixes-v1-0-8d5cc55c30a1@virtuozzo.com
---
Vasileios Almpanis (2):
dm/push_backup: reject a cluster size of 0
dm/push_backup: free the bitmaps of an expired session on restart
drivers/md/dm-push-backup.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 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] 8+ messages in thread
* [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
@ 2026-11-25 12:12 ` Vasileios Almpanis
2026-12-01 0:14 ` no-reply
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 12:12 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] 8+ messages in thread
* [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
@ 2026-11-25 12:12 ` Vasileios Almpanis
2026-12-01 0:15 ` no-reply
2026-11-25 12:16 ` [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Andrey Zhadchenko
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Vasileios Almpanis @ 2026-11-25 12:12 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 never freed, because push_backup_stop() and pb_destroy()
free only the current pointers.
Each bitmap takes one bit per cluster. 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.
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] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
@ 2026-11-25 12:16 ` Andrey Zhadchenko
2026-11-30 15:06 ` Konstantin Khorenko
2026-11-30 15:06 ` Konstantin Khorenko
4 siblings, 0 replies; 8+ messages in thread
From: Andrey Zhadchenko @ 2026-11-25 12:16 UTC (permalink / raw)
To: Vasileios Almpanis, Konstantin Khorenko; +Cc: Den Lunev, devel
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
On 11/25/26 13:12, Vasileios Almpanis wrote:
> This series fixes the two older bugs that sashiko found in the
> push_backup driver during the review of VSTOR-153891.
>
> 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, which were never freed. 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.
>
> 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,
> 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
>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> ---
> Changes in v2:
> - Drop the patch that removed the push_backup_read and push_backup_write
> messages. The ploop test still sends them and an older ploop-backup
> has nothing that keeps it off this kernel, so it will come separately.
> - 2/2: say that the old bitmaps are never freed, drop the 32 GiB
> example and say that a failed start keeps only the bitmaps.
> - Link to v1: http://lore.virtuozzo.com/20261125-push-backup-fixes-v1-0-8d5cc55c30a1@virtuozzo.com
>
> ---
> Vasileios Almpanis (2):
> dm/push_backup: reject a cluster size of 0
> dm/push_backup: free the bitmaps of an expired session on restart
>
> drivers/md/dm-push-backup.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
> ---
> base-commit: aef96420256e57bf1291859a844800a462f2790e
> change-id: 20261125-push-backup-fixes-a4dc3cef9cbe
>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
` (2 preceding siblings ...)
2026-11-25 12:16 ` [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Andrey Zhadchenko
@ 2026-11-30 15:06 ` Konstantin Khorenko
2026-11-30 15:06 ` Konstantin Khorenko
4 siblings, 0 replies; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 15:06 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Den Lunev
Applying as is.
On Wed, 25 Nov 2026 12:12:04 +0000, Vasileios Almpanis wrote:
> - Drop the patch that removed the push_backup_read and push_backup_write
> messages. The ploop test still sends them and an older ploop-backup
> has nothing that keeps it off this kernel, so it will come separately.
Thank you, all v1 items are done; the code of both patches is the same
as in v1.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
` (3 preceding siblings ...)
2026-11-30 15:06 ` Konstantin Khorenko
@ 2026-11-30 15:06 ` Konstantin Khorenko
4 siblings, 0 replies; 8+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 15:06 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: Den Lunev, devel
On Wed, 25 Nov 2026 12:12:04 +0000, Vasileios Almpanis wrote:
> dm/push_backup: fix two old bugs
>
> This series fixes the two older bugs that sashiko found in the
> push_backup driver during the review of VSTOR-153891.
>
> 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.
>
> [...]
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.6.vz10, thanks!
[1/2] dm/push_backup: reject a cluster size of 0
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/388047c8f1b5
[2/2] dm/push_backup: free the bitmaps of an expired session on restart
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/334e57cb30bb
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
@ 2026-12-01 0:14 ` no-reply
0 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2026-12-01 0:14 UTC (permalink / raw)
To: Vasileios Almpanis, 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>
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@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125-push-backup-fixes-v2-0-195a2bcd82f7@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
@ 2026-12-01 0:15 ` no-reply
0 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2026-12-01 0:15 UTC (permalink / raw)
To: Vasileios Almpanis, 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 never freed, because push_backup_stop() and pb_destroy()
> free only the current pointers.
>
> Each bitmap takes one bit per cluster. 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.
>
> 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>
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@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125-push-backup-fixes-v2-0-195a2bcd82f7@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-01 0:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 12:12 [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Vasileios Almpanis
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 1/2] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
2026-12-01 0:14 ` no-reply
2026-11-25 12:12 ` [Devel] [PATCH hci-8.2 v2 2/2] dm/push_backup: free the bitmaps of an expired session on restart Vasileios Almpanis
2026-12-01 0:15 ` no-reply
2026-11-25 12:16 ` [Devel] [PATCH hci-8.2 v2 0/2] dm/push_backup: fix two old bugs Andrey Zhadchenko
2026-11-30 15:06 ` Konstantin Khorenko
2026-11-30 15:06 ` Konstantin Khorenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.