From 222f7130c9e3333a2fcf32345a1c3fe529c0f994 Mon Sep 17 00:00:00 2001 From: wangzhiqiang Date: Thu, 21 Mar 2024 10:26:49 +0800 Subject: [PATCH 1/3] backport upstream patch (cherry picked from commit 0bf06dfca1e320b5fd3c09e875fd9fff6a635a5d) --- ...ct-in-_stats_create_group-error-path.patch | 43 +++++++++++++++++++ lvm2.spec | 6 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch diff --git a/0017-clean-up-group-struct-in-_stats_create_group-error-path.patch b/0017-clean-up-group-struct-in-_stats_create_group-error-path.patch new file mode 100644 index 0000000..010172f --- /dev/null +++ b/0017-clean-up-group-struct-in-_stats_create_group-error-path.patch @@ -0,0 +1,43 @@ +From eda99fc3839dcd439270ba5977ca6628bd9752cc Mon Sep 17 00:00:00 2001 +From: "Bryn M. Reeves" +Date: Thu, 31 Aug 2023 16:59:02 +0100 +Subject: [PATCH] Clean up group struct in _stats_create_group() error path + +Conflict: NA +Reference: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=eda99fc3839dcd439270ba5977ca6628bd9752cc + +Fix a double free in the error path from _stats_create_group() by +clearing the group struct embedded in the dm_stats handle before +returning: + + device-mapper: message ioctl on (253:0) failed: Invalid argument + Could not create regions from file /var/tmp/File With Spaces. + free(): double free detected in tcache 2 + Aborted (core dumped) +--- + libdm/libdm-stats.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c +index 62b28b69d..dc2907f4e 100644 +--- a/libdm/libdm-stats.c ++++ b/libdm/libdm-stats.c +@@ -3908,9 +3908,14 @@ static int _stats_create_group(struct dm_stats *dms, dm_bitset_t regions, + + /* force an update of the group tag stored in aux_data */ + if (!_stats_set_aux(dms, *group_id, dms->regions[*group_id].aux_data)) +- return 0; ++ goto bad; + + return 1; ++bad: ++ group->group_id = DM_STATS_GROUP_NOT_PRESENT; ++ group->regions = NULL; ++ dm_free((char *) group->alias); ++ return 0; + } + + static int _stats_group_check_overlap(const struct dm_stats *dms, +-- +2.39.3 + diff --git a/lvm2.spec b/lvm2.spec index 0253617..0afcfd8 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.21 -Release: 6 +Release: 7 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -65,6 +65,7 @@ Patch13: 0013-udev-repeat.patch Patch14: 0014-use-sync-io-read-bcache-by-defaults.patch Patch15: 0015-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch Patch16: 0016-dm-event-release-buffer-on-dm_event_get_version.patch +Patch17: 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -491,6 +492,9 @@ fi %changelog +* Thu Mar 21 2024 wangzhiqiang - 8:2.03.21-7 +- backport upstream patch + * Wed Feb 28 2024 wangzhiqiang - 8:2.03.21-6 - revert version to 2.03.21 -- Gitee From dbb452875c58a6abaf2589d51aeb4f2ed61b99bc Mon Sep 17 00:00:00 2001 From: yanshuai01 Date: Tue, 7 May 2024 11:00:10 +0800 Subject: [PATCH 2/3] do not pass empty string in callback --- ...do-not-pass-empty-string-in-callback.patch | 29 +++++++++++++++++++ lvm2.spec | 6 +++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 0018-do-not-pass-empty-string-in-callback.patch diff --git a/0018-do-not-pass-empty-string-in-callback.patch b/0018-do-not-pass-empty-string-in-callback.patch new file mode 100644 index 0000000..4ef293a --- /dev/null +++ b/0018-do-not-pass-empty-string-in-callback.patch @@ -0,0 +1,29 @@ +From e022805f1d908cd9da8701db99a8e8ffd97c5519 Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Tue, 4 Jul 2023 22:46:50 +0200 +Subject: [PATCH] pool: do not pass empty string in callback + +When preparing cmdline to executing dmpd tool, avoid adding +empty string ("") on such line. + +--- + lib/activate/dev_manager.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c +index 07d5873..469d71f 100644 +--- a/lib/activate/dev_manager.c ++++ b/lib/activate/dev_manager.c +@@ -2529,7 +2529,8 @@ static int _pool_callback(struct dm_tree_node *node, + data->global); + return 0; + } +- argv[++args] = cv->v.str; ++ if (cv->v.str[0]) ++ argv[++args] = cv->v.str; + } + + if (args == 16) { +-- +2.27.0 + diff --git a/lvm2.spec b/lvm2.spec index 0afcfd8..a3597c1 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.21 -Release: 7 +Release: 8 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -66,6 +66,7 @@ Patch14: 0014-use-sync-io-read-bcache-by-defaults.patch Patch15: 0015-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch Patch16: 0016-dm-event-release-buffer-on-dm_event_get_version.patch Patch17: 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch +Patch18: 0018-do-not-pass-empty-string-in-callback.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -492,6 +493,9 @@ fi %changelog +* Tue May 7 2024 yanshuai - 8:2.03.21-8 +- pool: do not pass empty string in callback + * Thu Mar 21 2024 wangzhiqiang - 8:2.03.21-7 - backport upstream patch -- Gitee From df42ae28c961f95c4cee7de3fc8f664cbf773986 Mon Sep 17 00:00:00 2001 From: yanshuai01 Date: Thu, 9 May 2024 16:05:09 +0800 Subject: [PATCH 3/3] fix memleak in vgchange --- 0019-fix-memleak-in-vgchange.patch | 28 ++++++++++++++++++++++++++++ lvm2.spec | 6 +++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 0019-fix-memleak-in-vgchange.patch diff --git a/0019-fix-memleak-in-vgchange.patch b/0019-fix-memleak-in-vgchange.patch new file mode 100644 index 0000000..b5703e4 --- /dev/null +++ b/0019-fix-memleak-in-vgchange.patch @@ -0,0 +1,28 @@ +From 7ec97ed5f2b95585eb1538ee6edeedb7275101eb Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Wed, 12 Jul 2023 14:15:41 +0200 +Subject: [PATCH] cov: fix memleak in vgchange + +Release allocated vgname from get_single_vgname_cmd_arg() +when it is not returned via *vgname_ret. + +--- + tools/vgchange.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tools/vgchange.c b/tools/vgchange.c +index 63861b5..7a53a7f 100644 +--- a/tools/vgchange.c ++++ b/tools/vgchange.c +@@ -863,6 +863,8 @@ static int _vgchange_autoactivation_setup(struct cmd_context *cmd, + *flags &= ~READ_WITHOUT_LOCK; + cmd->can_use_one_scan = 0; + } ++ ++ free(vgname); + return 1; + + } +-- +2.27.0 + diff --git a/lvm2.spec b/lvm2.spec index a3597c1..5b7e55a 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.21 -Release: 8 +Release: 9 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -67,6 +67,7 @@ Patch15: 0015-vgchange-acquire-an-exclusive-VG-lock-for-refresh.patch Patch16: 0016-dm-event-release-buffer-on-dm_event_get_version.patch Patch17: 0017-clean-up-group-struct-in-_stats_create_group-error-path.patch Patch18: 0018-do-not-pass-empty-string-in-callback.patch +Patch19: 0019-fix-memleak-in-vgchange.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -493,6 +494,9 @@ fi %changelog +* Thu May 9 2024 yanshuai - 8:2.03.21-9 +- cov: fix memleak in vgchange + * Tue May 7 2024 yanshuai - 8:2.03.21-8 - pool: do not pass empty string in callback -- Gitee