diff --git a/0023-udev-create-symlinks-and-watch-even-in-suspended-sta.patch b/0023-udev-create-symlinks-and-watch-even-in-suspended-sta.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ff2ac328bbf38c328c3211ea9a8a831e1081f71 --- /dev/null +++ b/0023-udev-create-symlinks-and-watch-even-in-suspended-sta.patch @@ -0,0 +1,43 @@ +From 0ffad44e2b768a09be410b7d0decceb6404c46d1 Mon Sep 17 00:00:00 2001 +From: Martin Wilck +Date: Fri, 28 Jan 2022 14:42:29 +0100 +Subject: [PATCH 1/2] udev: create symlinks and watch even in suspended state + +If a dm device is suspended, we can't run blkid on it. But earlier +rules (e.g. 11-dm-parts.rules) might have imported previously scanned +properties from the udev db, in particular if the device had been correctly +set up beforehand (DM_UDEV_PRIMARY_SOURCE_FLAG==1). Symlinks for existing +ID_FS_xyz properties must be preserved in this case. Otherwise lower-priority +devices (such as multipath components) might take over the symlink +temporarily. + +Likewise, we should't stop watching a temporarily suspended, but previously +correctly configured dm device. + +Signed-off-by: Martin Wilck +--- + udev/13-dm-disk.rules.in | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in +index fcb2f37..18254b4 100644 +--- a/udev/13-dm-disk.rules.in ++++ b/udev/13-dm-disk.rules.in +@@ -17,10 +17,14 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end" + ENV{DM_NAME}=="?*", SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}" + ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}" + ++ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link" ++ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link" + ENV{DM_SUSPENDED}=="1", GOTO="dm_end" + ENV{DM_NOSCAN}=="1", GOTO="dm_watch" + + (BLKID_RULE) ++ ++LABEL="dm_link" + ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100" + ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" + ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +-- +2.33.0 + diff --git a/0024-udev-import-previous-results-of-blkid-when-in-suspen.patch b/0024-udev-import-previous-results-of-blkid-when-in-suspen.patch new file mode 100644 index 0000000000000000000000000000000000000000..c189a8e3635dd23ee896280713e9b3b9272c5ac2 --- /dev/null +++ b/0024-udev-import-previous-results-of-blkid-when-in-suspen.patch @@ -0,0 +1,55 @@ +From 05176a06cf24cd9be00bd98c76466398841008b9 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Thu, 2 Feb 2023 00:28:12 +0900 +Subject: [PATCH 2/2] udev: import previous results of blkid when in suspended + state + +Follow-up for e10f67e91728f1e576803df884049ecbd92874d0. + +The commit e10f67e91728f1e576803df884049ecbd92874d0 tries to keep device +node symlinks even if the device is in the suspended state. However, +necessary properties that may previously obtained by the blkid command +were not imported at least in the .rules file. So, unless ID_FS_xyz +properties are imported by another earlier .rules file, the device node +symlinks are still lost when event is processed in the suspended state. + +Let's explicitly import the necessary properties. + +RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2158628 +GHPR: https://github.com/lvmteam/lvm2/pull/105 +--- + udev/13-dm-disk.rules.in | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in +index 18254b4..0ca0d57 100644 +--- a/udev/13-dm-disk.rules.in ++++ b/udev/13-dm-disk.rules.in +@@ -17,12 +17,22 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end" + ENV{DM_NAME}=="?*", SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}" + ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}" + +-ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link" +-ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_link" ++ENV{DM_SUSPENDED}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_import" ++ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", GOTO="dm_import" + ENV{DM_SUSPENDED}=="1", GOTO="dm_end" + ENV{DM_NOSCAN}=="1", GOTO="dm_watch" + + (BLKID_RULE) ++GOTO="dm_link" ++ ++LABEL="dm_import" ++IMPORT{db}="ID_FS_USAGE" ++IMPORT{db}="ID_FS_UUID_ENC" ++IMPORT{db}="ID_FS_LABEL_ENC" ++IMPORT{db}="ID_PART_ENTRY_NAME" ++IMPORT{db}="ID_PART_ENTRY_UUID" ++IMPORT{db}="ID_PART_ENTRY_SCHEME" ++IMPORT{db}="ID_PART_GPT_AUTO_ROOT" + + LABEL="dm_link" + ENV{DM_UDEV_LOW_PRIORITY_FLAG}=="1", OPTIONS="link_priority=-100" +-- +2.33.0 + diff --git a/0025-toollib-fix-segfault-if-using-S-select-with-log-repo.patch b/0025-toollib-fix-segfault-if-using-S-select-with-log-repo.patch new file mode 100644 index 0000000000000000000000000000000000000000..ec63bda61b5a794c3e0c6f6ee45ce311bdddde5b --- /dev/null +++ b/0025-toollib-fix-segfault-if-using-S-select-with-log-repo.patch @@ -0,0 +1,55 @@ +From 163371130d7142538b06b7eeb425adf45bb9bd87 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 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 + diff --git a/0026-dm-event-release-buffer-on-dm_event_get_version.patch b/0026-dm-event-release-buffer-on-dm_event_get_version.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e26c0d397ce8b9dede85af7f1a6d0b1af65cfac --- /dev/null +++ b/0026-dm-event-release-buffer-on-dm_event_get_version.patch @@ -0,0 +1,45 @@ +From a203499ba32aabec0e8a9002517e1608e4e83b2c Mon Sep 17 00:00:00 2001 +From: Zdenek Kabelac +Date: Mon, 25 Sep 2023 11:47:40 +0200 +Subject: [PATCH] dm-event: release buffer on dm_event_get_version + +Avoid memory leak in this function. +--- + daemons/dmeventd/libdevmapper-event.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c +index 9e4dd2469..0aabc03e6 100644 +--- a/daemons/dmeventd/libdevmapper-event.c ++++ b/daemons/dmeventd/libdevmapper-event.c +@@ -844,6 +844,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next) + int dm_event_get_version(struct dm_event_fifos *fifos, int *version) { + char *p; + struct dm_event_daemon_message msg = { 0 }; ++ int ret = 0; + + if (daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0)) + return 0; +@@ -851,13 +852,17 @@ int dm_event_get_version(struct dm_event_fifos *fifos, int *version) { + *version = 0; + + if (!p || !(p = strchr(p, ' '))) /* Message ID */ +- return 0; ++ goto out; + if (!(p = strchr(p + 1, ' '))) /* HELLO */ +- return 0; ++ goto out; + if ((p = strchr(p + 1, ' '))) /* HELLO, once more */ + *version = atoi(p); + +- return 1; ++ ret = 1; ++out: ++ free(msg.data); ++ ++ return ret; + } + + void dm_event_log_set(int debug_log_level, int use_syslog) +-- +2.39.3 \ No newline at end of file diff --git a/0027-clean-up-group-struct-in-_stats_create_group-error-path.patch b/0027-clean-up-group-struct-in-_stats_create_group-error-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..010172fbc8e58747bd5a9fdb4b95af518a945879 --- /dev/null +++ b/0027-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/0028-dmstats-Fix-memory-leak-on-error-path.patch b/0028-dmstats-Fix-memory-leak-on-error-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d0608d4a3997729c800fc3bd43a5c0455c9fc26 --- /dev/null +++ b/0028-dmstats-Fix-memory-leak-on-error-path.patch @@ -0,0 +1,25 @@ +From d1f0b89e65fd8817930bbf89051fe03efb0a1db5 Mon Sep 17 00:00:00 2001 +From: Marian Csontos +Date: Tue, 28 Nov 2023 21:41:35 +0100 +Subject: [PATCH] dmstats: Fix memory leak on error path + +--- + libdm/libdm-stats.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c +index 0401b83..037f275 100644 +--- a/libdm/libdm-stats.c ++++ b/libdm/libdm-stats.c +@@ -1968,7 +1968,7 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id, + (strlen(hist_arg)) ? HISTOGRAM_ARG : "", + hist_arg)) < 0) { + log_error(err_fmt, PRECISE_ARG " option."); +- return 0; ++ goto out; + } + } else + opt_args = dm_strdup(""); +-- +2.27.0 + diff --git a/lvm2.spec b/lvm2.spec index 99bc4bfadc77795c7b1f4c5af774d7a5a30230e8..f9a600b49b4ed8c4fc488097bce76fb1369bf036 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -8,7 +8,7 @@ %global use_lockd_dlm 0 %endif -%ifnarch x86_64 aarch64 +%ifnarch x86_64 aarch64 loongarch64 %global use_lockd_sanlock 0 %endif @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.09 -Release: 13 +Release: 19 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -71,6 +71,12 @@ Patch19: 0019-devices-simplify-md-superblock-checking-code.patch Patch20: 0020-gcc-calc-size-in-compile-time.patch 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 +Patch26: 0026-dm-event-release-buffer-on-dm_event_get_version.patch +patch27: 0027-clean-up-group-struct-in-_stats_create_group-error-path.patch +patch28: 0028-dmstats-Fix-memory-leak-on-error-path.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -496,6 +502,24 @@ fi %changelog +* Wed Oct 23 2024 yanshuai - 8:2.03.09-19 +- dmstats: Fix memory leak on error path + +* Wed Nov 22 2023 wangxiaomeng - 8:2.03.09-18 +- lvmlockd: add suport for loongarch64 + +* Tue Dec 19 2023 wuyifeng - 8:2.03.09-17 +- fix an double free in the error path from _stats_creat_group + +* Tue Dec 19 2023 wangzhiqiang - 8:2.03.09-16 +- dm-event: release buffer on dm_event_get_version + +* Thu Nov 30 2023 wuguanghao - 8:2.03.09-15 +- bakcport patch from community + +* Tue Nov 14 2023 wangzhiqiang - 8:2.03.09-14 +- fix an issue for the symlink of the by-uuid file lost + * Sat Oct 29 2022 Xiaole He - 8:2.03.09-13 - backport patches:18-22 for supporting intel vroc raid(virtual raid on cpu)