Bug 2167370

Summary: LVM metadata is broken if device_id is set and contains a double quote
Product: Red Hat Enterprise Linux 9 Reporter: Lars <boers>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: LVM Metadata / lvmetad QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: high    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, teigland, zkabelac
Version: 9.1Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.21-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:53:27 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:
Attachments:
Description Flags
volume group backup none

Description Lars 2023-02-06 12:17:23 UTC
Created attachment 1942532 [details]
volume group backup

Description of problem:
LVM metadata is broken if device_id is set and contains a double quote `"`

Version-Release number of selected component (if applicable):
LVM2 version 2.03.16(2) (2022-05-18): Wed Feb  1 16:46:42 2023

How reproducible:
- install Rocky/Alma Linux 9.1 on a Broadwell system with Intel i3-5010U CPU, 4 GB RAM and 32 GB Innodisk 2.5" SATA SSD 3MG2-P
- do minimal installation and use LVM for disk partitioning
- the volume group uses all available space and assigns 10 GB to the root partition so that there are still ~14 GB available space in the volume group:

	[root@localhost ~]# vgs
	  VG #PV #LV #SN Attr   VSize   VFree  
	  rl   1   2   0 wz--n- <27.30g <14.41g

	[root@localhost ~]# lvs
	  LV   VG Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
	  root rl -wi-ao---- 10.00g                                                    
	  swap rl -wi-ao----  2.89g                                                    

	[root@localhost ~]# df -h
	  Filesystem           Size  Used Avail Use% Mounted on
	  devtmpfs             4.0M     0  4.0M   0% /dev
	  tmpfs                1.8G     0  1.8G   0% /dev/shm
	  tmpfs                713M  9.1M  704M   2% /run
	  /dev/mapper/rl-root   10G  1.1G  9.0G  11% /
	  /dev/sda2           1014M  214M  801M  22% /boot
	  /dev/sda1            599M  7.0M  592M   2% /boot/efi
	  tmpfs                357M     0  357M   0% /run/user/0

Steps to Reproduce:
Try to create a lvm snapshot of the root partiton:

	[root@localhost ~]# lvcreate -v -s rl/root -n root_snapshot -L 5G
	  Setting chunksize to 4.00 KiB.
	  Creating logical volume root_snapshot
	  Archiving volume group "rl" metadata (seqno 3).
	  Parse error at byte 401 (line 20): unexpected token
	  Error parsing metadata for VG rl.
	  Failed to write VG rl.

Actual results:
Failed to create the lvm snapshot.

Expected results:
lvm snapshot should be created.

Additional info:
Found while watching the lvm backup & archive files - in short / full backup is attached:

	# Generated by LVM2 version 2.03.16(2) (2022-05-18): Wed Feb  1 16:46:42 2023
	...
	rl {
		...
		physical_volumes {
			pv0 {
				id = "9iGP6J-AS0i-URS2-W5gV-t3pu-Fr1Z-Rj5myh"
				device = "/dev/sda3"	# Hint only

				device_id_type = "sys_wwid"
				device_id = "t10.ATA_____2.5"_SATA_SSD_3MG2-P____________________20161128AA0018230001"
				...
			}
		}
		logical_volumes {
			...
		}
	}

Comment 1 David Teigland 2023-02-06 18:47:02 UTC
fix in main
https://sourceware.org/git/?p=lvm2.git;a=commit;h=dc99f0def17b936f95c63612a56ae2a6ae81db0e


Reformatted test output from devicesfile-vpd-ids.sh:

$ mkdir -p /test/sys/dev/block/8:32/
$ echo "t10.ATA_2.5\"_SATA_SSD_1112-A___111111111111" > /test/sys/dev/block/8:32/wwid

$ lvmdevices --adddev /dev/sdc

$ cat /tmp/LVMTEST47875.lw0KIc9Bga/etc/devices/system.devices
 # LVM uses devices listed in this file.
 # Created by LVM command lvmdevices pid 48170 at Mon Feb  6 12:17:21 2023
 VERSION=1.1.1
 IDTYPE=sys_wwid IDNAME=t10.ATA_2.5_SATA_SSD_1112-A___111111111111 DEVNAME=/dev/sdc PVID=. 

$ vgcreate LVMTEST47875vg /dev/sdc
   Physical volume "/dev/sdc" successfully created.
   Volume group "LVMTEST47875vg" successfully created

$ lvcreate -l1 -an LVMTEST47875vg
   Logical volume "lvol0" created.

$ cat /tmp/LVMTEST47875.lw0KIc9Bga/etc/devices/system.devices
 # LVM uses devices listed in this file.
 # Created by LVM command vgcreate pid 48172 at Mon Feb  6 12:17:21 2023
 VERSION=1.1.2
 IDTYPE=sys_wwid IDNAME=t10.ATA_2.5_SATA_SSD_1112-A___111111111111 DEVNAME=/dev/sdc PVID=0SGGnXmf1WwGjjzApiNLxmt4tClh02IK

$ pvs -o+deviceidtype,deviceid /dev/sdc
   PV         VG             Fmt  Attr PSize  PFree DeviceIDType DeviceID
   /dev/sdc   LVMTEST47875vg lvm2 a--  12.00m 8.00m sys_wwid     t10.ATA_2.5_SATA_SSD_1112-A___111111111111

Comment 5 Corey Marthaler 2023-06-20 15:55:37 UTC
Marking Verified:Tested based on results provided in comment #1.

Comment 11 errata-xmlrpc 2023-11-07 08:53:27 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 (lvm2 bug fix and enhancement update), 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-2023:6633