backport patch from community

This commit is contained in:
wguanghao 2023-11-30 16:18:59 +08:00
parent 6916364bdc
commit ae95209e0b
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,55 @@
From 163371130d7142538b06b7eeb425adf45bb9bd87 Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
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 a5304bf..b3b2efc 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1846,7 +1846,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;
--
1.8.3.1

View File

@ -43,7 +43,7 @@
Name: lvm2
Version: 2.03.09
Release: 14
Release: 15
Epoch: 8
Summary: Tools for logical volume management
License: GPLv2+ and LGPLv2.1 and BSD
@ -73,6 +73,7 @@ Patch21: 0021-fix-check-for-md-raid-imsm-signature-on-4k-devices.patch
Patch22: 0022-clang-remove-unused-assignment.patch
Patch23: 0023-udev-create-symlinks-and-watch-even-in-suspended-sta.patch
Patch24: 0024-udev-import-previous-results-of-blkid-when-in-suspen.patch
patch25: 0025-toollib-fix-segfault-if-using-S-select-with-log-repo.patch
BuildRequires: gcc
BuildRequires: gcc-c++
@ -498,6 +499,9 @@ fi
%changelog
* Thu Nov 30 2023 wuguanghao <wuguanghao3@huawei.com> - 8:2.03.09-15
- bakcport patch from community
* Tue Nov 14 2023 wangzhiqiang <wangzhiqiang95@huawei.com> - 8:2.03.09-14
- fix an issue for the symlink of the by-uuid file lost