From eb1bab4554fa1c985c0e76677de670ea4736c26f Mon Sep 17 00:00:00 2001 From: wuguanghao Date: Sun, 4 Sep 2022 13:55:02 +0800 Subject: [PATCH] fix segfault of pvscan --cache (cherry picked from commit b4eb3b04edf4f7d29a27ac8ae258ae864ccf8de9) --- ...a-fix-segfault-caused-by-using-null-.patch | 35 +++++++++++++++++++ lvm2.spec | 6 +++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 0015-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch diff --git a/0015-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch b/0015-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch new file mode 100644 index 0000000..ef8da8a --- /dev/null +++ b/0015-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch @@ -0,0 +1,35 @@ +From ce58e9d5b37c3e408f2b41c8095980490a87f2a4 Mon Sep 17 00:00:00 2001 +From: Wu Guanghao +Date: Mon, 15 Aug 2022 09:39:02 -0500 +Subject: [PATCH] _vg_read_raw_area: fix segfault caused by using null pointer + +When we tested lvm2, the kernel injected various random faults. + +(gdb) bt +... +(gdb) p vg +$1 = (struct volume_group *) 0x0 +(gdb) p use_previous_vg +$2 = (unsigned int *) 0x0 + +Signed-off-by: Wu Guanghao +--- + lib/format_text/format-text.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c +index 07aaa0b28..c1ccdb031 100644 +--- a/lib/format_text/format-text.c ++++ b/lib/format_text/format-text.c +@@ -428,7 +428,7 @@ static struct volume_group *_vg_read_raw_area(struct cmd_context *cmd, + rlocn->checksum, + &when, &desc); + +- if (!vg && !*use_previous_vg) { ++ if (!vg && (!use_previous_vg || !*use_previous_vg)) { + log_warn("WARNING: Failed to read metadata text at %llu off %llu size %llu VG %s on %s", + (unsigned long long)(area->start + rlocn->offset), + (unsigned long long)rlocn->offset, +-- +2.34.1 + diff --git a/lvm2.spec b/lvm2.spec index d0772d9..cfacb24 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.14 -Release: 5 +Release: 6 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -63,6 +63,7 @@ Patch11: 0011-bugfix-lvm2-fix-the-reuse-of-va_list.patch Patch12: 0012-13-dm-disk.rules-check-DM_NAME-before-create-symlink.patch Patch13: 0013-dev_name-determine-whether-the-dev-aliases-linked-li.patch Patch14: 0014-lvm-code-reduce-cyclomatic-complexity.patch +Patch15: 0015-_vg_read_raw_area-fix-segfault-caused-by-using-null-.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -489,6 +490,9 @@ fi %changelog +* Sun Sep 04 2022 wuguanghao - 8:2.03.14-6 +- lvm: fix segfault of pvscan --cache + * Wed Apr 27 2022 wuguanghao - 8:2.03.14-5 - lvm: fix error of epoch version -- Gitee