Bug 2040937

Summary: lvmdevices segfault attempting to re-add devices file entry after an altered PART value
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: high CC: agk, cluster-qe, heinzm, jbrassow, lvm-team, mcsontos, msnitzer, prajnoha, zkabelac
Version: 9.0Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.15-0.1.20211115git4a1f617.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2040491 Environment:
Last Closed: 2022-05-17 15:56:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2040491    
Bug Blocks:    

Description Corey Marthaler 2022-01-14 23:06:16 UTC
This exists and needs to be fixed in rhel9.0 as well.

Jan 14 17:03:31 hayes-03 kernel: lvmdevices[6442]: segfault at 28 ip 000055fb112d5a96 sp 00007ffd2ed7a060 error 4 in lvm[55fb11256000+182000]

kernel-5.14.0-39.el9    BUILT: Thu Dec 23 10:43:17 PM CST 2021
lvm2-2.03.14-3.el9    BUILT: Tue Jan  4 04:49:45 PM CST 2022


+++ This bug was initially created as a clone of Bug #2040491 +++

Description of problem:
SCENARIO - altered_devicesfile_partition_check_and_repair:  Test the discovery and repair of an altered partition value in devicesfile entry (bug 2039977|2040482)
Copying out blanked system.devices file to begin with
/tmp/system990.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdd1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291ba5c230d16c6 DEVNAME=/dev/sdd1 PVID=. PART=9
Copying out altered system.devices file to hayes-01
/tmp/system1715.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file sys_wwid naa.6d094660575ece002291ba5c230d16c6 PVID none last seen on /dev/sdd1 not found.



[root@hayes-01 ~]# cat /etc/lvm/devices/system.devices
# edited by QA Thu Jan 13 14:08:37 2022# LVM uses devices listed in this file.
# Created by LVM command lvmdevices pid 92867 at Thu Jan 13 14:08:36 2022
VERSION=1.1.1452
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291ba5c230d16c6 DEVNAME=/dev/sdd1 PVID=. PART=9

[root@hayes-01 ~]# lvmdevices --check
  Devices file sys_wwid naa.6d094660575ece002291ba5c230d16c6 PVID none last seen on /dev/sdd1 not found.

[root@hayes-01 ~]# lvmdevices --update
  Devices file sys_wwid naa.6d094660575ece002291ba5c230d16c6 PVID none last seen on /dev/sdd1 not found.
  No update for devices file is needed.

[root@hayes-01 ~]# lvmdevices --adddev /dev/sdd1
  Devices file sys_wwid naa.6d094660575ece002291ba5c230d16c6 PVID none last seen on /dev/sdd1 not found.
Segmentation fault (core dumped)


Version-Release number of selected component (if applicable):
kernel-4.18.0-357.el8    BUILT: Wed Dec 22 15:55:27 CST 2021
lvm2-2.03.14-3.el8    BUILT: Tue Jan  4 14:54:16 CST 2022
lvm2-libs-2.03.14-3.el8    BUILT: Tue Jan  4 14:54:16 CST 2022

--- Additional comment from Corey Marthaler on 2022-01-13 20:22:50 UTC ---

Core was generated by `lvmdevices --adddev /dev/sdd1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005653c3e7b0fe in read_sys_block (cmd=cmd@entry=0x5653c61709f0, dev=0x0, suffix=suffix@entry=0x5653c3fa50b4 "device/wwid", sysbuf=sysbuf@entry=0x7ffec9aff780 "", 
    sysbufsize=sysbufsize@entry=4096) at device/device_id.c:186
186     {
(gdb) bt
#0  0x00005653c3e7b0fe in read_sys_block (cmd=cmd@entry=0x5653c61709f0, dev=0x0, suffix=suffix@entry=0x5653c3fa50b4 "device/wwid", sysbuf=sysbuf@entry=0x7ffec9aff780 "", 
    sysbufsize=sysbufsize@entry=4096) at device/device_id.c:186
#1  0x00005653c3e7b968 in device_id_system_read (cmd=cmd@entry=0x5653c61709f0, dev=0x0, idtype=<optimized out>) at device/device_id.c:310
#2  0x00005653c3e7d2fb in device_id_add (cmd=cmd@entry=0x5653c61709f0, dev=dev@entry=0x5653c6197638, pvid_arg=pvid_arg@entry=0x5653c61976d0 "", idtype_arg=<optimized out>, 
    id_arg=id_arg@entry=0x0) at device/device_id.c:1200
#3  0x00005653c3e2a91f in lvmdevices (cmd=0x5653c61709f0, argc=<optimized out>, argv=<optimized out>) at lvmdevices.c:325
#4  0x00005653c3e28e69 in lvm_run_command (cmd=cmd@entry=0x5653c61709f0, argc=<optimized out>, argc@entry=3, argv=<optimized out>, argv@entry=0x7ffec9b00cc8) at lvmcmdline.c:3295
#5  0x00005653c3e29e64 in lvm2_main (argc=3, argv=0x7ffec9b00cc8) at lvmcmdline.c:3824
#6  0x00007fd9bb611ca3 in __libc_start_main (main=0x5653c3e03150 <main>, argc=3, argv=0x7ffec9b00cc8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7ffec9b00cb8) at ../csu/libc-start.c:314
#7  0x00005653c3e0321e in _start () at lvm.c:23

Comment 1 David Teigland 2022-02-07 20:28:04 UTC
in main branch: https://sourceware.org/git/?p=lvm2.git;a=commit;h=8f50c5e79b6ce619a53d51353dded2f84953af00

improves adding/removing devices when the file has bad entries.

(I have been mixing up this bz with related lvmdevices bug 2040482 that was filed about the same time.  All the lvmdevices fixes and both bz's should be handled together since they are all related.

Comment 2 Corey Marthaler 2022-02-11 03:07:09 UTC
This appears fixed in the latest build. This can be marked Modified and the Fixed In Version updated.

kernel-5.14.0-55.el9    BUILT: Fri Feb  4 05:27:31 PM CST 2022
lvm2-2.03.15-0.1.20211115git4a1f617.el9    BUILT: Tue Feb  8 02:56:52 PM CST 2022
lvm2-libs-2.03.15-0.1.20211115git4a1f617.el9    BUILT: Tue Feb  8 02:56:52 PM CST 2022



SCENARIO - altered_partition_check_and_repair:  Test the discovery and repair of an altered partition value in devicesfile entry (bug 2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1688.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdc1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291b9e01bad8691 DEVNAME=/dev/sdc1 PVID=YBfQDSEbkjJaK9db9RQcFjAfrFlOSoF3 PART=9 
Copying out altered system.devices file to hayes-01
/tmp/system433.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file sys_wwid naa.6d094660575ece002291b9e01bad8691 PVID YBfQDSEbkjJaK9db9RQcFjAfrFlOSoF3 last seen on /dev/sdc1 not found.

lvmdevices should have properly added /dev/sdc1 entry
lvmdevices should have properly returned non zero for a check issue

lvmdevices --adddev /dev/sdc1
  Devices file sys_wwid naa.6d094660575ece002291b9e01bad8691 PVID YBfQDSEbkjJaK9db9RQcFjAfrFlOSoF3 last seen on /dev/sdc1 not found.
  WARNING: adding device /dev/sdc1 with PVID YBfQDSEbkjJaK9db9RQcFjAfrFlOSoF3 which is already used for missing device.
  WARNING: adding device /dev/sdc1 with idname naa.6d094660575ece002291b9e01bad8691 which is already used for missing device.
Checking for segfault notification (bug 2040491)
lvmdevices --update
  No update for devices file is needed.

lvmdevices should have updated the partition change back
1.1.447 == 1.1.448
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291b9e01bad8691 DEVNAME=/dev/sdc1 PVID=YBfQDSEbkjJaK9db9RQcFjAfrFlOSoF3 PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system591.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --deldev /dev/sdc1

Comment 3 Corey Marthaler 2022-02-17 18:16:48 UTC
Marking Verified:Tested in the latest rpms.

kernel-5.14.0-58.el9    BUILT: Thu Feb 10 11:18:21 AM CST 2022
lvm2-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022
lvm2-libs-2.03.14-4.el9    BUILT: Wed Feb 16 06:01:21 AM CST 2022


SCENARIO - altered_partition_check_and_repair:  Test the discovery and repair of an altered partition value in devicesfile entry bugs 2039977|2040482 and --adddev segfault bugs 2040491|2040937 
Copying out blanked system.devices file to begin with
/tmp/system597.devices -> hayes-02:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdc1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=. PART=9 
Copying out altered system.devices file to hayes-02
/tmp/system37.devices -> hayes-02:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file sys_wwid naa.6d094660650d1e0022bd29ee1e0945a8 PVID none last seen on /dev/sdc1 not found.

lvmdevices should have properly returned non zero for a check issue

lvmdevices --update
  No update for devices file is needed.

lvmdevices should have updated the partition change back
lvmdevices --adddev /dev/sdc1
  Devices file sys_wwid naa.6d094660650d1e0022bd29ee1e0945a8 PVID none last seen on /dev/sdc1 not found.
  WARNING: adding device /dev/sdc1 with idname naa.6d094660650d1e0022bd29ee1e0945a8 which is already used for missing device.
Checking for segfault notification (bug 2040491|2040937)
1.1.16 == 1.1.17
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=. PART=1 
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=. PART=1 
Copying out altered system.devices file to hayes-02
/tmp/system389.devices -> hayes-02:/etc/lvm/devices/system.devices
lvmdevices --deldev /dev/sdc1

Comment 7 Corey Marthaler 2022-02-21 21:42:19 UTC
Marking VERIFIED based on comment #3 run on the latest build.

Comment 9 errata-xmlrpc 2022-05-17 15:56:34 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: lvm2), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3972

Comment 10 Red Hat Bugzilla 2023-09-15 01:51:05 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 365 days