From a4b256424fcac49975aa094b873a06897b1c3bab Mon Sep 17 00:00:00 2001 From: wangzhiqiang Date: Sun, 25 Jun 2023 11:16:04 +0800 Subject: [PATCH] backport some bugfix patches from upstream Signed-off-by: wangzhiqiang (cherry picked from commit d81775f21f4c3229e5184787999c449b032b5e95) --- ...grind-error-when-dropping-md-duplica.patch | 41 ++++++++++++++ ...ault-if-using-S-select-with-log-repo.patch | 55 +++++++++++++++++++ lvm2.spec | 7 ++- 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 0026-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch create mode 100644 0027-toollib-fix-segfault-if-using-S-select-with-log-repo.patch diff --git a/0026-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch b/0026-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch new file mode 100644 index 0000000..91b6186 --- /dev/null +++ b/0026-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch @@ -0,0 +1,41 @@ +From a326ed70228fd1dff16d6f386bbba2760897f627 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Tue, 25 Apr 2023 14:46:36 -0500 +Subject: [PATCH] lvmcache: fix valgrind error when dropping md duplicate + +When lvmcache info is dropped because it's an md component, +then the lvmcache vginfo can also be dropped, but the list +iterator was still using the list head in vginfo, so break +from the loop earlier to avoid it. +--- + lib/cache/lvmcache.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c +index bee63eb..f67eba2 100644 +--- a/lib/cache/lvmcache.c ++++ b/lib/cache/lvmcache.c +@@ -1193,6 +1193,9 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) + */ + + dm_list_iterate_items_safe(vginfo, vginfo2, &_vginfos) { ++ char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 }; ++ memcpy(vgid, vginfo->vgid, ID_LEN); ++ + dm_list_iterate_items_safe(info, info2, &vginfo->infos) { + dev = info->dev; + device_hint = _get_pvsummary_device_hint(dev->pvid); +@@ -1246,6 +1249,10 @@ void lvmcache_extra_md_component_checks(struct cmd_context *cmd) + lvmcache_del(info); + lvmcache_del_dev_from_duplicates(dev); + cmd->filter->wipe(cmd, cmd->filter, dev, NULL); ++ ++ /* If vginfo was deleted don't continue using vginfo->infos */ ++ if (!_search_vginfos_list(NULL, vgid)) ++ break; + } + } + } +-- +2.33.0 + diff --git a/0027-toollib-fix-segfault-if-using-S-select-with-log-repo.patch b/0027-toollib-fix-segfault-if-using-S-select-with-log-repo.patch new file mode 100644 index 0000000..2d3d2bb --- /dev/null +++ b/0027-toollib-fix-segfault-if-using-S-select-with-log-repo.patch @@ -0,0 +1,55 @@ +From 8877cc0ff8e4f2a52006240fa5575c8051cc351f Mon Sep 17 00:00:00 2001 +From: Peter Rajnoha +Date: Tue, 7 Mar 2023 14:45:06 +0100 +Subject: [PATCH] toollib: fix segfault if using -S|--select with + log/report_command_log=1 setting + +When we are using -S|--select for non-reporting tools while using command log +reporting (log/report_command_log=1 setting), we need to create an internal +processing handle to handle the selection itself. In this case, the internal +processing handle to execute the selection (to process the -S|--select) has +a parent handle (that is processing the actual non-reporting command). + +When this parent handle exists, we can't destroy the command log report +in destroy_processing_handle as there's still the parent processing to +finish. The parent processing may still generate logs which need to be +reported in the command log report. If the command log report was +destroyed prematurely together with destroying the internal processing +handle for -S|--select, then any subsequent log request from processing +the actual command (and hence an attermpt to access the command log report) +ended up with a segfault. + +See also: https://bugzilla.redhat.com/show_bug.cgi?id=2175220 +--- + tools/toollib.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/tools/toollib.c b/tools/toollib.c +index bf744d6..18eb7be 100644 +--- a/tools/toollib.c ++++ b/tools/toollib.c +@@ -1796,7 +1796,20 @@ void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle + + log_restore_report_state(cmd->cmd_report.saved_log_report_state); + +- if (!cmd->is_interactive) { ++ /* ++ * Do not destroy current cmd->report_group and cmd->log_rh ++ * (the log report) yet if we're running interactively ++ * (== running in lvm shell) or if there's a parent handle ++ * (== we're executing nested processing, like it is when ++ * doing selection for parent's process_each_* processing). ++ * ++ * In both cases, there's still possible further processing ++ * to do outside the processing covered by the handle we are ++ * destroying here and for which we may still need to access ++ * the log report to cover the rest of the processing. ++ * ++ */ ++ if (!cmd->is_interactive && !handle->parent) { + if (!dm_report_group_destroy(cmd->cmd_report.report_group)) + stack; + cmd->cmd_report.report_group = NULL; +-- +2.33.0 + diff --git a/lvm2.spec b/lvm2.spec index 9a89342..78f8c40 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.14 -Release: 8 +Release: 9 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -74,6 +74,8 @@ Patch22: 0022-pvscan-fix-filter-symlink-checks.patch Patch23: 0023-udev-repeat.patch Patch24: 0024-use-sync-io-read-bcache-by-defaults.patch Patch25: 0025-vgremove-PVID-file-leakage-in-run-lvm-pvs_online.patch +Patch26: 0026-lvmcache-fix-valgrind-error-when-dropping-md-duplica.patch +Patch27: 0027-toollib-fix-segfault-if-using-S-select-with-log-repo.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -500,6 +502,9 @@ fi %changelog +* Sun Jun 25 2023 wangzhiqiang - 8:2.03.14-9 +- backport some bugfix patches from upstream + * Thu Jun 8 2023 wangzhiqiang - 8:2.03.14-8 - fix fail to create lv and pvid file leakage -- Gitee