From 10b58a92d202a9cb5ff00917157d56f43213dec9 Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Tue, 6 Dec 2022 15:52:43 +0100 Subject: [PATCH] Additional patch for 9.2.0 lvm2 Resolves: #2150348 --- ...segfault-verifying-serial-for-non-pv.patch | 133 ++++++++++++++++++ lvm2.spec | 10 +- 2 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch diff --git a/0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch b/0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch new file mode 100644 index 0000000..5832580 --- /dev/null +++ b/0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch @@ -0,0 +1,133 @@ +From b01433cdc841133500a0ed4041b9b35838d45e87 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Fri, 2 Dec 2022 11:59:09 -0600 +Subject: [PATCH] device_id: fix segfault verifying serial for non-pv + +The recent change that verifies sys_serial system.devices entries +using the PVID did not exclude non-PV devices from being checked. +The verification code would attempt to use du->pvid which was null +for the non-PVs causing a segfault. + +(cherry picked from commit 6613a61d3b5ce4d12a6fef79195eac34f30ef4da) +--- + lib/device/device_id.c | 6 ++- + test/shell/devicesfile-serial.sh | 79 ++++++++++++++++++++++++++++++++ + 2 files changed, 83 insertions(+), 2 deletions(-) + +diff --git a/lib/device/device_id.c b/lib/device/device_id.c +index aae875776..96726a448 100644 +--- a/lib/device/device_id.c ++++ b/lib/device/device_id.c +@@ -2237,8 +2237,8 @@ void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, + * number is correct, since serial numbers may not be unique. + * Search for the PVID on other devs in device_ids_check_serial. + */ +- if ((du->idtype == DEV_ID_TYPE_SYS_SERIAL) && +- (!du->pvid || memcmp(dev->pvid, du->pvid, ID_LEN))) { ++ if ((du->idtype == DEV_ID_TYPE_SYS_SERIAL) && du->pvid && ++ memcmp(dev->pvid, du->pvid, ID_LEN)) { + log_debug("suspect device id serial %s for %s", du->idname, dev_name(dev)); + str_list_add(cmd->mem, &cmd->device_ids_check_serial, dm_pool_strdup(cmd->mem, du->idname)); + *device_ids_invalid = 1; +@@ -2570,6 +2570,8 @@ void device_ids_check_serial(struct cmd_context *cmd, struct dm_list *scan_devs, + dm_list_iterate_items(dul, &dus_check) { + if (!dul->du->dev) + continue; ++ if (!dul->du->pvid) ++ continue; + /* save previously matched devs so they can be dropped from + lvmcache at the end if they are no longer used */ + if (!(dil = dm_pool_zalloc(cmd->mem, sizeof(*dil)))) +diff --git a/test/shell/devicesfile-serial.sh b/test/shell/devicesfile-serial.sh +index b7bfce29e..a88c1906a 100644 +--- a/test/shell/devicesfile-serial.sh ++++ b/test/shell/devicesfile-serial.sh +@@ -772,6 +772,85 @@ grep $SERIAL1 out2 + grep $dev3 out3 + grep $SERIAL3 out3 + ++# non-PV devices ++ ++aux wipefs_a $dev1 ++aux wipefs_a $dev2 ++aux wipefs_a $dev3 ++aux wipefs_a $dev4 ++ ++echo $SERIAL1 > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/serial ++echo $SERIAL2 > $SYS_DIR/dev/block/$MAJOR2:$MINOR2/device/serial ++echo $SERIAL2 > $SYS_DIR/dev/block/$MAJOR3:$MINOR3/device/serial ++echo $SERIAL4 > $SYS_DIR/dev/block/$MAJOR4:$MINOR4/device/serial ++ ++rm $DF ++touch $DF ++vgcreate $vg4 $dev4 ++lvmdevices --adddev "$dev1" ++lvmdevices --adddev "$dev2" ++lvmdevices --adddev "$dev3" ++cat $DF ++ ++grep $dev1 $DF |tee out1 ++grep $dev2 $DF |tee out2 ++grep $dev3 $DF |tee out3 ++grep $dev4 $DF |tee out4 ++ ++grep $SERIAL1 out1 ++grep $SERIAL2 out2 ++grep $SERIAL2 out3 ++grep $SERIAL4 out4 ++ ++pvs |tee out ++grep $dev4 out ++not grep $dev1 out ++not grep $dev2 out ++not grep $dev3 out ++ ++pvcreate $dev1 ++pvs |tee out ++grep $dev1 out ++grep $dev4 out ++not grep $dev2 out ++not grep $dev3 out ++ ++pvcreate $dev2 ++pvs |tee out ++grep $dev1 out ++grep $dev4 out ++grep $dev2 out ++not grep $dev3 out ++ ++pvcreate $dev3 ++pvs |tee out ++grep $dev1 out ++grep $dev4 out ++grep $dev2 out ++grep $dev3 out ++ ++PVID1=`pvs "$dev1" --noheading -o uuid | tr -d - | awk '{print $1}'` ++PVID2=`pvs "$dev2" --noheading -o uuid | tr -d - | awk '{print $1}'` ++PVID3=`pvs "$dev3" --noheading -o uuid | tr -d - | awk '{print $1}'` ++PVID4=`pvs "$dev4" --noheading -o uuid | tr -d - | awk '{print $1}'` ++OPVID1=`pvs "$dev1" --noheading -o uuid | awk '{print $1}'` ++OPVID2=`pvs "$dev2" --noheading -o uuid | awk '{print $1}'` ++OPVID3=`pvs "$dev3" --noheading -o uuid | awk '{print $1}'` ++OPVID4=`pvs "$dev4" --noheading -o uuid | awk '{print $1}'` ++ ++grep $dev1 $DF |tee out1 ++grep $dev2 $DF |tee out2 ++grep $dev3 $DF |tee out3 ++grep $dev4 $DF |tee out4 ++ ++grep $PVID1 out1 ++grep $PVID2 out2 ++grep $PVID3 out3 ++grep $PVID4 out4 ++ ++vgcreate $vg2 $dev2 $dev3 ++vgs | grep $vg2 ++ + remove_base + rmmod brd + +-- +2.38.1 + diff --git a/lvm2.spec b/lvm2.spec index 996206b..6987f48 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -63,7 +63,7 @@ Version: 2.03.17 #Release: 0.1.20211115git%{shortcommit}%{?dist}%{?rel_suffix} Release: 4%{?dist}%{?rel_suffix} %else -Release: 2%{?dist}%{?rel_suffix} +Release: 3%{?dist}%{?rel_suffix} %endif License: GPLv2 URL: http://sourceware.org/lvm2 @@ -72,7 +72,8 @@ Source0: lvm2-%{shortcommit}.tgz %else Source0: ftp://sourceware.org/pub/lvm2/releases/LVM2.%{version}.tgz %endif -#Patch1: 0001-make-generate.patch +# BZ 2150348: +Patch1: 0001-device_id-fix-segfault-verifying-serial-for-non-pv.patch BuildRequires: make BuildRequires: gcc @@ -133,7 +134,7 @@ or more physical volumes and creating one or more logical volumes %else %setup -q -n LVM2.%{version} %endif -#%%patch1 -p1 -b .backup1 +%patch1 -p1 -b .backup1 %build %global _default_pid_dir /run @@ -705,6 +706,9 @@ An extensive functional testsuite for LVM2. %endif %changelog +* Tue Dec 06 2022 Marian Csontos - 2.03.17-3 +- Fix segfault during scanning PVs. + * Tue Nov 29 2022 Marian Csontos - 2.03.17-2 - Fix permissions on lvresize_fs_helper.